diff --git a/hygon-hub/.dockerignore b/.dockerignore similarity index 100% rename from hygon-hub/.dockerignore rename to .dockerignore diff --git a/hygon-hub/.gitignore b/.gitignore similarity index 100% rename from hygon-hub/.gitignore rename to .gitignore diff --git a/hygon-hub/.pre-commit-config.yaml b/.pre-commit-config.yaml similarity index 100% rename from hygon-hub/.pre-commit-config.yaml rename to .pre-commit-config.yaml diff --git a/hygon-hub/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 100% rename from hygon-hub/CONTRIBUTING.md rename to CONTRIBUTING.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..35383bad06fbd7f78189005a8a7d56d85e608da0 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# Hygon-hub +海光测试镜像仓库。 + +## 贡献指南 +为了提升协作效率,本项目使用 [pre-commit](https://pre-commit.com/) 框架在每次提交前自动执行代码格式化与检查。具体使用方式请参考 [CONTRIBUTING.md](./CONTRIBUTING.md)。 + +## 镜像层级依赖关系 + +本项目的 Docker 镜像采用分层构建策略,各镜像之间存在依赖关系。下图展示了镜像的构建层级和目录位置: + +```mermaid +flowchart TD + A["🏭 Hygon PyTorch Base
harbor.sourcefind.cn:5443/dcu/admin/base/pytorch

"] + + B["📦 PyTorch Common Base
common/base/pytorch/

"] + + C["🚗 Autodrive
common/base/autodrive/

"] + D["💬 Megatron-LM
common/base/megatron/

"] + E["🎨 DiffSynth-Studio
common/base/diffsynth-studio/

"] + + F["Qwen3
models/Qwen2-3/

"] + G["Wan2.2, FLUX.2, ...
models/xxx/

"] + H["BEVFormer, ...
models/BEVFormer/

"] + + A --> B + B --> C & D & E + C --> H + D --> F + E --> G + + style A fill:#e1f5fe,stroke:#01579b,stroke-width:2px + style B fill:#fff3e0,stroke:#e65100,stroke-width:2px + style C fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px + style D fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px + style E fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px + style F fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px + style G fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px + style H fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px +``` + +### 镜像层级说明 + +| 层级 | 名称 | 说明 | 构建目录 | +|------|------|------|----------| +| L0 | 海光官方镜像 | 由海光提供的 PyTorch DCU 基础镜像 | - | +| L1 | PyTorch 公共镜像 | 包含 SSH、网络、环境变量等通用配置 | `common/base/pytorch/` | +| L2 | 框架公共镜像 | 面向特定领域的框架镜像(自动驾驶/LLM/生成模型) | `common/base//` | +| L3 | 模型镜像 | 特定模型的训练镜像 | `models//` | + +### 构建顺序 + +构建镜像时需要按照依赖顺序进行: + +1. **L1**: 先构建 `common/base/pytorch/dockerfile`,生成 `pytorch2.7.1_dtk26.04_v2.0_Hygon` +2. **L2**: 再构建框架镜像(如 `common/base/autodrive/dockerfile`),生成 `mmcv1.6_dtk26.04_v2.0_Hygon` +3. **L3**: 最后构建具体模型镜像(如 `models/BEVFormer/dockerfile`) + +> 构建时直接使用 Dockerfile 中配置的内部源或随模型目录携带的必要 wheel,不再需要启动本地包服务。 + +> ⚠️ **注意**: 构建下层镜像前,请确保其依赖的上层镜像已经构建完成并正确推送到镜像仓库。 + + +## 项目目录结构 + +``` +TrainingPerfBench/ +├── common/ # 公共文件 +│ ├── base/ # 基础框架镜像目录 +│ │ ├── diffsynth-studio/ # DiffSynthStudio 目录 +│ │ │ ├── DiffSynth-Studio/ # DiffSynthStudio 项目源码 +│ │ │ ├── dockerfile # DiffSynthStudio 基础镜像 dockerfile +│ │ │ └── README.md # 镜像构建命令 +│ │ │ +│ │ ├── megatron/ # Megatron-LM 目录 +│ │ │ ├── Megatron-LM/ # Megatron-LM 项目源码 +│ │ │ ├── dockerfile # Megatron-LM 基础镜像 dockerfile +│ │ │ └── README.md # 镜像构建命令 +│ │ └── ... +│ │ +│ └── utils/ # 通用工具脚本 +│ ├── download_utils.sh +│ └── run_cmd.sh +│ +├── models/ # 模型特定训练镜像 +│ ├── Qwen2-3/ # Qwen 2/3 训练 +│ │ ├── dockerfile +│ │ ├── train_qwen.sh +│ │ ├── download_datasets.sh +│ │ └── README.md # 镜像构建命令 +│ │ +│ ├── Qwen2.5VL/ # Qwen 2.5 多模态视觉语言模型 +│ ├── Wan2/ # Wan2 模型 +│ └── ... +│ +├── .dockerignore +├── .gitignore +├── .gitmodules +└── README.md + +``` diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.clang-format b/common/base/autodrive/3rdparty/detectron2/.clang-format similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.clang-format rename to common/base/autodrive/3rdparty/detectron2/.clang-format diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.flake8 b/common/base/autodrive/3rdparty/detectron2/.flake8 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.flake8 rename to common/base/autodrive/3rdparty/detectron2/.flake8 diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/CODE_OF_CONDUCT.md b/common/base/autodrive/3rdparty/detectron2/.github/CODE_OF_CONDUCT.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/CODE_OF_CONDUCT.md rename to common/base/autodrive/3rdparty/detectron2/.github/CODE_OF_CONDUCT.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/CONTRIBUTING.md b/common/base/autodrive/3rdparty/detectron2/.github/CONTRIBUTING.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/CONTRIBUTING.md rename to common/base/autodrive/3rdparty/detectron2/.github/CONTRIBUTING.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/Detectron2-Logo-Horz.svg b/common/base/autodrive/3rdparty/detectron2/.github/Detectron2-Logo-Horz.svg similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/Detectron2-Logo-Horz.svg rename to common/base/autodrive/3rdparty/detectron2/.github/Detectron2-Logo-Horz.svg diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE.md b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE.md rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/bugs.md b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/bugs.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/bugs.md rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/bugs.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/config.yml b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/config.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/config.yml rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/config.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/documentation.md b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/documentation.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/documentation.md rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/documentation.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/feature-request.md b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/feature-request.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/feature-request.md rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/feature-request.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md b/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md rename to common/base/autodrive/3rdparty/detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2_win/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2_win/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2_win/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/install_detectron2_win/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_dep/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_dep/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_dep/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_dep/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_gpu_dep/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_gpu_dep/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_gpu_dep/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/install_linux_gpu_dep/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_windows_dep/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/install_windows_dep/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/install_windows_dep/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/install_windows_dep/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests_win/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests_win/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests_win/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/run_unittests_win/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/uninstall_tests/action.yml b/common/base/autodrive/3rdparty/detectron2/.github/actions/uninstall_tests/action.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/actions/uninstall_tests/action.yml rename to common/base/autodrive/3rdparty/detectron2/.github/actions/uninstall_tests/action.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/import-tests.sh b/common/base/autodrive/3rdparty/detectron2/.github/import-tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/import-tests.sh rename to common/base/autodrive/3rdparty/detectron2/.github/import-tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/pull_request_template.md b/common/base/autodrive/3rdparty/detectron2/.github/pull_request_template.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/pull_request_template.md rename to common/base/autodrive/3rdparty/detectron2/.github/pull_request_template.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/check-template.yml b/common/base/autodrive/3rdparty/detectron2/.github/workflows/check-template.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/check-template.yml rename to common/base/autodrive/3rdparty/detectron2/.github/workflows/check-template.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/levenshtein.js b/common/base/autodrive/3rdparty/detectron2/.github/workflows/levenshtein.js similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/levenshtein.js rename to common/base/autodrive/3rdparty/detectron2/.github/workflows/levenshtein.js diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/needs-reply.yml b/common/base/autodrive/3rdparty/detectron2/.github/workflows/needs-reply.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/needs-reply.yml rename to common/base/autodrive/3rdparty/detectron2/.github/workflows/needs-reply.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/remove-needs-reply.yml b/common/base/autodrive/3rdparty/detectron2/.github/workflows/remove-needs-reply.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/remove-needs-reply.yml rename to common/base/autodrive/3rdparty/detectron2/.github/workflows/remove-needs-reply.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/workflow.yml b/common/base/autodrive/3rdparty/detectron2/.github/workflows/workflow.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.github/workflows/workflow.yml rename to common/base/autodrive/3rdparty/detectron2/.github/workflows/workflow.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/.gitignore b/common/base/autodrive/3rdparty/detectron2/.gitignore similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/.gitignore rename to common/base/autodrive/3rdparty/detectron2/.gitignore diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/GETTING_STARTED.md b/common/base/autodrive/3rdparty/detectron2/GETTING_STARTED.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/GETTING_STARTED.md rename to common/base/autodrive/3rdparty/detectron2/GETTING_STARTED.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/INSTALL.md b/common/base/autodrive/3rdparty/detectron2/INSTALL.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/INSTALL.md rename to common/base/autodrive/3rdparty/detectron2/INSTALL.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/LICENSE b/common/base/autodrive/3rdparty/detectron2/LICENSE similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/LICENSE rename to common/base/autodrive/3rdparty/detectron2/LICENSE diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/MODEL_ZOO.md b/common/base/autodrive/3rdparty/detectron2/MODEL_ZOO.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/MODEL_ZOO.md rename to common/base/autodrive/3rdparty/detectron2/MODEL_ZOO.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/README.md b/common/base/autodrive/3rdparty/detectron2/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/README.md rename to common/base/autodrive/3rdparty/detectron2/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-C4.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-C4.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-C4.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-C4.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-DilatedC5.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-DilatedC5.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-DilatedC5.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-DilatedC5.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Base-RCNN-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RetinaNet.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Base-RetinaNet.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Base-RetinaNet.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Base-RetinaNet.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fcos_R_50_FPN_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fcos_R_50_FPN_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fcos_R_50_FPN_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/fcos_R_50_FPN_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_C4_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_C4_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_C4_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_C4_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Detection/rpn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/Base-Keypoint-RCNN-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/Base-Keypoint-RCNN-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/Base-Keypoint-RCNN-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/Base-Keypoint-RCNN-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Cityscapes/mask_rcnn_R_50_FPN.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Cityscapes/mask_rcnn_R_50_FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Cityscapes/mask_rcnn_R_50_FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Cityscapes/mask_rcnn_R_50_FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/README.md b/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/README.md rename to common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mmdet_mask_rcnn_R_50_FPN_1x.py b/common/base/autodrive/3rdparty/detectron2/configs/Misc/mmdet_mask_rcnn_R_50_FPN_1x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/mmdet_mask_rcnn_R_50_FPN_1x.py rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/mmdet_mask_rcnn_R_50_FPN_1x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/semantic_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/configs/Misc/semantic_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/semantic_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/semantic_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/torchvision_imagenet_R_50.py b/common/base/autodrive/3rdparty/detectron2/configs/Misc/torchvision_imagenet_R_50.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/Misc/torchvision_imagenet_R_50.py rename to common/base/autodrive/3rdparty/detectron2/configs/Misc/torchvision_imagenet_R_50.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml b/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml b/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/README.md b/common/base/autodrive/3rdparty/detectron2/configs/common/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/README.md rename to common/base/autodrive/3rdparty/detectron2/configs/common/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/coco_schedule.py b/common/base/autodrive/3rdparty/detectron2/configs/common/coco_schedule.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/coco_schedule.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/coco_schedule.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco.py b/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/data/coco.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_keypoint.py b/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_keypoint.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_keypoint.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_keypoint.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_panoptic_separated.py b/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_panoptic_separated.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_panoptic_separated.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/data/coco_panoptic_separated.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/constants.py b/common/base/autodrive/3rdparty/detectron2/configs/common/data/constants.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/data/constants.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/data/constants.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/cascade_rcnn.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/cascade_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/cascade_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/cascade_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/fcos.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/fcos.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/fcos.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/fcos.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/keypoint_rcnn_fpn.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/keypoint_rcnn_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/keypoint_rcnn_fpn.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/keypoint_rcnn_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_c4.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_c4.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_c4.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_c4.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_fpn.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_fpn.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_vitdet.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_vitdet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_vitdet.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/mask_rcnn_vitdet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/panoptic_fpn.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/panoptic_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/panoptic_fpn.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/panoptic_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/retinanet.py b/common/base/autodrive/3rdparty/detectron2/configs/common/models/retinanet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/models/retinanet.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/models/retinanet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/optim.py b/common/base/autodrive/3rdparty/detectron2/configs/common/optim.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/optim.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/optim.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/train.py b/common/base/autodrive/3rdparty/detectron2/configs/common/train.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/common/train.py rename to common/base/autodrive/3rdparty/detectron2/configs/common/train.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py b/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py rename to common/base/autodrive/3rdparty/detectron2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/README.md b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/README.md rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/fast_rcnn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_GCV_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_GCV_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_GCV_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_GCV_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_C4_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_DC5_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_DC5_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_DC5_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_DC5_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/panoptic_fpn_R_50_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/retinanet_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/rpn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/configs/quick_schedules/semantic_R_50_FPN_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/README.md b/common/base/autodrive/3rdparty/detectron2/datasets/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/README.md rename to common/base/autodrive/3rdparty/detectron2/datasets/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_ade20k_sem_seg.py b/common/base/autodrive/3rdparty/detectron2/datasets/prepare_ade20k_sem_seg.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_ade20k_sem_seg.py rename to common/base/autodrive/3rdparty/detectron2/datasets/prepare_ade20k_sem_seg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_cocofied_lvis.py b/common/base/autodrive/3rdparty/detectron2/datasets/prepare_cocofied_lvis.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_cocofied_lvis.py rename to common/base/autodrive/3rdparty/detectron2/datasets/prepare_cocofied_lvis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_for_tests.sh b/common/base/autodrive/3rdparty/detectron2/datasets/prepare_for_tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_for_tests.sh rename to common/base/autodrive/3rdparty/detectron2/datasets/prepare_for_tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_panoptic_fpn.py b/common/base/autodrive/3rdparty/detectron2/datasets/prepare_panoptic_fpn.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/datasets/prepare_panoptic_fpn.py rename to common/base/autodrive/3rdparty/detectron2/datasets/prepare_panoptic_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/README.md b/common/base/autodrive/3rdparty/detectron2/demo/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/README.md rename to common/base/autodrive/3rdparty/detectron2/demo/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/demo.py b/common/base/autodrive/3rdparty/detectron2/demo/demo.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/demo.py rename to common/base/autodrive/3rdparty/detectron2/demo/demo.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/predictor.py b/common/base/autodrive/3rdparty/detectron2/demo/predictor.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/demo/predictor.py rename to common/base/autodrive/3rdparty/detectron2/demo/predictor.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/c2_model_loading.py b/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/c2_model_loading.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/c2_model_loading.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/c2_model_loading.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/catalog.py b/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/catalog.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/catalog.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/catalog.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/detection_checkpoint.py b/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/detection_checkpoint.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/detection_checkpoint.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/checkpoint/detection_checkpoint.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/compat.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/compat.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/compat.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/compat.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/config.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/config.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/defaults.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/defaults.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/defaults.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/defaults.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/instantiate.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/instantiate.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/instantiate.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/instantiate.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/lazy.py b/common/base/autodrive/3rdparty/detectron2/detectron2/config/lazy.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/config/lazy.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/config/lazy.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/benchmark.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/benchmark.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/benchmark.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/benchmark.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/build.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/build.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/catalog.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/catalog.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/catalog.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/catalog.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/common.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/common.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/common.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/common.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/dataset_mapper.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/dataset_mapper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/dataset_mapper.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/dataset_mapper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/README.md b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/README.md rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin_meta.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin_meta.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin_meta.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/builtin_meta.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes_panoptic.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes_panoptic.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes_panoptic.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/cityscapes_panoptic.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco_panoptic.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco_panoptic.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco_panoptic.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/coco_panoptic.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v0_5_categories.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v0_5_categories.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v0_5_categories.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v0_5_categories.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_categories.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_categories.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_categories.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_categories.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_category_image_count.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_category_image_count.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_category_image_count.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/lvis_v1_category_image_count.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/pascal_voc.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/pascal_voc.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/pascal_voc.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/pascal_voc.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/register_coco.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/register_coco.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/register_coco.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/datasets/register_coco.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/detection_utils.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/detection_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/detection_utils.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/detection_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/distributed_sampler.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/distributed_sampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/distributed_sampler.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/distributed_sampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/grouped_batch_sampler.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/grouped_batch_sampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/grouped_batch_sampler.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/samplers/grouped_batch_sampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation_impl.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation_impl.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation_impl.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/augmentation_impl.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/transform.py b/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/transform.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/data/transforms/transform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/engine/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/engine/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/defaults.py b/common/base/autodrive/3rdparty/detectron2/detectron2/engine/defaults.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/defaults.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/engine/defaults.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/hooks.py b/common/base/autodrive/3rdparty/detectron2/detectron2/engine/hooks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/hooks.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/engine/hooks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/launch.py b/common/base/autodrive/3rdparty/detectron2/detectron2/engine/launch.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/launch.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/engine/launch.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/train_loop.py b/common/base/autodrive/3rdparty/detectron2/detectron2/engine/train_loop.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/engine/train_loop.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/engine/train_loop.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/cityscapes_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/cityscapes_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/cityscapes_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/cityscapes_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/coco_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/coco_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/coco_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/coco_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/evaluator.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/evaluator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/evaluator.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/evaluator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/fast_eval_api.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/fast_eval_api.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/fast_eval_api.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/fast_eval_api.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/lvis_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/lvis_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/lvis_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/lvis_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/panoptic_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/panoptic_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/panoptic_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/panoptic_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/pascal_voc_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/pascal_voc_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/pascal_voc_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/pascal_voc_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/rotated_coco_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/rotated_coco_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/rotated_coco_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/rotated_coco_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/sem_seg_evaluation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/sem_seg_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/sem_seg_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/sem_seg_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/testing.py b/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/testing.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/testing.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/evaluation/testing.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/README.md b/common/base/autodrive/3rdparty/detectron2/detectron2/export/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/README.md rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/api.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/api.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/api.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/api.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/c10.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/c10.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/c10.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/c10.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_export.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_export.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_export.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_export.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_inference.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_inference.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_inference.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_inference.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_modeling.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_modeling.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_modeling.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_modeling.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_patch.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_patch.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_patch.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/caffe2_patch.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/flatten.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/flatten.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/flatten.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/flatten.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/shared.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/shared.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/shared.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/shared.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript_patch.py b/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript_patch.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript_patch.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/export/torchscript_patch.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/aspp.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/aspp.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/aspp.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/aspp.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/batch_norm.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/batch_norm.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/batch_norm.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/batch_norm.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/blocks.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/blocks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/blocks.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/blocks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/README.md b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/README.md rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cuda.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cuda.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cuda.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cuda.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_utils.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_utils.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_utils.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_utils.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cuda_version.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cuda_version.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cuda_version.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/cuda_version.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda_kernel.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda_kernel.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda_kernel.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/deformable/deform_conv_cuda_kernel.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated.h b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated.h rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/vision.cpp b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/vision.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/vision.cpp rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/csrc/vision.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/deform_conv.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/deform_conv.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/deform_conv.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/deform_conv.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/losses.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/losses.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/losses.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/losses.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/mask_ops.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/mask_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/mask_ops.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/mask_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/nms.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/nms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/nms.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/nms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align_rotated.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align_rotated.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align_rotated.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/roi_align_rotated.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/rotated_boxes.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/rotated_boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/rotated_boxes.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/rotated_boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/shape_spec.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/shape_spec.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/shape_spec.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/shape_spec.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/wrappers.py b/common/base/autodrive/3rdparty/detectron2/detectron2/layers/wrappers.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/layers/wrappers.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/layers/wrappers.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/model_zoo.py b/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/model_zoo.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/model_zoo.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/model_zoo/model_zoo.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/anchor_generator.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/anchor_generator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/anchor_generator.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/anchor_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/backbone.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/backbone.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/backbone.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/backbone.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/build.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/build.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/fpn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/fpn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/mvit.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/mvit.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/mvit.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/mvit.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/regnet.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/regnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/regnet.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/regnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/resnet.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/resnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/resnet.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/resnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/swin.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/swin.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/swin.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/swin.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/utils.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/utils.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/vit.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/vit.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/vit.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/backbone/vit.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/box_regression.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/box_regression.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/box_regression.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/box_regression.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/matcher.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/matcher.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/matcher.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/matcher.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/build.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/build.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/dense_detector.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/dense_detector.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/dense_detector.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/dense_detector.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/fcos.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/fcos.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/fcos.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/fcos.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/panoptic_fpn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/panoptic_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/panoptic_fpn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/panoptic_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/rcnn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/rcnn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/retinanet.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/retinanet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/retinanet.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/retinanet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/semantic_seg.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/semantic_seg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/semantic_seg.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/meta_arch/semantic_seg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/mmdet_wrapper.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/mmdet_wrapper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/mmdet_wrapper.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/mmdet_wrapper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/poolers.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/poolers.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/poolers.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/poolers.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/postprocessing.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/postprocessing.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/postprocessing.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/postprocessing.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/build.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/build.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/proposal_utils.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/proposal_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/proposal_utils.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/proposal_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rpn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rpn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rrpn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rrpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rrpn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/proposal_generator/rrpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/box_head.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/box_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/box_head.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/box_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/cascade_rcnn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/cascade_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/cascade_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/cascade_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/fast_rcnn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/fast_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/fast_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/fast_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/keypoint_head.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/keypoint_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/keypoint_head.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/keypoint_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/mask_head.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/mask_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/mask_head.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/mask_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/roi_heads.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/roi_heads.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/roi_heads.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/roi_heads.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/rotated_fast_rcnn.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/rotated_fast_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/rotated_fast_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/roi_heads/rotated_fast_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/sampling.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/sampling.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/sampling.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/sampling.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/test_time_augmentation.py b/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/test_time_augmentation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/modeling/test_time_augmentation.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/modeling/test_time_augmentation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/projects/README.md b/common/base/autodrive/3rdparty/detectron2/detectron2/projects/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/projects/README.md rename to common/base/autodrive/3rdparty/detectron2/detectron2/projects/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/projects/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/projects/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/projects/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/projects/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/solver/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/solver/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/build.py b/common/base/autodrive/3rdparty/detectron2/detectron2/solver/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/build.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/solver/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/lr_scheduler.py b/common/base/autodrive/3rdparty/detectron2/detectron2/solver/lr_scheduler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/solver/lr_scheduler.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/solver/lr_scheduler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/boxes.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/boxes.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/image_list.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/image_list.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/image_list.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/image_list.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/instances.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/instances.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/instances.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/instances.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/keypoints.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/keypoints.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/keypoints.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/keypoints.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/masks.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/masks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/masks.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/masks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/rotated_boxes.py b/common/base/autodrive/3rdparty/detectron2/detectron2/structures/rotated_boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/structures/rotated_boxes.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/structures/rotated_boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/base_tracker.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/base_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/base_tracker.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/base_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/hungarian_tracker.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/hungarian_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/hungarian_tracker.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/hungarian_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/utils.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/utils.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/README.md b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/README.md rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/__init__.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/__init__.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/analysis.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/analysis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/analysis.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/analysis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/collect_env.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/collect_env.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/collect_env.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/collect_env.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/colormap.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/colormap.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/colormap.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/colormap.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/comm.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/comm.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/comm.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/comm.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/develop.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/develop.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/develop.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/develop.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/env.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/env.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/env.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/env.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/events.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/events.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/events.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/events.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/file_io.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/file_io.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/file_io.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/file_io.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/logger.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/logger.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/logger.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/logger.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/memory.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/memory.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/memory.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/memory.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/registry.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/registry.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/registry.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/registry.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/serialize.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/serialize.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/serialize.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/serialize.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/testing.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/testing.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/testing.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/testing.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/torch_version_utils.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/torch_version_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/torch_version_utils.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/torch_version_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/tracing.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/tracing.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/tracing.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/tracing.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/video_visualizer.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/video_visualizer.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/video_visualizer.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/video_visualizer.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/visualizer.py b/common/base/autodrive/3rdparty/detectron2/detectron2/utils/visualizer.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/detectron2/utils/visualizer.py rename to common/base/autodrive/3rdparty/detectron2/detectron2/utils/visualizer.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/README.md b/common/base/autodrive/3rdparty/detectron2/dev/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/README.md rename to common/base/autodrive/3rdparty/detectron2/dev/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/linter.sh b/common/base/autodrive/3rdparty/detectron2/dev/linter.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/linter.sh rename to common/base/autodrive/3rdparty/detectron2/dev/linter.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/README.md b/common/base/autodrive/3rdparty/detectron2/dev/packaging/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/README.md rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_all_wheels.sh b/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_all_wheels.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_all_wheels.sh rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/build_all_wheels.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_wheel.sh b/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_wheel.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/build_wheel.sh rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/build_wheel.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_install_table.py b/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_install_table.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_install_table.py rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_install_table.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_wheel_index.sh b/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_wheel_index.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_wheel_index.sh rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/gen_wheel_index.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/pkg_helpers.bash b/common/base/autodrive/3rdparty/detectron2/dev/packaging/pkg_helpers.bash old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/packaging/pkg_helpers.bash rename to common/base/autodrive/3rdparty/detectron2/dev/packaging/pkg_helpers.bash diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/parse_results.sh b/common/base/autodrive/3rdparty/detectron2/dev/parse_results.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/parse_results.sh rename to common/base/autodrive/3rdparty/detectron2/dev/parse_results.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/run_inference_tests.sh b/common/base/autodrive/3rdparty/detectron2/dev/run_inference_tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/run_inference_tests.sh rename to common/base/autodrive/3rdparty/detectron2/dev/run_inference_tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/run_instant_tests.sh b/common/base/autodrive/3rdparty/detectron2/dev/run_instant_tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/dev/run_instant_tests.sh rename to common/base/autodrive/3rdparty/detectron2/dev/run_instant_tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/Dockerfile b/common/base/autodrive/3rdparty/detectron2/docker/Dockerfile similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/Dockerfile rename to common/base/autodrive/3rdparty/detectron2/docker/Dockerfile diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/README.md b/common/base/autodrive/3rdparty/detectron2/docker/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/README.md rename to common/base/autodrive/3rdparty/detectron2/docker/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/deploy.Dockerfile b/common/base/autodrive/3rdparty/detectron2/docker/deploy.Dockerfile similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/deploy.Dockerfile rename to common/base/autodrive/3rdparty/detectron2/docker/deploy.Dockerfile diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/docker-compose.yml b/common/base/autodrive/3rdparty/detectron2/docker/docker-compose.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docker/docker-compose.yml rename to common/base/autodrive/3rdparty/detectron2/docker/docker-compose.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/.gitignore b/common/base/autodrive/3rdparty/detectron2/docs/.gitignore similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/.gitignore rename to common/base/autodrive/3rdparty/detectron2/docs/.gitignore diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/Makefile b/common/base/autodrive/3rdparty/detectron2/docs/Makefile similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/Makefile rename to common/base/autodrive/3rdparty/detectron2/docs/Makefile diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/README.md b/common/base/autodrive/3rdparty/detectron2/docs/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/README.md rename to common/base/autodrive/3rdparty/detectron2/docs/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/_static/css/custom.css b/common/base/autodrive/3rdparty/detectron2/docs/_static/css/custom.css similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/_static/css/custom.css rename to common/base/autodrive/3rdparty/detectron2/docs/_static/css/custom.css diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/conf.py b/common/base/autodrive/3rdparty/detectron2/docs/conf.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/conf.py rename to common/base/autodrive/3rdparty/detectron2/docs/conf.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/index.rst b/common/base/autodrive/3rdparty/detectron2/docs/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/index.rst rename to common/base/autodrive/3rdparty/detectron2/docs/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/checkpoint.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/checkpoint.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/checkpoint.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/checkpoint.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/config.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/config.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/config.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/config.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/data.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/data.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/data.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/data.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/data_transforms.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/data_transforms.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/data_transforms.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/data_transforms.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/engine.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/engine.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/engine.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/engine.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/evaluation.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/evaluation.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/evaluation.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/evaluation.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/export.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/export.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/export.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/export.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/fvcore.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/fvcore.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/fvcore.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/fvcore.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/index.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/index.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/layers.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/layers.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/layers.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/layers.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/model_zoo.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/model_zoo.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/model_zoo.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/model_zoo.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/modeling.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/modeling.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/modeling.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/modeling.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/solver.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/solver.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/solver.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/solver.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/structures.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/structures.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/structures.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/structures.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/utils.rst b/common/base/autodrive/3rdparty/detectron2/docs/modules/utils.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/modules/utils.rst rename to common/base/autodrive/3rdparty/detectron2/docs/modules/utils.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/benchmarks.md b/common/base/autodrive/3rdparty/detectron2/docs/notes/benchmarks.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/benchmarks.md rename to common/base/autodrive/3rdparty/detectron2/docs/notes/benchmarks.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/changelog.md b/common/base/autodrive/3rdparty/detectron2/docs/notes/changelog.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/changelog.md rename to common/base/autodrive/3rdparty/detectron2/docs/notes/changelog.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/compatibility.md b/common/base/autodrive/3rdparty/detectron2/docs/notes/compatibility.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/compatibility.md rename to common/base/autodrive/3rdparty/detectron2/docs/notes/compatibility.md diff --git a/common/base/autodrive/3rdparty/detectron2/docs/notes/contributing.md b/common/base/autodrive/3rdparty/detectron2/docs/notes/contributing.md new file mode 120000 index 0000000000000000000000000000000000000000..95181235eaff1cb5cbb2dc554e8d4991b603d0e5 --- /dev/null +++ b/common/base/autodrive/3rdparty/detectron2/docs/notes/contributing.md @@ -0,0 +1 @@ +../../.github/CONTRIBUTING.md \ No newline at end of file diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/index.rst b/common/base/autodrive/3rdparty/detectron2/docs/notes/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/notes/index.rst rename to common/base/autodrive/3rdparty/detectron2/docs/notes/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/requirements.txt b/common/base/autodrive/3rdparty/detectron2/docs/requirements.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/requirements.txt rename to common/base/autodrive/3rdparty/detectron2/docs/requirements.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/README.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/README.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/augmentation.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/augmentation.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/augmentation.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/augmentation.md diff --git a/common/base/autodrive/3rdparty/detectron2/docs/tutorials/builtin_datasets.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/builtin_datasets.md new file mode 120000 index 0000000000000000000000000000000000000000..0ba82423ad498bdd86274ada56a201134a590d94 --- /dev/null +++ b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/builtin_datasets.md @@ -0,0 +1 @@ +../../datasets/README.md \ No newline at end of file diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/configs.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/configs.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/configs.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/configs.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/data_loading.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/data_loading.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/data_loading.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/data_loading.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/datasets.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/datasets.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/datasets.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/datasets.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/deployment.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/deployment.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/deployment.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/deployment.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/evaluation.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/evaluation.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/evaluation.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/evaluation.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/extend.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/extend.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/extend.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/extend.md diff --git a/common/base/autodrive/3rdparty/detectron2/docs/tutorials/getting_started.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/getting_started.md new file mode 120000 index 0000000000000000000000000000000000000000..e90bde77a3197b77f4cfdce86ca8f96491650acd --- /dev/null +++ b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/getting_started.md @@ -0,0 +1 @@ +../../GETTING_STARTED.md \ No newline at end of file diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/index.rst b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/index.rst rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/index.rst diff --git a/common/base/autodrive/3rdparty/detectron2/docs/tutorials/install.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/install.md new file mode 120000 index 0000000000000000000000000000000000000000..5f52b2be3c9650cfc3e16ffb8fa374d3fcbad371 --- /dev/null +++ b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/install.md @@ -0,0 +1 @@ +../../INSTALL.md \ No newline at end of file diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/lazyconfigs.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/lazyconfigs.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/lazyconfigs.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/lazyconfigs.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/models.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/models.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/models.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/models.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/training.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/training.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/training.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/training.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/write-models.md b/common/base/autodrive/3rdparty/detectron2/docs/tutorials/write-models.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/docs/tutorials/write-models.md rename to common/base/autodrive/3rdparty/detectron2/docs/tutorials/write-models.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/README.md b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/Base-DeepLabV3-OS16-Semantic.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/Base-DeepLabV3-OS16-Semantic.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/Base-DeepLabV3-OS16-Semantic.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/Base-DeepLabV3-OS16-Semantic.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/build_solver.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/build_solver.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/build_solver.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/build_solver.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/config.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/loss.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/loss.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/loss.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/loss.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/lr_scheduler.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/lr_scheduler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/lr_scheduler.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/lr_scheduler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/resnet.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/resnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/resnet.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/resnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/semantic_seg.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/semantic_seg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/semantic_seg.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/deeplab/semantic_seg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DeepLab/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/DeepLab/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/README.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/apply_net.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/apply_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/apply_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/apply_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/Base-DensePose-RCNN-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/Base-DensePose-RCNN-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/Base-DensePose-RCNN-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/Base-DensePose-RCNN-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN-Human.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN-Human.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN-Human.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN-Human.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/Base-DensePose-RCNN-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_soft_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_soft_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_soft_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_soft_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_16k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_16k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_16k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_16k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_4k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_4k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_4k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_4k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_16k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_16k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_16k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_16k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_i2m_16k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_i2m_16k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_i2m_16k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_i2m_16k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_m2m_16k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_m2m_16k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_m2m_16k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_m2m_16k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_16k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_16k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_16k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_16k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_4k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_4k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_4k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_4k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_maskonly_24k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_maskonly_24k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_maskonly_24k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_maskonly_24k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x_legacy.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x_legacy.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x_legacy.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x_legacy.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2M_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2M_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2M_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2M_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x_legacy.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x_legacy.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x_legacy.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x_legacy.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/Base-RCNN-FPN-Atop10P_CA.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/Base-RCNN-FPN-Atop10P_CA.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/Base-RCNN-FPN-Atop10P_CA.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/Base-RCNN-FPN-Atop10P_CA.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_coarsesegm.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_coarsesegm.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_coarsesegm.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_coarsesegm.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_finesegm.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_finesegm.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_finesegm.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_finesegm.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uniform.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uniform.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uniform.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uniform.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uv.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uv.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uv.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uv.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_DL_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_DL_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_DL_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_DL_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_soft_animals_finetune_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_DL_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_DL_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_DL_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_DL_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC1_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC1_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC1_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC1_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC2_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC2_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC2_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC2_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_inference_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_inference_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_inference_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_inference_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_instant_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_instant_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_instant_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_instant_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_training_acc_test.yaml b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_training_acc_test.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_training_acc_test.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_training_acc_test.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/config.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/base.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/base.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/builtin.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/builtin.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/builtin.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/builtin.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_hflip.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_hflip.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_hflip.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_hflip.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_to_chart_result.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_to_chart_result.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_to_chart_result.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/chart_output_to_chart_result.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/hflip.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/hflip.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/hflip.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/hflip.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/segm_to_mask.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/segm_to_mask.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/segm_to_mask.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/segm_to_mask.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_chart_result.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_chart_result.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_chart_result.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_chart_result.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_mask.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_mask.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_mask.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/converters/to_mask.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/build.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/build.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/combined_loader.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/combined_loader.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/combined_loader.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/combined_loader.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/dataset_mapper.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/dataset_mapper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/dataset_mapper.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/dataset_mapper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/builtin.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/builtin.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/builtin.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/builtin.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/chimpnsee.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/chimpnsee.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/chimpnsee.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/chimpnsee.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/coco.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/coco.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/coco.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/coco.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/dataset_type.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/dataset_type.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/dataset_type.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/dataset_type.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/lvis.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/lvis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/lvis.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/datasets/lvis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/image_list_dataset.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/image_list_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/image_list_dataset.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/image_list_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/inference_based_loader.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/inference_based_loader.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/inference_based_loader.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/inference_based_loader.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/builtin.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/builtin.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/builtin.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/builtin.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/catalog.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/catalog.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/catalog.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/meshes/catalog.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_base.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_base.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_confidence_based.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_confidence_based.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_confidence_based.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_confidence_based.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_base.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_base.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_confidence_based.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_confidence_based.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_confidence_based.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_confidence_based.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_uniform.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_uniform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_uniform.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_cse_uniform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_uniform.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_uniform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_uniform.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/densepose_uniform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/mask_from_densepose.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/mask_from_densepose.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/mask_from_densepose.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/mask_from_densepose.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/prediction_to_gt.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/prediction_to_gt.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/prediction_to_gt.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/samplers/prediction_to_gt.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/image.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/image.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/image.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/transform/image.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/utils.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/frame_selector.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/frame_selector.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/frame_selector.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/frame_selector.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/video_keyframe_dataset.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/video_keyframe_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/video_keyframe_dataset.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/data/video/video_keyframe_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/trainer.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/trainer.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/trainer.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/engine/trainer.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/d2_evaluator_adapter.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/d2_evaluator_adapter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/d2_evaluator_adapter.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/d2_evaluator_adapter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/densepose_coco_evaluation.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/densepose_coco_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/densepose_coco_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/densepose_coco_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/evaluator.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/evaluator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/evaluator.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/evaluator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/mesh_alignment_evaluator.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/mesh_alignment_evaluator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/mesh_alignment_evaluator.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/mesh_alignment_evaluator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/tensor_storage.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/tensor_storage.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/tensor_storage.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/evaluation/tensor_storage.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/build.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/build.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/build.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/build.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/embedder.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/embedder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/embedder.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/embedder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/utils.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_direct_embedder.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_direct_embedder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_direct_embedder.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_direct_embedder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_feature_embedder.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_feature_embedder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_feature_embedder.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/cse/vertex_feature_embedder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/densepose_checkpoint.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/densepose_checkpoint.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/densepose_checkpoint.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/densepose_checkpoint.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/filter.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/filter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/filter.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/filter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrfpn.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrfpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrfpn.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrfpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrnet.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrnet.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/hrnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/inference.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/inference.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/inference.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/inference.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart_with_confidences.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart_with_confidences.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart_with_confidences.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/chart_with_confidences.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cse.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cse.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cse.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cse.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_pix2shape.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_pix2shape.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_pix2shape.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_pix2shape.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_shape2shape.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_shape2shape.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_shape2shape.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/cycle_shape2shape.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed_utils.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed_utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/embed_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask_or_segm.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask_or_segm.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask_or_segm.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/mask_or_segm.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/registry.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/registry.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/registry.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/registry.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/segm.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/segm.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/segm.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/segm.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/soft_embed.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/soft_embed.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/soft_embed.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/soft_embed.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/utils.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/losses/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_with_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_with_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_with_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/chart_with_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_with_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_with_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_with_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/cse_with_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/registry.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/registry.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/registry.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/predictors/registry.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/deeplab.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/deeplab.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/deeplab.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/deeplab.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/registry.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/registry.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/registry.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/registry.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/roi_head.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/roi_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/roi_head.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/roi_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/v1convx.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/v1convx.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/v1convx.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/roi_heads/v1convx.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/test_time_augmentation.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/test_time_augmentation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/test_time_augmentation.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/test_time_augmentation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/utils.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/modeling/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_result.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_result.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_result.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/chart_result.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse_confidence.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse_confidence.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse_confidence.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/cse_confidence.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/data_relative.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/data_relative.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/data_relative.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/data_relative.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/list.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/list.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/list.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/list.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/mesh.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/mesh.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/mesh.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/mesh.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/transform_data.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/transform_data.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/transform_data.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/structures/transform_data.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/__init__.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/dbhelper.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/dbhelper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/dbhelper.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/dbhelper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/logger.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/logger.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/logger.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/logger.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/transform.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/transform.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/utils/transform.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/__init__.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/base.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/base.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/bounding_box.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/bounding_box.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/bounding_box.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/bounding_box.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_data_points.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_data_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_data_points.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_data_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_iuv.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_iuv.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_iuv.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_iuv.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_vertex.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_vertex.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_vertex.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_outputs_vertex.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results_textures.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results_textures.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results_textures.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/densepose_results_textures.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/extractor.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/extractor.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/extractor.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/densepose/vis/extractor.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/README.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_inference_tests.sh b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_inference_tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_inference_tests.sh rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_inference_tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_instant_tests.sh b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_instant_tests.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_instant_tests.sh rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/dev/run_instant_tests.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_CSE.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_CSE.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_CSE.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_CSE.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_DATASETS.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_DATASETS.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_DATASETS.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_DATASETS.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_IUV.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_IUV.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_IUV.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/DENSEPOSE_IUV.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/GETTING_STARTED.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/GETTING_STARTED.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/GETTING_STARTED.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/GETTING_STARTED.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2020_04.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2020_04.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2020_04.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2020_04.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_03.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_03.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_03.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_03.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_06.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_06.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_06.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/RELEASE_2021_06.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/query_db.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/query_db.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/query_db.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/query_db.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/setup.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/setup.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/setup.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/setup.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/common.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/common.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/common.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/common.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_chart_based_annotations_accumulator.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_chart_based_annotations_accumulator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_chart_based_annotations_accumulator.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_chart_based_annotations_accumulator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_combine_data_loader.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_combine_data_loader.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_combine_data_loader.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_combine_data_loader.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_cse_annotations_accumulator.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_cse_annotations_accumulator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_cse_annotations_accumulator.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_cse_annotations_accumulator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_dataset_loaded_annotations.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_dataset_loaded_annotations.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_dataset_loaded_annotations.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_dataset_loaded_annotations.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_frame_selector.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_frame_selector.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_frame_selector.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_frame_selector.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_list_dataset.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_list_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_list_dataset.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_list_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_resize_transform.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_resize_transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_resize_transform.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_image_resize_transform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_model_e2e.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_model_e2e.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_model_e2e.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_model_e2e.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_setup.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_setup.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_setup.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_setup.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_structures.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_structures.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_structures.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_structures.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_tensor_storage.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_tensor_storage.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_tensor_storage.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_tensor_storage.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_video_keyframe_dataset.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_video_keyframe_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_video_keyframe_dataset.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/tests/test_video_keyframe_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/DensePose/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/DensePose/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/DensePose/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/README.md b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_in21k_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_in21k_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_in21k_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_b_in21k_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_h_in21k_lsj_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_h_in21k_lsj_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_h_in21k_lsj_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_h_in21k_lsj_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_l_in21k_lsj_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_l_in21k_lsj_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_l_in21k_lsj_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_l_in21k_lsj_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_s_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_s_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_s_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_s_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_t_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_t_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_t_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/cascade_mask_rcnn_mvitv2_t_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader_lsj.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader_lsj.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader_lsj.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/common/coco_loader_lsj.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/mask_rcnn_mvitv2_t_3x.py b/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/mask_rcnn_mvitv2_t_3x.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/mask_rcnn_mvitv2_t_3x.py rename to common/base/autodrive/3rdparty/detectron2/projects/MViTv2/configs/mask_rcnn_mvitv2_t_3x.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/README.md b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/COCO-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/COCO-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/COCO-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/COCO-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/config.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/dataset_mapper.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/dataset_mapper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/dataset_mapper.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/dataset_mapper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/panoptic_seg.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/panoptic_seg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/panoptic_seg.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/panoptic_seg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/post_processing.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/post_processing.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/post_processing.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/post_processing.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/target_generator.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/target_generator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/target_generator.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/panoptic_deeplab/target_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/train_net.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/Panoptic-DeepLab/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/README.md b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-Implicit-PointRend.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-Implicit-PointRend.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-Implicit-PointRend.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-Implicit-PointRend.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_1x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_1x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_1x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_1x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_101_FPN_3x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_101_FPN_3x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_101_FPN_3x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_101_FPN_3x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/Base-PointRend-Semantic-FPN.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/Base-PointRend-Semantic-FPN.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/Base-PointRend-Semantic-FPN.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/Base-PointRend-Semantic-FPN.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/configs/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/color_augmentation.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/color_augmentation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/color_augmentation.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/color_augmentation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/config.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/mask_head.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/mask_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/mask_head.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/mask_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_features.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_features.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_features.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_features.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_head.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_head.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/point_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/roi_heads.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/roi_heads.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/roi_heads.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/roi_heads.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/semantic_seg.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/semantic_seg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/semantic_seg.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/point_rend/semantic_seg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/PointRend/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointRend/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointRend/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/README.md b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/config.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/dataset_mapper.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/dataset_mapper.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/dataset_mapper.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/dataset_mapper.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/detection_utils.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/detection_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/detection_utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/detection_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/mask_head.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/mask_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/mask_head.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/mask_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/point_utils.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/point_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/point_utils.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/point_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/register_point_annotations.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/register_point_annotations.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/register_point_annotations.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/point_sup/register_point_annotations.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/tools/prepare_coco_point_annotations_without_masks.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/tools/prepare_coco_point_annotations_without_masks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/tools/prepare_coco_point_annotations_without_masks.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/tools/prepare_coco_point_annotations_without_masks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/PointSup/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/PointSup/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/PointSup/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/README.md b/common/base/autodrive/3rdparty/detectron2/projects/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/README.md b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_batch_stats.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_batch_stats.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_batch_stats.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_batch_stats.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_shuffle.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_shuffle.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_shuffle.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_shuffle.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_SyncBNhead.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_SyncBNhead.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_SyncBNhead.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/mask_rcnn_SyncBNhead.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/retinanet-eval-domain-specific.py b/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/retinanet-eval-domain-specific.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/retinanet-eval-domain-specific.py rename to common/base/autodrive/3rdparty/detectron2/projects/Rethinking-BatchNorm/retinanet-eval-domain-specific.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/README.md b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/Base-TensorMask.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/Base-TensorMask.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/Base-TensorMask.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/Base-TensorMask.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_6x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_6x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_6x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/configs/tensormask_R_50_FPN_6x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/setup.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/setup.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/setup.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/setup.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/arch.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/arch.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/arch.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/arch.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/config.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat.h b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat.h rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat_cuda.cu b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat_cuda.cu rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/SwapAlign2Nat/SwapAlign2Nat_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/vision.cpp b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/vision.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/vision.cpp rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/csrc/vision.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/swap_align2nat.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/swap_align2nat.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/swap_align2nat.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tensormask/layers/swap_align2nat.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/test_swap_align2nat.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/test_swap_align2nat.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/test_swap_align2nat.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/tests/test_swap_align2nat.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TensorMask/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/TensorMask/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/README.md b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/Base-TridentNet-Fast-C4.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/Base-TridentNet-Fast-C4.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/Base-TridentNet-Fast-C4.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/Base-TridentNet-Fast-C4.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_101_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_101_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_101_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_101_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_1x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_1x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_1x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_1x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_3x.yaml b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_3x.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_3x.yaml rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/configs/tridentnet_fast_R_50_C4_3x.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/train_net.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/train_net.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/__init__.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/__init__.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/config.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/config.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_backbone.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_backbone.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_backbone.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_backbone.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_conv.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_conv.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_conv.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_conv.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rcnn.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rpn.py b/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rpn.py rename to common/base/autodrive/3rdparty/detectron2/projects/TridentNet/tridentnet/trident_rpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/README.md b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/README.md rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_h_in21k_36ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_h_in21k_36ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_h_in21k_36ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_h_in21k_36ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_b_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_b_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_b_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_b_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_l_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_l_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_l_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_swin_l_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_b_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_b_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_b_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_b_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_h_75ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_h_75ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_h_75ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_h_75ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_l_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_l_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_l_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/cascade_mask_rcnn_vitdet_l_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_b_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_b_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_b_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_b_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_h_75ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_h_75ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_h_75ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_h_75ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_l_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_l_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_l_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/COCO/mask_rcnn_vitdet_l_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_b_in21k_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_h_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_h_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_h_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_h_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_mvitv2_l_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_b_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_b_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_b_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_b_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_l_in21k_50ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_l_in21k_50ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_l_in21k_50ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_swin_l_in21k_50ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_b_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_b_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_b_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_b_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_h_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_h_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_h_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_h_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_l_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_l_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_l_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/cascade_mask_rcnn_vitdet_l_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_b_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_b_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_b_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_b_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_h_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_h_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_h_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_h_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_l_100ep.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_l_100ep.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_l_100ep.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/LVIS/mask_rcnn_vitdet_l_100ep.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/common/coco_loader_lsj.py b/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/common/coco_loader_lsj.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/common/coco_loader_lsj.py rename to common/base/autodrive/3rdparty/detectron2/projects/ViTDet/configs/common/coco_loader_lsj.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/setup.cfg b/common/base/autodrive/3rdparty/detectron2/setup.cfg similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/setup.cfg rename to common/base/autodrive/3rdparty/detectron2/setup.cfg diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/setup.py b/common/base/autodrive/3rdparty/detectron2/setup.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/setup.py rename to common/base/autodrive/3rdparty/detectron2/setup.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/README.md b/common/base/autodrive/3rdparty/detectron2/tests/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/README.md rename to common/base/autodrive/3rdparty/detectron2/tests/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import.py b/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import2.py b/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import2.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import2.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/dir1/bad_import2.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_a.py b/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_a.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_a.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_a.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_b.py b/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_b.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_b.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/dir1/dir1_b.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/load_rel.py b/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/load_rel.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/dir1/load_rel.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/dir1/load_rel.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/root_cfg.py b/common/base/autodrive/3rdparty/detectron2/tests/config/root_cfg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/root_cfg.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/root_cfg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_instantiate_config.py b/common/base/autodrive/3rdparty/detectron2/tests/config/test_instantiate_config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_instantiate_config.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/test_instantiate_config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_lazy_config.py b/common/base/autodrive/3rdparty/detectron2/tests/config/test_lazy_config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_lazy_config.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/test_lazy_config.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_yacs_config.py b/common/base/autodrive/3rdparty/detectron2/tests/config/test_yacs_config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/config/test_yacs_config.py rename to common/base/autodrive/3rdparty/detectron2/tests/config/test_yacs_config.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/analysis_tools/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/data/__init__.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/analysis_tools/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_coco.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco_evaluation.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco_evaluation.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_coco_evaluation.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_coco_evaluation.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_dataset.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_dataset.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_detection_utils.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_detection_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_detection_utils.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_detection_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_rotation_transform.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_rotation_transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_rotation_transform.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_rotation_transform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_sampler.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_sampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_sampler.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_sampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_transforms.py b/common/base/autodrive/3rdparty/detectron2/tests/data/test_transforms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/data/test_transforms.py rename to common/base/autodrive/3rdparty/detectron2/tests/data/test_transforms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/export/test_c10.py b/common/base/autodrive/3rdparty/detectron2/tests/export/test_c10.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/export/test_c10.py rename to common/base/autodrive/3rdparty/detectron2/tests/export/test_c10.py diff --git a/docker-hub/FlashOCC/Flashocc/projects/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/projects/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_blocks.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_blocks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_blocks.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_blocks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_deformable.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_deformable.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_deformable.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_deformable.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_losses.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_losses.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_losses.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_losses.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_mask_ops.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_mask_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_mask_ops.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_mask_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms_rotated.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms_rotated.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms_rotated.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_nms_rotated.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align_rotated.py b/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align_rotated.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align_rotated.py rename to common/base/autodrive/3rdparty/detectron2/tests/layers/test_roi_align_rotated.py diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_anchor_generator.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_anchor_generator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_anchor_generator.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_anchor_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_backbone.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_backbone.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_backbone.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_backbone.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_box2box_transform.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_box2box_transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_box2box_transform.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_box2box_transform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_fast_rcnn.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_fast_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_fast_rcnn.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_fast_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_matcher.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_matcher.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_matcher.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_matcher.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_mmdet.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_mmdet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_mmdet.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_mmdet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_model_e2e.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_model_e2e.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_model_e2e.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_model_e2e.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_heads.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_heads.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_heads.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_heads.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_pooler.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_pooler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_pooler.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_roi_pooler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_rpn.py b/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_rpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/modeling/test_rpn.py rename to common/base/autodrive/3rdparty/detectron2/tests/modeling/test_rpn.py diff --git a/docker-hub/MapTRv2/MapTR/projects/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/__init__.py similarity index 100% rename from docker-hub/MapTRv2/MapTR/projects/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_boxes.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_boxes.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_imagelist.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_imagelist.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_imagelist.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_imagelist.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_instances.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_instances.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_instances.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_instances.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_keypoints.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_keypoints.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_keypoints.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_keypoints.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_masks.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_masks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_masks.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_masks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_rotated_boxes.py b/common/base/autodrive/3rdparty/detectron2/tests/structures/test_rotated_boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/structures/test_rotated_boxes.py rename to common/base/autodrive/3rdparty/detectron2/tests/structures/test_rotated_boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_checkpoint.py b/common/base/autodrive/3rdparty/detectron2/tests/test_checkpoint.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_checkpoint.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_checkpoint.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_engine.py b/common/base/autodrive/3rdparty/detectron2/tests/test_engine.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_engine.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_engine.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_events.py b/common/base/autodrive/3rdparty/detectron2/tests/test_events.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_events.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_events.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_caffe2.py b/common/base/autodrive/3rdparty/detectron2/tests/test_export_caffe2.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_caffe2.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_export_caffe2.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_onnx.py b/common/base/autodrive/3rdparty/detectron2/tests/test_export_onnx.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_onnx.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_export_onnx.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_torchscript.py b/common/base/autodrive/3rdparty/detectron2/tests/test_export_torchscript.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_export_torchscript.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_export_torchscript.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_model_analysis.py b/common/base/autodrive/3rdparty/detectron2/tests/test_model_analysis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_model_analysis.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_model_analysis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_model_zoo.py b/common/base/autodrive/3rdparty/detectron2/tests/test_model_zoo.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_model_zoo.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_model_zoo.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_packaging.py b/common/base/autodrive/3rdparty/detectron2/tests/test_packaging.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_packaging.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_packaging.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_registry.py b/common/base/autodrive/3rdparty/detectron2/tests/test_registry.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_registry.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_registry.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_scheduler.py b/common/base/autodrive/3rdparty/detectron2/tests/test_scheduler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_scheduler.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_scheduler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_solver.py b/common/base/autodrive/3rdparty/detectron2/tests/test_solver.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_solver.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_solver.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_visualizer.py b/common/base/autodrive/3rdparty/detectron2/tests/test_visualizer.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/test_visualizer.py rename to common/base/autodrive/3rdparty/detectron2/tests/test_visualizer.py diff --git a/docker-hub/MapTRv2/MapTR/tools/analysis_tools/__init__.py b/common/base/autodrive/3rdparty/detectron2/tests/tracking/__init__.py similarity index 100% rename from docker-hub/MapTRv2/MapTR/tools/analysis_tools/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tests/tracking/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/tests/tracking/test_bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_hungarian_tracker.py b/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_hungarian_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_hungarian_tracker.py rename to common/base/autodrive/3rdparty/detectron2/tests/tracking/test_hungarian_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_iou_weighted_hungarian_bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_iou_weighted_hungarian_bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_iou_weighted_hungarian_bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/tests/tracking/test_iou_weighted_hungarian_bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_vanilla_hungarian_bbox_iou_tracker.py b/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_vanilla_hungarian_bbox_iou_tracker.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/tracking/test_vanilla_hungarian_bbox_iou_tracker.py rename to common/base/autodrive/3rdparty/detectron2/tests/tracking/test_vanilla_hungarian_bbox_iou_tracker.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/utils/test_tensorboardx.py b/common/base/autodrive/3rdparty/detectron2/tests/utils/test_tensorboardx.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tests/utils/test_tensorboardx.py rename to common/base/autodrive/3rdparty/detectron2/tests/utils/test_tensorboardx.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/README.md b/common/base/autodrive/3rdparty/detectron2/tools/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/README.md rename to common/base/autodrive/3rdparty/detectron2/tools/README.md diff --git a/docker-hub/MapTRv2/MapTR/tools/maptr/utils/__init__.py b/common/base/autodrive/3rdparty/detectron2/tools/__init__.py similarity index 100% rename from docker-hub/MapTRv2/MapTR/tools/maptr/utils/__init__.py rename to common/base/autodrive/3rdparty/detectron2/tools/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/analyze_model.py b/common/base/autodrive/3rdparty/detectron2/tools/analyze_model.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/analyze_model.py rename to common/base/autodrive/3rdparty/detectron2/tools/analyze_model.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/benchmark.py b/common/base/autodrive/3rdparty/detectron2/tools/benchmark.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/benchmark.py rename to common/base/autodrive/3rdparty/detectron2/tools/benchmark.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/convert-torchvision-to-d2.py b/common/base/autodrive/3rdparty/detectron2/tools/convert-torchvision-to-d2.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/convert-torchvision-to-d2.py rename to common/base/autodrive/3rdparty/detectron2/tools/convert-torchvision-to-d2.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/CMakeLists.txt b/common/base/autodrive/3rdparty/detectron2/tools/deploy/CMakeLists.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/CMakeLists.txt rename to common/base/autodrive/3rdparty/detectron2/tools/deploy/CMakeLists.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/README.md b/common/base/autodrive/3rdparty/detectron2/tools/deploy/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/README.md rename to common/base/autodrive/3rdparty/detectron2/tools/deploy/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/export_model.py b/common/base/autodrive/3rdparty/detectron2/tools/deploy/export_model.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/export_model.py rename to common/base/autodrive/3rdparty/detectron2/tools/deploy/export_model.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/torchscript_mask_rcnn.cpp b/common/base/autodrive/3rdparty/detectron2/tools/deploy/torchscript_mask_rcnn.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/deploy/torchscript_mask_rcnn.cpp rename to common/base/autodrive/3rdparty/detectron2/tools/deploy/torchscript_mask_rcnn.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/lazyconfig_train_net.py b/common/base/autodrive/3rdparty/detectron2/tools/lazyconfig_train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/lazyconfig_train_net.py rename to common/base/autodrive/3rdparty/detectron2/tools/lazyconfig_train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/lightning_train_net.py b/common/base/autodrive/3rdparty/detectron2/tools/lightning_train_net.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/lightning_train_net.py rename to common/base/autodrive/3rdparty/detectron2/tools/lightning_train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/plain_train_net.py b/common/base/autodrive/3rdparty/detectron2/tools/plain_train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/plain_train_net.py rename to common/base/autodrive/3rdparty/detectron2/tools/plain_train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/train_net.py b/common/base/autodrive/3rdparty/detectron2/tools/train_net.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/train_net.py rename to common/base/autodrive/3rdparty/detectron2/tools/train_net.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/visualize_data.py b/common/base/autodrive/3rdparty/detectron2/tools/visualize_data.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/visualize_data.py rename to common/base/autodrive/3rdparty/detectron2/tools/visualize_data.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/visualize_json_results.py b/common/base/autodrive/3rdparty/detectron2/tools/visualize_json_results.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/detectron2/tools/visualize_json_results.py rename to common/base/autodrive/3rdparty/detectron2/tools/visualize_json_results.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gather_models.py b/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gather_models.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gather_models.py rename to common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gather_models.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/.dev_scripts/gen_benchmark_script.py b/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gen_benchmark_script.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/.dev_scripts/gen_benchmark_script.py rename to common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/gen_benchmark_script.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/.dev_scripts/linter.sh b/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/linter.sh similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/.dev_scripts/linter.sh rename to common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/linter.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/test_benchmark.sh b/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/test_benchmark.sh similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/test_benchmark.sh rename to common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/test_benchmark.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/train_benchmark.sh b/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/train_benchmark.sh similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/train_benchmark.sh rename to common/base/autodrive/3rdparty/mmdetection3d/.dev_scripts/train_benchmark.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/CODE_OF_CONDUCT.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/CODE_OF_CONDUCT.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/CODE_OF_CONDUCT.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/CODE_OF_CONDUCT.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/.github/CONTRIBUTING.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/CONTRIBUTING.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/.github/CONTRIBUTING.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/CONTRIBUTING.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/.github/ISSUE_TEMPLATE/config.yml b/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/config.yml similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/.github/ISSUE_TEMPLATE/config.yml rename to common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/config.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/error-report.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/error-report.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/error-report.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/error-report.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/feature_request.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/feature_request.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/feature_request.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/feature_request.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/general_questions.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/general_questions.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/general_questions.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/general_questions.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/reimplementation_questions.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/reimplementation_questions.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/reimplementation_questions.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/ISSUE_TEMPLATE/reimplementation_questions.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/pull_request_template.md b/common/base/autodrive/3rdparty/mmdetection3d/.github/pull_request_template.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/pull_request_template.md rename to common/base/autodrive/3rdparty/mmdetection3d/.github/pull_request_template.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/build.yml b/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/build.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/build.yml rename to common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/build.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/deploy.yml b/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/deploy.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/deploy.yml rename to common/base/autodrive/3rdparty/mmdetection3d/.github/workflows/deploy.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.gitignore b/common/base/autodrive/3rdparty/mmdetection3d/.gitignore similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.gitignore rename to common/base/autodrive/3rdparty/mmdetection3d/.gitignore diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.pre-commit-config.yaml b/common/base/autodrive/3rdparty/mmdetection3d/.pre-commit-config.yaml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.pre-commit-config.yaml rename to common/base/autodrive/3rdparty/mmdetection3d/.pre-commit-config.yaml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.readthedocs.yml b/common/base/autodrive/3rdparty/mmdetection3d/.readthedocs.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/.readthedocs.yml rename to common/base/autodrive/3rdparty/mmdetection3d/.readthedocs.yml diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/CITATION.cff b/common/base/autodrive/3rdparty/mmdetection3d/CITATION.cff similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/CITATION.cff rename to common/base/autodrive/3rdparty/mmdetection3d/CITATION.cff diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/LICENSE b/common/base/autodrive/3rdparty/mmdetection3d/LICENSE similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/LICENSE rename to common/base/autodrive/3rdparty/mmdetection3d/LICENSE diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/MANIFEST.in b/common/base/autodrive/3rdparty/mmdetection3d/MANIFEST.in similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/MANIFEST.in rename to common/base/autodrive/3rdparty/mmdetection3d/MANIFEST.in diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/README.md b/common/base/autodrive/3rdparty/mmdetection3d/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/README_zh-CN.md b/common/base/autodrive/3rdparty/mmdetection3d/README_zh-CN.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/README_zh-CN.md rename to common/base/autodrive/3rdparty/mmdetection3d/README_zh-CN.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/3dssd/3dssd_4x4_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/3dssd_4x4_kitti-3d-car.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/3dssd/3dssd_4x4_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/3dssd_4x4_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/3dssd/metafile.yml diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/coco_instance.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/coco_instance.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/coco_instance.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/coco_instance.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/kitti-3d-3class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/kitti-3d-3class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/kitti-3d-car.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/kitti-3d-car.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/lyft-3d.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/lyft-3d.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/nuim_instance.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nuim_instance.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/nuim_instance.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nuim_instance.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nus-3d.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/_base_/datasets/nus-mono3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nus-mono3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/_base_/datasets/nus-mono3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/nus-mono3d.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/range100_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/range100_lyft-3d.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/range100_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/range100_lyft-3d.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/s3dis-3d-5class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/s3dis-3d-5class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/s3dis-3d-5class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/s3dis-3d-5class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/s3dis_seg-3d-13class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/s3dis_seg-3d-13class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/s3dis_seg-3d-13class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/s3dis_seg-3d-13class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/scannet-3d-18class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/scannet-3d-18class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/scannet-3d-18class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/scannet-3d-18class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/scannet_seg-3d-20class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/scannet_seg-3d-20class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/scannet_seg-3d-20class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/scannet_seg-3d-20class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/sunrgbd-3d-10class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/sunrgbd-3d-10class.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/sunrgbd-3d-10class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/sunrgbd-3d-10class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-3class.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/waymoD5-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-car.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/datasets/waymoD5-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/datasets/waymoD5-3d-car.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/default_runtime.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/default_runtime.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/default_runtime.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/default_runtime.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/3dssd.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/3dssd.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/3dssd.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/3dssd.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/cascade_mask_rcnn_r50_fpn.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/cascade_mask_rcnn_r50_fpn.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/cascade_mask_rcnn_r50_fpn.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/cascade_mask_rcnn_r50_fpn.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/centerpoint_01voxel_second_secfpn_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/centerpoint_01voxel_second_secfpn_nus.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/centerpoint_01voxel_second_secfpn_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/centerpoint_01voxel_second_secfpn_nus.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/centerpoint_02pillar_second_secfpn_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/centerpoint_02pillar_second_secfpn_nus.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/centerpoint_02pillar_second_secfpn_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/centerpoint_02pillar_second_secfpn_nus.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/fcos3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/fcos3d.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/fcos3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/fcos3d.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/groupfree3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/groupfree3d.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/groupfree3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/groupfree3d.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/h3dnet.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/h3dnet.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/h3dnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/h3dnet.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_lyft.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_lyft.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_lyft.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_lyft.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_nus.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_nus.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_range100_lyft.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_range100_lyft.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_fpn_range100_lyft.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_fpn_range100_lyft.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_secfpn_kitti.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_secfpn_kitti.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_secfpn_kitti.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_secfpn_kitti.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_secfpn_waymo.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_secfpn_waymo.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_pointpillars_secfpn_waymo.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_pointpillars_secfpn_waymo.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_second_secfpn_kitti.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_second_secfpn_kitti.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_second_secfpn_kitti.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_second_secfpn_kitti.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_second_secfpn_waymo.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_second_secfpn_waymo.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/hv_second_secfpn_waymo.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/hv_second_secfpn_waymo.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/imvotenet_image.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/imvotenet_image.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/imvotenet_image.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/imvotenet_image.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/mask_rcnn_r50_fpn.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/mask_rcnn_r50_fpn.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/mask_rcnn_r50_fpn.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/mask_rcnn_r50_fpn.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/paconv_cuda_ssg.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/paconv_cuda_ssg.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/paconv_cuda_ssg.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/paconv_cuda_ssg.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/paconv_ssg.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/paconv_ssg.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/paconv_ssg.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/paconv_ssg.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/parta2.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/parta2.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/parta2.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/parta2.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/pointnet2_msg.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/pointnet2_msg.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/pointnet2_msg.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/pointnet2_msg.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/pointnet2_ssg.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/pointnet2_ssg.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/pointnet2_ssg.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/pointnet2_ssg.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/votenet.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/votenet.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/models/votenet.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/models/votenet.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cosine.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cosine.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cosine.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cosine.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cyclic_20e.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cyclic_20e.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cyclic_20e.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cyclic_20e.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cyclic_40e.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cyclic_40e.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/cyclic_40e.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/cyclic_40e.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/mmdet_schedule_1x.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/mmdet_schedule_1x.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/mmdet_schedule_1x.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/mmdet_schedule_1x.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/schedule_2x.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/schedule_2x.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/schedule_2x.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/schedule_2x.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/schedule_3x.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/schedule_3x.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/schedule_3x.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/schedule_3x.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_150e.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_150e.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_150e.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_150e.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_200e.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_200e.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_200e.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_200e.py diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_50e.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_50e.py similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/projects/configs/_base_/schedules/seg_cosine_50e.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/_base_/schedules/seg_cosine_50e.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_PartA2_secfpn_4x8_cyclic_80e_pcdet_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_PartA2_secfpn_4x8_cyclic_80e_pcdet_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_PartA2_secfpn_4x8_cyclic_80e_pcdet_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_PartA2_secfpn_4x8_cyclic_80e_pcdet_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_4x8_80e_pcdet_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_4x8_80e_pcdet_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_4x8_80e_pcdet_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_pointpillars_secfpn_4x8_80e_pcdet_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_second_secfpn_4x8_80e_pcdet_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_second_secfpn_4x8_80e_pcdet_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_second_secfpn_4x8_80e_pcdet_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/benchmark/hv_second_secfpn_4x8_80e_pcdet_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_flip-tta_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_flip-tta_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_flip-tta_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_flip-tta_20e_nus.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_tta_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_tta_20e_nus.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_tta_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_tta_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_flip-tta_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_flip-tta_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_flip-tta_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_flip-tta_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/centerpoint/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_6x8_80e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_6x8_80e_kitti-3d-car.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_6x8_80e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/dv_second_secfpn_6x8_80e_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/dynamic_voxelization/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/metafile.yml similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/fcos3d/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fcos3d/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/fp16/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_strong-aug_4x8_3x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/free_anchor/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L12-O256.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L12-O256.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L12-O256.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L12-O256.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L6-O256.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L6-O256.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L6-O256.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-L6-O256.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O256.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O256.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O256.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O256.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O512.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O512.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O512.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/groupfree3d_8x4_scannet-3d-18class-w2x-L12-O512.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/metafile.yml similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/groupfree3d/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/groupfree3d/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/h3dnet/h3dnet_3x8_scannet-3d-18class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/h3dnet_3x8_scannet-3d-18class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/h3dnet/h3dnet_3x8_scannet-3d-18class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/h3dnet_3x8_scannet-3d-18class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/h3dnet/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/imvotenet/imvotenet_faster_rcnn_r50_fpn_2x4_sunrgbd-3d-10class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/imvotenet_faster_rcnn_r50_fpn_2x4_sunrgbd-3d-10class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/imvotenet/imvotenet_faster_rcnn_r50_fpn_2x4_sunrgbd-3d-10class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/imvotenet_faster_rcnn_r50_fpn_2x4_sunrgbd-3d-10class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/imvotenet/imvotenet_stage2_16x8_sunrgbd-3d-10class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/imvotenet_stage2_16x8_sunrgbd-3d-10class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/imvotenet/imvotenet_stage2_16x8_sunrgbd-3d-10class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/imvotenet_stage2_16x8_sunrgbd-3d-10class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvotenet/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/imvoxelnet_4x8_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/imvoxelnet_4x8_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/imvoxelnet_4x8_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/imvoxelnet_4x8_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/imvoxelnet/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/mvxnet/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r101_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r101_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r101_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r101_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_without_semantic_r50_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_without_semantic_r50_fpn_1x_nuim.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_without_semantic_r50_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_without_semantic_r50_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r101_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r101_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r101_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r101_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_20e_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_20e_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_20e_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_caffe_fpn_coco-3x_20e_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nuim.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nus-2d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nus-2d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nus-2d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nus-2d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_x101_32x4d_fpn_1x_nuim.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_x101_32x4d_fpn_1x_nuim.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/nuimages/mask_rcnn_x101_32x4d_fpn_1x_nuim.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/mask_rcnn_x101_32x4d_fpn_1x_nuim.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/nuimages/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/metafile.yml similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/metafile.yml diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/paconv_cuda_ssg_8x8_cosine_200e_s3dis_seg-3d-13class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/paconv_cuda_ssg_8x8_cosine_200e_s3dis_seg-3d-13class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/paconv_cuda_ssg_8x8_cosine_200e_s3dis_seg-3d-13class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/paconv_cuda_ssg_8x8_cosine_200e_s3dis_seg-3d-13class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/parta2/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/metafile.yml diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_250e_scannet_seg-3d-20class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_250e_scannet_seg-3d-20class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_250e_scannet_seg-3d-20class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_250e_scannet_seg-3d-20class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_xyz-only_16x2_cosine_250e_scannet_seg-3d-20class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_xyz-only_16x2_cosine_250e_scannet_seg-3d-20class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_msg_xyz-only_16x2_cosine_250e_scannet_seg-3d-20class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_msg_xyz-only_16x2_cosine_250e_scannet_seg-3d-20class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_xyz-only_16x2_cosine_200e_scannet_seg-3d-20class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_xyz-only_16x2_cosine_200e_scannet_seg-3d-20class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointnet2/pointnet2_ssg_xyz-only_16x2_cosine_200e_scannet_seg-3d-20class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointnet2/pointnet2_ssg_xyz-only_16x2_cosine_200e_scannet_seg-3d-20class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_2x8_2x_lyft-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_2x8_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/pointpillars/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_2x8_2x_lyft-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_2x8_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_4x8_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_4x8_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_4x8_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_4x8_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/hv_pointpillars_regnet-400mf_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/regnet/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/second/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/second/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/second/hv_second_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/second/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/second/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/second/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/README.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_lyft-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_lyft-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_lyft-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_lyft-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_nus-3d.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_nus-3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_nus-3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/hv_ssn_secfpn_sbn-all_2x16_2x_nus-3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/ssn/metafile.yml diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/README.md b/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/README.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/README.md rename to common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/README.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/metafile.yml b/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/metafile.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/metafile.yml rename to common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/metafile.yml diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_16x8_sunrgbd-3d-10class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_16x8_sunrgbd-3d-10class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_16x8_sunrgbd-3d-10class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_16x8_sunrgbd-3d-10class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_8x8_scannet-3d-18class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_8x8_scannet-3d-18class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_8x8_scannet-3d-18class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_8x8_scannet-3d-18class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_iouloss_8x8_scannet-3d-18class.py b/common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_iouloss_8x8_scannet-3d-18class.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/configs/votenet/votenet_iouloss_8x8_scannet-3d-18class.py rename to common/base/autodrive/3rdparty/mmdetection3d/configs/votenet/votenet_iouloss_8x8_scannet-3d-18class.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/mono_det_demo.py b/common/base/autodrive/3rdparty/mmdetection3d/demo/mono_det_demo.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/mono_det_demo.py rename to common/base/autodrive/3rdparty/mmdetection3d/demo/mono_det_demo.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/multi_modality_demo.py b/common/base/autodrive/3rdparty/mmdetection3d/demo/multi_modality_demo.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/multi_modality_demo.py rename to common/base/autodrive/3rdparty/mmdetection3d/demo/multi_modality_demo.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/pc_seg_demo.py b/common/base/autodrive/3rdparty/mmdetection3d/demo/pc_seg_demo.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/pc_seg_demo.py rename to common/base/autodrive/3rdparty/mmdetection3d/demo/pc_seg_demo.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/pcd_demo.py b/common/base/autodrive/3rdparty/mmdetection3d/demo/pcd_demo.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/demo/pcd_demo.py rename to common/base/autodrive/3rdparty/mmdetection3d/demo/pcd_demo.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docker/Dockerfile b/common/base/autodrive/3rdparty/mmdetection3d/docker/Dockerfile similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docker/Dockerfile rename to common/base/autodrive/3rdparty/mmdetection3d/docker/Dockerfile diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/1_exist_data_model.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/1_exist_data_model.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/1_exist_data_model.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/1_exist_data_model.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/2_new_data_model.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/2_new_data_model.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/2_new_data_model.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/2_new_data_model.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/Makefile b/common/base/autodrive/3rdparty/mmdetection3d/docs/Makefile similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/Makefile rename to common/base/autodrive/3rdparty/mmdetection3d/docs/Makefile diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/_static/css/readthedocs.css b/common/base/autodrive/3rdparty/mmdetection3d/docs/_static/css/readthedocs.css similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/_static/css/readthedocs.css rename to common/base/autodrive/3rdparty/mmdetection3d/docs/_static/css/readthedocs.css diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/api.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs/api.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/api.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs/api.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/benchmarks.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/benchmarks.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/benchmarks.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/benchmarks.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/changelog.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/changelog.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/changelog.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/changelog.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/compatibility.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/compatibility.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/compatibility.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/compatibility.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/conf.py b/common/base/autodrive/3rdparty/mmdetection3d/docs/conf.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/conf.py rename to common/base/autodrive/3rdparty/mmdetection3d/docs/conf.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/data_preparation.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/data_preparation.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/data_preparation.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/data_preparation.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/datasets/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/datasets/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/kitti_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/kitti_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/kitti_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/kitti_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/lyft_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/lyft_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/lyft_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/lyft_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/nuscenes_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/nuscenes_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/nuscenes_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/nuscenes_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/s3dis_sem_seg.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/s3dis_sem_seg.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/s3dis_sem_seg.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/s3dis_sem_seg.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_sem_seg.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_sem_seg.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_sem_seg.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/scannet_sem_seg.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/sunrgbd_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/sunrgbd_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/sunrgbd_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/sunrgbd_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/waymo_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/waymo_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/waymo_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/datasets/waymo_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/demo.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/demo.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/demo.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/demo.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/faq.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/faq.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/faq.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/faq.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/getting_started.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/getting_started.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/getting_started.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/getting_started.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs/index.rst diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/make.bat b/common/base/autodrive/3rdparty/mmdetection3d/docs/make.bat similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/make.bat rename to common/base/autodrive/3rdparty/mmdetection3d/docs/make.bat diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/model_zoo.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/model_zoo.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/model_zoo.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/model_zoo.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/stat.py b/common/base/autodrive/3rdparty/mmdetection3d/docs/stat.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/stat.py rename to common/base/autodrive/3rdparty/mmdetection3d/docs/stat.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/index.rst diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/lidar_det3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/lidar_det3d.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/lidar_det3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/lidar_det3d.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/lidar_sem_seg3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/lidar_sem_seg3d.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/supported_tasks/lidar_sem_seg3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/lidar_sem_seg3d.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/vision_det3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/vision_det3d.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/vision_det3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/supported_tasks/vision_det3d.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/switch_language.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/switch_language.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/switch_language.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/switch_language.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/config.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/config.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/config.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/config.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_dataset.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_dataset.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_dataset.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_dataset.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/tutorials/customize_models.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_models.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/en/tutorials/customize_models.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_models.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_runtime.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_runtime.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_runtime.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/customize_runtime.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/data_pipeline.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/data_pipeline.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/data_pipeline.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/data_pipeline.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs/tutorials/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/useful_tools.md b/common/base/autodrive/3rdparty/mmdetection3d/docs/useful_tools.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs/useful_tools.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs/useful_tools.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/1_exist_data_model.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/1_exist_data_model.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/1_exist_data_model.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/1_exist_data_model.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/2_new_data_model.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/2_new_data_model.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/2_new_data_model.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/2_new_data_model.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/Makefile b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/Makefile similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/Makefile rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/Makefile diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/_static/css/readthedocs.css b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/_static/css/readthedocs.css similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/_static/css/readthedocs.css rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/_static/css/readthedocs.css diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/api.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/api.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/api.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/api.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/benchmarks.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/benchmarks.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/benchmarks.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/benchmarks.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/changelog.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/changelog.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/changelog.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/changelog.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/compatibility.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/compatibility.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/compatibility.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/compatibility.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/conf.py b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/conf.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/conf.py rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/conf.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/data_preparation.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/data_preparation.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/data_preparation.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/data_preparation.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/datasets/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/datasets/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/kitti_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/kitti_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/kitti_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/kitti_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/lyft_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/lyft_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/lyft_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/lyft_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/nuscenes_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/nuscenes_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/nuscenes_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/nuscenes_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/s3dis_sem_seg.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/s3dis_sem_seg.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/s3dis_sem_seg.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/s3dis_sem_seg.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_sem_seg.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_sem_seg.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_sem_seg.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/scannet_sem_seg.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/sunrgbd_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/sunrgbd_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/sunrgbd_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/sunrgbd_det.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/waymo_det.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/waymo_det.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/waymo_det.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/datasets/waymo_det.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/demo.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/demo.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/demo.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/demo.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/faq.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/faq.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/faq.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/faq.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/getting_started.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/getting_started.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/getting_started.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/getting_started.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/index.rst diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/make.bat b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/make.bat similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/make.bat rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/make.bat diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/model_zoo.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/model_zoo.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/model_zoo.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/model_zoo.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/stat.py b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/stat.py old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/stat.py rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/stat.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/supported_tasks/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/index.rst similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/supported_tasks/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_det3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_det3d.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_det3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_det3d.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_sem_seg3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_sem_seg3d.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_sem_seg3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/lidar_sem_seg3d.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/vision_det3d.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/vision_det3d.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/vision_det3d.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/supported_tasks/vision_det3d.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/switch_language.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/switch_language.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/switch_language.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/switch_language.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/config.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/config.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/config.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/config.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_dataset.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_dataset.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_dataset.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_dataset.md diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/tutorials/customize_models.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_models.md similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/docs/zh_cn/tutorials/customize_models.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_models.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_runtime.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_runtime.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_runtime.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/customize_runtime.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/data_pipeline.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/data_pipeline.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/data_pipeline.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/data_pipeline.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/index.rst b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/index.rst similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/index.rst rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/tutorials/index.rst diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/useful_tools.md b/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/useful_tools.md similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/useful_tools.md rename to common/base/autodrive/3rdparty/mmdetection3d/docs_zh-CN/useful_tools.md diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/inference.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/inference.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/inference.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/inference.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/test.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/test.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/test.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/test.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/train.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/train.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/train.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/apis/train.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/__init__.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/anchor/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/anchor/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/anchor_3d_generator.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/anchor_3d_generator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/anchor_3d_generator.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/anchor/anchor_3d_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/__init__.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/assigners/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/assigners/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/assigners/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/assigners/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/box_np_ops.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/box_np_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/box_np_ops.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/box_np_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/anchor_free_bbox_coder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/anchor_free_bbox_coder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/anchor_free_bbox_coder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/anchor_free_bbox_coder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/centerpoint_bbox_coders.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/centerpoint_bbox_coders.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/centerpoint_bbox_coders.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/centerpoint_bbox_coders.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/groupfree3d_bbox_coder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/groupfree3d_bbox_coder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/groupfree3d_bbox_coder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/groupfree3d_bbox_coder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/iou_calculators/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/iou_calculators/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/samplers/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/bbox/samplers/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/base_box3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/base_box3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/base_box3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/base_box3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/box_3d_mode.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/box_3d_mode.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/box_3d_mode.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/box_3d_mode.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/cam_box3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/cam_box3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/cam_box3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/cam_box3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/coord_3d_mode.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/coord_3d_mode.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/coord_3d_mode.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/coord_3d_mode.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/depth_box3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/depth_box3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/depth_box3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/depth_box3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/lidar_box3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/lidar_box3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/lidar_box3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/lidar_box3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/structures/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/transforms.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/transforms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/transforms.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/bbox/transforms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/indoor_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/indoor_eval.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/indoor_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/indoor_eval.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/eval.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/eval.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/rotate_iou.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/rotate_iou.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/rotate_iou.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/kitti_utils/rotate_iou.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/lyft_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/lyft_eval.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/lyft_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/lyft_eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/seg_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/seg_eval.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/seg_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/seg_eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/waymo_utils/prediction_kitti_to_waymo.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/waymo_utils/prediction_kitti_to_waymo.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/waymo_utils/prediction_kitti_to_waymo.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/evaluation/waymo_utils/prediction_kitti_to_waymo.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/points/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/points/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/base_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/base_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/base_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/base_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/cam_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/cam_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/cam_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/cam_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/depth_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/depth_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/depth_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/depth_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/lidar_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/lidar_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/lidar_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/points/lidar_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/box3d_nms.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/box3d_nms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/box3d_nms.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/box3d_nms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/merge_augs.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/merge_augs.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/merge_augs.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/post_processing/merge_augs.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/gaussian.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/gaussian.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/gaussian.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/utils/gaussian.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/visualizer/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/visualizer/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/image_vis.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/image_vis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/image_vis.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/image_vis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/open3d_vis.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/open3d_vis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/open3d_vis.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/open3d_vis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/show_result.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/show_result.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/show_result.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/visualizer/show_result.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/voxel/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/voxel/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/__init__.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/voxel/builder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/builder.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/core/voxel/builder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/builder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/voxel_generator.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/voxel_generator.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/voxel_generator.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/core/voxel/voxel_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/builder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/builder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/builder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/builder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d_seg.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d_seg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d_seg.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/custom_3d_seg.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/datasets/dataset_wrappers.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/dataset_wrappers.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/datasets/dataset_wrappers.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/dataset_wrappers.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti2d_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti2d_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti2d_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti2d_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_mono_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_mono_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_mono_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/kitti_mono_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/lyft_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/lyft_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/lyft_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/lyft_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_mono_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_mono_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_mono_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/nuscenes_mono_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/data_augment_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/data_augment_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/data_augment_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/data_augment_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/dbsampler.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/dbsampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/dbsampler.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/dbsampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/formating.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/formating.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/formating.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/formating.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/loading.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/loading.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/loading.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/loading.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/test_time_aug.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/test_time_aug.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/test_time_aug.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/test_time_aug.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/transforms_3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/transforms_3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/transforms_3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/pipelines/transforms_3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/s3dis_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/s3dis_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/s3dis_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/s3dis_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/scannet_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/scannet_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/scannet_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/scannet_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/semantickitti_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/semantickitti_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/semantickitti_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/semantickitti_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/sunrgbd_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/sunrgbd_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/sunrgbd_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/sunrgbd_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/waymo_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/waymo_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/waymo_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/datasets/waymo_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/base_pointnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/base_pointnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/base_pointnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/base_pointnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/multi_backbone.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/multi_backbone.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/multi_backbone.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/multi_backbone.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/nostem_regnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/nostem_regnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/nostem_regnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/nostem_regnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_msg.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_msg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_msg.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_msg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_ssg.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_ssg.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_ssg.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/pointnet2_sa_ssg.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/second.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/second.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/second.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/backbones/second.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/builder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/builder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/builder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/builder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/decode_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/decode_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/decode_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/decode_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/paconv_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/paconv_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/paconv_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/paconv_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/pointnet2_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/pointnet2_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/pointnet2_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/decode_heads/pointnet2_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor_free_mono3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor_free_mono3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor_free_mono3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/anchor_free_mono3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_conv_bbox_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_conv_bbox_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_conv_bbox_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_conv_bbox_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_mono3d_dense_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_mono3d_dense_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_mono3d_dense_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/base_mono3d_dense_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/centerpoint_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/centerpoint_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/centerpoint_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/centerpoint_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/fcos_mono3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/fcos_mono3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/fcos_mono3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/fcos_mono3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/free_anchor3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/free_anchor3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/free_anchor3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/free_anchor3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/groupfree3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/groupfree3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/groupfree3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/groupfree3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/parta2_rpn_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/parta2_rpn_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/parta2_rpn_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/parta2_rpn_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/shape_aware_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/shape_aware_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/shape_aware_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/shape_aware_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/ssd_3d_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/ssd_3d_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/ssd_3d_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/ssd_3d_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/train_mixins.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/train_mixins.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/train_mixins.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/train_mixins.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/vote_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/vote_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/vote_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/dense_heads/vote_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/base.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/base.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/centerpoint.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/centerpoint.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/centerpoint.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/centerpoint.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/dynamic_voxelnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/dynamic_voxelnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/dynamic_voxelnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/dynamic_voxelnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/fcos_mono3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/fcos_mono3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/fcos_mono3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/fcos_mono3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/groupfree3dnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/groupfree3dnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/groupfree3dnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/groupfree3dnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/h3dnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/h3dnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/h3dnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/h3dnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvotenet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvotenet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvotenet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvotenet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvoxelnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvoxelnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvoxelnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/imvoxelnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_faster_rcnn.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_faster_rcnn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_faster_rcnn.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_faster_rcnn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_two_stage.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_two_stage.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_two_stage.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/mvx_two_stage.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/parta2.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/parta2.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/parta2.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/parta2.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage_mono3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage_mono3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage_mono3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/single_stage_mono3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/ssd3dnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/ssd3dnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/ssd3dnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/ssd3dnet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/two_stage.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/two_stage.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/two_stage.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/two_stage.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/votenet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/votenet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/votenet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/votenet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/voxelnet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/voxelnet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/voxelnet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/detectors/voxelnet.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/fusion_layers/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/fusion_layers/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/coord_transform.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/coord_transform.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/coord_transform.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/coord_transform.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/point_fusion.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/point_fusion.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/point_fusion.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/point_fusion.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/fusion_layers/vote_fusion.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/vote_fusion.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/fusion_layers/vote_fusion.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/fusion_layers/vote_fusion.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/axis_aligned_iou_loss.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/axis_aligned_iou_loss.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/axis_aligned_iou_loss.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/axis_aligned_iou_loss.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/chamfer_distance.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/chamfer_distance.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/chamfer_distance.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/chamfer_distance.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/paconv_regularization_loss.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/paconv_regularization_loss.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/paconv_regularization_loss.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/losses/paconv_regularization_loss.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_encoder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_encoder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_encoder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_encoder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_unet.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_unet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_unet.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/middle_encoders/sparse_unet.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/transformer.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/transformer.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/transformer.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/transformer.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/vote_module.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/vote_module.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/vote_module.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/model_utils/vote_module.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/imvoxel_neck.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/imvoxel_neck.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/imvoxel_neck.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/imvoxel_neck.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/second_fpn.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/second_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/second_fpn.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/necks/second_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/base_3droi_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/base_3droi_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/base_3droi_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/base_3droi_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/h3d_bbox_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/h3d_bbox_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/h3d_bbox_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/h3d_bbox_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/h3d_roi_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/h3d_roi_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/h3d_roi_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/h3d_roi_head.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/pointwise_semantic_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/pointwise_semantic_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/pointwise_semantic_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/pointwise_semantic_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/primitive_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/primitive_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/primitive_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/mask_heads/primitive_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/part_aggregation_roi_head.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/part_aggregation_roi_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/part_aggregation_roi_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/part_aggregation_roi_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/single_roiaware_extractor.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/single_roiaware_extractor.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/single_roiaware_extractor.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/roi_heads/roi_extractors/single_roiaware_extractor.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/segmentors/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/models/segmentors/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/base.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/base.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/base.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/base.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/encoder_decoder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/encoder_decoder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/encoder_decoder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/segmentors/encoder_decoder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/clip_sigmoid.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/clip_sigmoid.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/clip_sigmoid.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/clip_sigmoid.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/mlp.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/mlp.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/mlp.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/utils/mlp.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/pillar_encoder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/pillar_encoder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/pillar_encoder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/pillar_encoder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/voxel_encoder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/voxel_encoder.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/voxel_encoder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/models/voxel_encoders/voxel_encoder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/ball_query.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/ball_query.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/ball_query.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/ball_query.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/ball_query/src/ball_query_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/furthest_point_sample.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/furthest_point_sample.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/furthest_point_sample.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/furthest_point_sample.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/points_sampler.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/points_sampler.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/points_sampler.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/points_sampler.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/src/furthest_point_sample_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/furthest_point_sample/utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/gather_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/gather_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/gather_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/gather_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/gather_points/src/gather_points_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/group_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/group_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/group_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/group_points.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/group_points/src/group_points_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/interpolate.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/interpolate.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/interpolate.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/interpolate.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_interpolate_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_interpolate_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_interpolate_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_interpolate_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_nn_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_nn_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_nn_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/src/three_nn_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_interpolate.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_interpolate.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_interpolate.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_interpolate.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_nn.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_nn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_nn.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/interpolate/three_nn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/iou3d_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/iou3d_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/iou3d_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/iou3d_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d_kernel.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d_kernel.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d_kernel.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/iou3d/src/iou3d_kernel.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/knn.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/knn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/knn.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/knn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/knn/src/knn_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/norm.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/norm.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/norm.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/norm.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/assign_score.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/assign_score.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/assign_score.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/assign_score.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/paconv.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/paconv.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/paconv.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/paconv.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/src/assign_score_withk_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/paconv/utils.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/ops/pointnet_modules/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/__init__.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/ops/pointnet_modules/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/__init__.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/ops/pointnet_modules/builder.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/builder.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/mmdet3d/ops/pointnet_modules/builder.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/builder.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/paconv_sa_module.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/paconv_sa_module.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/paconv_sa_module.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/paconv_sa_module.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_fp_module.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_fp_module.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_fp_module.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_fp_module.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_sa_module.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_sa_module.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_sa_module.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/pointnet_modules/point_sa_module.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/points_in_boxes.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/points_in_boxes.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/points_in_boxes.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/points_in_boxes.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/roiaware_pool3d.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/roiaware_pool3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/roiaware_pool3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/roiaware_pool3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cpu.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cpu.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cpu.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/points_in_boxes_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d_kernel.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d_kernel.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d_kernel.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/roiaware_pool3d/src/roiaware_pool3d_kernel.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/sparse_block.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/sparse_block.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/sparse_block.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/sparse_block.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/conv.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/conv.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/conv.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/conv.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/functional.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/functional.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/functional.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/functional.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/paramsgrid.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/paramsgrid.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/paramsgrid.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/paramsgrid.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/prettyprint.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/prettyprint.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/prettyprint.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/prettyprint.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/pybind11_utils.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/pybind11_utils.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/pybind11_utils.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/pybind11_utils.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/fused_spconv_ops.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/fused_spconv_ops.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/fused_spconv_ops.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/fused_spconv_ops.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/geometry.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/geometry.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/geometry.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/geometry.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.cu.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.cu.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.cu.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.cu.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/indice.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/maxpool.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/maxpool.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/maxpool.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/maxpool.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/mp_helper.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/mp_helper.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/mp_helper.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/mp_helper.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/point2voxel.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/point2voxel.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/point2voxel.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/point2voxel.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/pool_ops.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/pool_ops.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/pool_ops.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/pool_ops.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.cu.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.cu.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.cu.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.cu.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/reordering.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/spconv_ops.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/spconv_ops.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/spconv_ops.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/spconv/spconv_ops.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_kernel.cu.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_kernel.cu.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_kernel.cu.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_kernel.cu.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_launch.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_launch.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_launch.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/helper_launch.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/tensorview.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/tensorview.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/tensorview.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/tensorview/tensorview.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/torch_utils.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/torch_utils.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/torch_utils.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/torch_utils.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/utility/timer.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/utility/timer.h similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/utility/timer.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/include/utility/timer.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/modules.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/modules.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/modules.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/modules.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/ops.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/ops.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/pool.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/pool.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/pool.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/pool.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/all.cc b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/all.cc similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/all.cc rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/all.cc diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice.cc b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice.cc similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice.cc rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice.cc diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/indice_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool.cc b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool.cc similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool.cc rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool.cc diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/maxpool_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering.cc b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering.cc similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering.cc rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering.cc diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/src/reordering_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/structure.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/structure.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/structure.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/structure.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/test_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/test_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/test_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/spconv/test_utils.py diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/__init__.py similarity index 100% rename from docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/scatter_points.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/scatter_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/scatter_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/scatter_points.py diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/scatter_points_cpu.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cpu.cpp similarity index 100% rename from docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/scatter_points_cpu.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/scatter_points_cuda.cu diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/voxelization.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization.cpp similarity index 100% rename from docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/voxelization.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization.cpp diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/voxelization.h b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization.h similarity index 100% rename from docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/src/voxelization.h rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization.h diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cpu.cpp b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cpu.cpp similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cpu.cpp rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cpu.cpp diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cuda.cu b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cuda.cu similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cuda.cu rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/src/voxelization_cuda.cu diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/voxelize.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/voxelize.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/voxelize.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/ops/voxel/voxelize.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/__init__.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/__init__.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/collect_env.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/collect_env.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/collect_env.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/collect_env.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/logger.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/logger.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/logger.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/utils/logger.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/version.py b/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/version.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/version.py rename to common/base/autodrive/3rdparty/mmdetection3d/mmdet3d/version.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/model-index.yml b/common/base/autodrive/3rdparty/mmdetection3d/model-index.yml similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/model-index.yml rename to common/base/autodrive/3rdparty/mmdetection3d/model-index.yml diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements.txt similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements.txt diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements/build.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/build.txt similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements/build.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/build.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/docs.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/docs.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/docs.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/docs.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/mminstall.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/mminstall.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/mminstall.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/mminstall.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/optional.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/optional.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/optional.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/optional.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/readthedocs.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/readthedocs.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/readthedocs.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/readthedocs.txt diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/runtime.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/runtime.txt similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/requirements/runtime.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/runtime.txt diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements/tests.txt b/common/base/autodrive/3rdparty/mmdetection3d/requirements/tests.txt similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/requirements/tests.txt rename to common/base/autodrive/3rdparty/mmdetection3d/requirements/tests.txt diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/mmdet3d_outdoor_demo.gif b/common/base/autodrive/3rdparty/mmdetection3d/resources/mmdet3d_outdoor_demo.gif similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/mmdet3d_outdoor_demo.gif rename to common/base/autodrive/3rdparty/mmdetection3d/resources/mmdet3d_outdoor_demo.gif diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/nuimages_demo.gif b/common/base/autodrive/3rdparty/mmdetection3d/resources/nuimages_demo.gif similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/nuimages_demo.gif rename to common/base/autodrive/3rdparty/mmdetection3d/resources/nuimages_demo.gif diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/open3d_visual.gif b/common/base/autodrive/3rdparty/mmdetection3d/resources/open3d_visual.gif similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/resources/open3d_visual.gif rename to common/base/autodrive/3rdparty/mmdetection3d/resources/open3d_visual.gif diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/setup.cfg b/common/base/autodrive/3rdparty/mmdetection3d/setup.cfg similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/setup.cfg rename to common/base/autodrive/3rdparty/mmdetection3d/setup.cfg diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/setup.py b/common/base/autodrive/3rdparty/mmdetection3d/setup.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/setup.py rename to common/base/autodrive/3rdparty/mmdetection3d/setup.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_datasets/test_dataset_wrappers.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_dataset_wrappers.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_datasets/test_dataset_wrappers.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_dataset_wrappers.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_mono_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_mono_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_mono_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_kitti_mono_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_lyft_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_lyft_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_lyft_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_lyft_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscene_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscene_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscene_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscene_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscenes_mono_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscenes_mono_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscenes_mono_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_nuscenes_mono_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_s3dis_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_s3dis_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_s3dis_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_s3dis_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_scannet_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_scannet_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_scannet_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_scannet_dataset.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_datasets/test_semantickitti_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_semantickitti_dataset.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_datasets/test_semantickitti_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_semantickitti_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_sunrgbd_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_sunrgbd_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_sunrgbd_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_sunrgbd_dataset.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_waymo_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_waymo_dataset.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_waymo_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_datasets/test_waymo_dataset.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_data_augment_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_data_augment_utils.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_data_augment_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_data_augment_utils.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_test_augment_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_test_augment_utils.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_test_augment_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_test_augment_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_transforms_3d.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_transforms_3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_transforms_3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_augmentations/test_transforms_3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_pipeline.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_pipeline.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_pipeline.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_pipeline.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_sample.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_sample.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_sample.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_indoor_sample.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_images_from_multi_views.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_images_from_multi_views.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_images_from_multi_views.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_images_from_multi_views.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_points_from_multi_sweeps.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_points_from_multi_sweeps.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_points_from_multi_sweeps.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_load_points_from_multi_sweeps.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_loading.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_loading.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_loading.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_loadings/test_loading.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_outdoor_pipeline.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_outdoor_pipeline.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_outdoor_pipeline.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_data/test_pipelines/test_outdoor_pipeline.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_metrics/test_indoor_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_indoor_eval.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_metrics/test_indoor_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_indoor_eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_kitti_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_kitti_eval.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_kitti_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_kitti_eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_losses.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_losses.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_losses.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_losses.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_metrics/test_seg_eval.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_seg_eval.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_metrics/test_seg_eval.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_metrics/test_seg_eval.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_backbones.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_backbones.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_backbones.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_backbones.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_middle_encoders.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_middle_encoders.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_middle_encoders.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_middle_encoders.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_common_modules/test_paconv_modules.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_modules.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_common_modules/test_paconv_modules.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_modules.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_ops.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_ops.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_paconv_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_modules.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_modules.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_modules.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_modules.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_ops.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_ops.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_pointnet_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_roiaware_pool3d.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_roiaware_pool3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_roiaware_pool3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_roiaware_pool3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_sparse_unet.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_sparse_unet.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_sparse_unet.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_sparse_unet.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_common_modules/test_vote_module.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_vote_module.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_common_modules/test_vote_module.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_common_modules/test_vote_module.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_detectors.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_detectors.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_detectors.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_detectors.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_forward.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_forward.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_forward.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_forward.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_fusion_coord_trans.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_fusion_coord_trans.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_fusion_coord_trans.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_fusion_coord_trans.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_point_fusion.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_point_fusion.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_point_fusion.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_point_fusion.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_vote_fusion.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_vote_fusion.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_fusion/test_vote_fusion.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_fusion/test_vote_fusion.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_heads.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_heads.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_heads.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_heads.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_heads/test_paconv_decode_head.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_paconv_decode_head.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_heads/test_paconv_decode_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_paconv_decode_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_parta2_bbox_head.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_parta2_bbox_head.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_parta2_bbox_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_parta2_bbox_head.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_heads/test_pointnet2_decode_head.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_pointnet2_decode_head.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_heads/test_pointnet2_decode_head.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_pointnet2_decode_head.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_roi_extractors.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_roi_extractors.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_roi_extractors.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_roi_extractors.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_semantic_heads.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_semantic_heads.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_semantic_heads.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_heads/test_semantic_heads.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_fpn.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_fpn.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_fpn.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_fpn.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_necks.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_necks.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_necks.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_necks/test_necks.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_segmentors.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_segmentors.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_segmentors.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_segmentors.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_dynamic_scatter.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_dynamic_scatter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_dynamic_scatter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_dynamic_scatter.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_encoders.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_encoders.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_encoders.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_encoders.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_generator.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_generator.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_generator.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxel_generator.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxelize.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxelize.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxelize.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_models/test_voxel_encoder/test_voxelize.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_apis.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_apis.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_apis.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_apis.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_config.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_config.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_config.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_runtime/test_config.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_samples/parta2_roihead_inputs.npz b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_samples/parta2_roihead_inputs.npz similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_samples/parta2_roihead_inputs.npz rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_samples/parta2_roihead_inputs.npz diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_anchors.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_anchors.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_anchors.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_anchors.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_utils/test_assigners.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_assigners.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_utils/test_assigners.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_assigners.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_bbox_coders.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_bbox_coders.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_bbox_coders.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_bbox_coders.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box3d.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box3d.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box3d.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box3d.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box_np_ops.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box_np_ops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box_np_ops.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_box_np_ops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_coord_3d_mode.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_coord_3d_mode.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_coord_3d_mode.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_coord_3d_mode.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_merge_augs.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_merge_augs.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_merge_augs.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_merge_augs.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_nms.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_nms.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_nms.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_nms.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_points.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_points.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_points.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_points.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_utils/test_samplers.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_samplers.py similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tests/test_utils/test_samplers.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_samplers.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_utils.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tests/test_utils/test_utils.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/analysis_tools/analyze_logs.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/analyze_logs.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/analysis_tools/analyze_logs.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/analyze_logs.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/benchmark.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/benchmark.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/benchmark.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/benchmark.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/get_flops.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/get_flops.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/get_flops.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/analysis_tools/get_flops.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.sh b/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.sh rename to common/base/autodrive/3rdparty/mmdetection3d/tools/create_data.sh diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/__init__.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/__init__.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/__init__.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/create_gt_database.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/create_gt_database.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/create_gt_database.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/create_gt_database.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/indoor_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/indoor_converter.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/indoor_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/indoor_converter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_converter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_converter.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/kitti_data_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_data_utils.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/kitti_data_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/kitti_data_utils.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/lyft_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/lyft_converter.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/lyft_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/lyft_converter.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/lyft_data_fixer.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/lyft_data_fixer.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/lyft_data_fixer.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/lyft_data_fixer.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/nuimage_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuimage_converter.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/nuimage_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuimage_converter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuscenes_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuscenes_converter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuscenes_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/nuscenes_converter.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/s3dis_data_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/s3dis_data_utils.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/s3dis_data_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/s3dis_data_utils.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/scannet_data_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/scannet_data_utils.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/scannet_data_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/scannet_data_utils.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/data_converter/sunrgbd_data_utils.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/sunrgbd_data_utils.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/data_converter/sunrgbd_data_utils.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/sunrgbd_data_utils.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/waymo_converter.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/waymo_converter.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/waymo_converter.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/data_converter/waymo_converter.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_test.sh b/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_test.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_test.sh rename to common/base/autodrive/3rdparty/mmdetection3d/tools/dist_test.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_train.sh b/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_train.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/dist_train.sh rename to common/base/autodrive/3rdparty/mmdetection3d/tools/dist_train.sh diff --git a/docker-hub/BEVFormer/BEVFormer/tools/misc/browse_dataset.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/misc/browse_dataset.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/misc/browse_dataset.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/misc/browse_dataset.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/misc/fuse_conv_bn.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/misc/fuse_conv_bn.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/misc/fuse_conv_bn.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/misc/fuse_conv_bn.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/misc/print_config.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/misc/print_config.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/misc/print_config.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/misc/print_config.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/misc/visualize_results.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/misc/visualize_results.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/misc/visualize_results.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/misc/visualize_results.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_h3dnet_checkpoints.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_h3dnet_checkpoints.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_h3dnet_checkpoints.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_h3dnet_checkpoints.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/model_converters/convert_votenet_checkpoints.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_votenet_checkpoints.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/model_converters/convert_votenet_checkpoints.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/convert_votenet_checkpoints.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/model_converters/publish_model.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/publish_model.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/model_converters/publish_model.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/publish_model.py diff --git a/docker-hub/BEVFormer/BEVFormer/tools/model_converters/regnet2mmdet.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/regnet2mmdet.py old mode 100755 new mode 100644 similarity index 100% rename from docker-hub/BEVFormer/BEVFormer/tools/model_converters/regnet2mmdet.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/model_converters/regnet2mmdet.py diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tools/slurm_test.sh b/common/base/autodrive/3rdparty/mmdetection3d/tools/slurm_test.sh similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tools/slurm_test.sh rename to common/base/autodrive/3rdparty/mmdetection3d/tools/slurm_test.sh diff --git a/docker-hub/FlashOCC/Flashocc/mmdetection3d/tools/slurm_train.sh b/common/base/autodrive/3rdparty/mmdetection3d/tools/slurm_train.sh similarity index 100% rename from docker-hub/FlashOCC/Flashocc/mmdetection3d/tools/slurm_train.sh rename to common/base/autodrive/3rdparty/mmdetection3d/tools/slurm_train.sh diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/test.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/test.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/test.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/test.py diff --git a/hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/train.py b/common/base/autodrive/3rdparty/mmdetection3d/tools/train.py similarity index 100% rename from hygon-hub/common/base/autodrive/3rdparty/mmdetection3d/tools/train.py rename to common/base/autodrive/3rdparty/mmdetection3d/tools/train.py diff --git a/common/base/autodrive/README.md b/common/base/autodrive/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bc545d3683f311247dad58473a5e762022866787 --- /dev/null +++ b/common/base/autodrive/README.md @@ -0,0 +1,11 @@ +# 镜像构建 +```bash +cd common/base/autodrive + +docker build --network=host -f dockerfile \ + --build-arg VERSION=pytorch2.7.1_dtk26.04_v2.0_Hygon \ + -t aicompute.tencentcloudcr.com/hyperdrive/hygon:mmcv1.6_dtk26.04_v2.0_Hygon . +``` + +### 镜像列表 +- aicompute.tencentcloudcr.com/hyperdrive/hygon:mmcv1.6_dtk26.04_v2.0_Hygon diff --git a/common/base/autodrive/dockerfile b/common/base/autodrive/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..86e0cfdae3309a37213b6994f43249f767242ee9 --- /dev/null +++ b/common/base/autodrive/dockerfile @@ -0,0 +1,91 @@ +ARG VERSION=pytorch2.7.1_dtk26.04_v2.0_Hygon +ARG BASE_IMAGE=aicompute.tencentcloudcr.com/hyperdrive/hygon:${VERSION} +FROM ${BASE_IMAGE} + +ARG COS_BASE_URL="https://haihub-model-1251001002.cos.ap-shanghai.myqcloud.com/HyperDrive/haiguang/hygon-bench/train" +ARG PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple" +ARG COS_WHL_BASE="https://hygon-thpcbench-1251001002.cos.ap-shanghai.myqcloud.com/hygon/whl" +ARG LLVM_RUN_URL="${COS_WHL_BASE}/dtk_llvm.run" +ARG TORCH_WHL_URL="${COS_WHL_BASE}/torch-2.7.1+das.opt1.dtk2604.2605091817.g39c19f-cp310-cp310-manylinux_2_28_x86_64.whl" +ARG TRITON_WHL_URL="${COS_WHL_BASE}/triton-3.2.0+das.opt1.dtk2604.torch271.2605122039.gc13c4e-cp310-cp310-manylinux_2_28_x86_64.whl" +ARG MMCV_WHL_URL="${COS_WHL_BASE}/mmcv_full-1.6.1+das1.1.gite18c519.abi1.dtk26.torch2.5-cp310-cp310-manylinux_2_28_x86_64.whl" +ARG MMCV_2_WHL_URL="${COS_WHL_BASE}/mmcv-2.2.0+das.opt1.dtk2604.20260204.gb9d4e636-cp310-cp310-manylinux_2_28_x86_64.whl" +ARG LIGHTOP_WHL_URL="${COS_WHL_BASE}/lightop-0.7.0+das.dtk2604.torch271-cp310-cp310-manylinux_2_28_x86_64.whl" +ARG HIPDNN_WHL_URL="${COS_WHL_BASE}/hipdnn-1.0.1+dtk2604-cp310-cp310-linux_x86_64.whl" +ARG FASTPT_WHL_URL="${COS_WHL_BASE}/fastpt-2.2.0+das.dtk2604.torch271.2605091101.gc8b32c.noglog-cp310-cp310-linux_x86_64.whl" + + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update && \ + apt-get install -y --no-install-recommends zstd aria2 pv rsync python3-tk && \ + rm -rf /var/lib/apt/lists/* + +# Base image provides DTK. Replace the Python stack with the torch 2.7.1 +# packages from the internal package mirrors. +RUN pip uninstall -y torch triton && \ + curl -fL -o /tmp/dtk_llvm.run "${LLVM_RUN_URL}" && \ + chmod +x /tmp/dtk_llvm.run && \ + /tmp/dtk_llvm.run && \ + rm -f /tmp/dtk_llvm.run && \ + pip install "${TORCH_WHL_URL}" && \ + pip install "${TRITON_WHL_URL}" && \ + pip install "${MMCV_WHL_URL}" && \ + pip install "${FASTPT_WHL_URL}" && \ + if [ -n "${HIPDNN_WHL_URL}" ]; then \ + pip install "${HIPDNN_WHL_URL}"; \ + else \ + pip install hipdnn -i https://pypi.sourcefind.cn/release/dtk2604/; \ + fi + +# Download Hyhal for compile if dtk_llvm did not already provide it. +RUN if [ -e /opt/hyhal/lib ]; then \ + echo "Use existing /opt/hyhal"; \ + else \ + aria2c --enable-color=false --show-console-readout=false -x 8 -s 8 -k 1M -d /tmp -o hyhal.tar.gz ${COS_BASE_URL}/common/hyhal.tar.gz && \ + mkdir -p /opt/hyhal && \ + tar -zxf /tmp/hyhal.tar.gz --strip-components=2 -C /opt/hyhal && \ + rm -rf /tmp/hyhal.tar.gz; \ + fi + +# Install common deps +RUN pip install -i "${PIP_INDEX_URL}" \ + absl-py==2.3.1 antlr4-python3-runtime==4.9.3 asttokens==3.0.1 black==25.12.0 \ + decorator==5.2.1 descartes==1.1.0 executing==2.2.1 fire==0.7.1 flake8==7.3.0 \ + fvcore==0.1.5.post20221221 iopath==0.1.10 ipython==8.37.0 jedi==0.19.2 \ + joblib==1.5.3 lyft-dataset-sdk==0.0.8 Markdown==3.10 matplotlib-inline==0.2.1 \ + mccabe==0.7.0 mmdet==2.25.1 mmengine==0.10.7 mmsegmentation==0.25.0 \ + mypy_extensions==1.1.0 narwhals==2.14.0 nuscenes-devkit==1.1.11 \ + scikit-learn==1.7.2 termcolor==3.2.0 terminaltables==3.1.10 trimesh==2.35.39 \ + omegaconf==2.3.0 seaborn==0.13.2 yarl==1.20.0 yapf==0.40.1 \ + numba==0.56.4 numpy==1.23.5 future tensorboard av2 scikit-image==0.19.3 plyfile==1.1 && \ + sed 's/1.6.0/1.7.0/' -i /usr/local/lib/python3.10/dist-packages/mmseg/__init__.py + +ENV TORCH_CUDA_ARCH_LIST="9.0" + +# Build detectron2 with fastpt, matching the mmdet3d compile flow. Hyhal must +# stay available until both source-built packages are complete. +COPY 3rdparty/detectron2 /workspace/detectron2 +RUN pip uninstall -y detectron2 && \ + cd /workspace/detectron2 && /bin/bash -c \ + "source /usr/local/bin/fastpt -C && \ + FORCE_CUDA=1 python3 setup.py bdist_wheel && \ + pip install --no-deps dist/detectron2-*.whl && \ + rm -rf /workspace/detectron2 && \ + (source /usr/local/bin/fastpt -E || true)" + +# Install modified mmdet3d +COPY 3rdparty/mmdetection3d /workspace/mmdetection3d +RUN pip uninstall -y mmdet3d +RUN cd /workspace/mmdetection3d && /bin/bash -c \ + "source /usr/local/bin/fastpt -C && \ + FORCE_CUDA=1 python3 setup.py bdist_wheel && \ + pip install --no-deps dist/mmdet3d-*.whl && \ + rm -rf /workspace/mmdetection3d && \ + (source /usr/local/bin/fastpt -E || true) && \ + rm -rf /opt/hyhal" + +# Remove hyhal for runtime +RUN rm -rf /opt/hyhal + +WORKDIR /workspace diff --git a/hygon-hub/common/base/megatron/README.md b/common/base/megatron/README.md similarity index 100% rename from hygon-hub/common/base/megatron/README.md rename to common/base/megatron/README.md diff --git a/hygon-hub/common/base/megatron/dockerfile b/common/base/megatron/dockerfile similarity index 100% rename from hygon-hub/common/base/megatron/dockerfile rename to common/base/megatron/dockerfile diff --git a/hygon-hub/common/base/pytorch/3rdparty/example/.info/version b/common/base/pytorch/3rdparty/example/.info/version similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/example/.info/version rename to common/base/pytorch/3rdparty/example/.info/version diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.github/CODEOWNERS b/common/base/pytorch/3rdparty/rccl-tests/.github/CODEOWNERS old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.github/CODEOWNERS rename to common/base/pytorch/3rdparty/rccl-tests/.github/CODEOWNERS diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.github/PULL_REQUEST_TEMPLATE.md b/common/base/pytorch/3rdparty/rccl-tests/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.github/PULL_REQUEST_TEMPLATE.md rename to common/base/pytorch/3rdparty/rccl-tests/.github/PULL_REQUEST_TEMPLATE.md diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.gitignore b/common/base/pytorch/3rdparty/rccl-tests/.gitignore similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.gitignore rename to common/base/pytorch/3rdparty/rccl-tests/.gitignore diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/common.groovy b/common/base/pytorch/3rdparty/rccl-tests/.jenkins/common.groovy similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/common.groovy rename to common/base/pytorch/3rdparty/rccl-tests/.jenkins/common.groovy diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/precheckin.groovy b/common/base/pytorch/3rdparty/rccl-tests/.jenkins/precheckin.groovy similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/precheckin.groovy rename to common/base/pytorch/3rdparty/rccl-tests/.jenkins/precheckin.groovy diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/staticanalysis.groovy b/common/base/pytorch/3rdparty/rccl-tests/.jenkins/staticanalysis.groovy similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/.jenkins/staticanalysis.groovy rename to common/base/pytorch/3rdparty/rccl-tests/.jenkins/staticanalysis.groovy diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/CMakeLists.txt b/common/base/pytorch/3rdparty/rccl-tests/CMakeLists.txt similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/CMakeLists.txt rename to common/base/pytorch/3rdparty/rccl-tests/CMakeLists.txt diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/LICENSE.txt b/common/base/pytorch/3rdparty/rccl-tests/LICENSE.txt similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/LICENSE.txt rename to common/base/pytorch/3rdparty/rccl-tests/LICENSE.txt diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/Makefile b/common/base/pytorch/3rdparty/rccl-tests/Makefile similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/Makefile rename to common/base/pytorch/3rdparty/rccl-tests/Makefile diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/NOTICES.txt b/common/base/pytorch/3rdparty/rccl-tests/NOTICES.txt similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/NOTICES.txt rename to common/base/pytorch/3rdparty/rccl-tests/NOTICES.txt diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/README.md b/common/base/pytorch/3rdparty/rccl-tests/README.md similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/README.md rename to common/base/pytorch/3rdparty/rccl-tests/README.md diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/doc/PERFORMANCE.md b/common/base/pytorch/3rdparty/rccl-tests/doc/PERFORMANCE.md similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/doc/PERFORMANCE.md rename to common/base/pytorch/3rdparty/rccl-tests/doc/PERFORMANCE.md diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos similarity index 96% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos rename to common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos index 8da1feef1f194ebb1e85aa3e13fb05bc64a03e7f..f283956d2ff3570a035fac85346dd7aa083a732f 100644 --- a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos +++ b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-centos @@ -1,40 +1,40 @@ -# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. -# This Dockerfile provides a starting point for a ROCm installation of rccl - -# Parameters related to building rccl -ARG base_image - -FROM ${base_image} -LABEL maintainer="rccl-maintainer@amd.com" - -USER root -ARG user_uid - -# Install dependent packages -RUN yum install -y --nogpgcheck \ - sudo \ - chrpath \ - rock-dkms \ - rocm-cmake \ - centos-release-scl \ - devtoolset-7 \ - ca-certificates \ - git \ - cmake3 \ - make \ - libgomp \ - clang \ - clang-devel \ - gcc-c++ \ - pkgconfig \ - numactl-libs - -RUN echo '#!/bin/bash' | tee /etc/profile.d/devtoolset7.sh && echo \ - 'source scl_source enable devtoolset-7' >>/etc/profile.d/devtoolset7.sh - -# docker pipeline runs containers with particular uid -# create a jenkins user with this specific uid so it can use sudo priviledges -# Grant any member of sudo group password-less sudo privileges -RUN useradd --create-home -u ${user_uid} -o -G video --shell /bin/bash jenkins && \ - echo '%video ALL=(ALL) NOPASSWD:ALL' | tee /etc/sudoers.d/sudo-nopasswd && \ - chmod 400 /etc/sudoers.d/sudo-nopasswd +# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. +# This Dockerfile provides a starting point for a ROCm installation of rccl + +# Parameters related to building rccl +ARG base_image + +FROM ${base_image} +LABEL maintainer="rccl-maintainer@amd.com" + +USER root +ARG user_uid + +# Install dependent packages +RUN yum install -y --nogpgcheck \ + sudo \ + chrpath \ + rock-dkms \ + rocm-cmake \ + centos-release-scl \ + devtoolset-7 \ + ca-certificates \ + git \ + cmake3 \ + make \ + libgomp \ + clang \ + clang-devel \ + gcc-c++ \ + pkgconfig \ + numactl-libs + +RUN echo '#!/bin/bash' | tee /etc/profile.d/devtoolset7.sh && echo \ + 'source scl_source enable devtoolset-7' >>/etc/profile.d/devtoolset7.sh + +# docker pipeline runs containers with particular uid +# create a jenkins user with this specific uid so it can use sudo priviledges +# Grant any member of sudo group password-less sudo privileges +RUN useradd --create-home -u ${user_uid} -o -G video --shell /bin/bash jenkins && \ + echo '%video ALL=(ALL) NOPASSWD:ALL' | tee /etc/sudoers.d/sudo-nopasswd && \ + chmod 400 /etc/sudoers.d/sudo-nopasswd diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-ubuntu-rock b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-ubuntu-rock similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-ubuntu-rock rename to common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-build-ubuntu-rock diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos similarity index 96% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos rename to common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos index d0b70e37c13da9cff5e373f5e183e98debebe141..2ccd6337f665c6cb80dffa081b749d7d30696bd5 100644 --- a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos +++ b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-centos @@ -1,8 +1,8 @@ -# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. -# Parameters related to building rccl -ARG base_image - -FROM ${base_image} -LABEL maintainer="rccl-maintainer@amd.com" - -#empty for now +# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. +# Parameters related to building rccl +ARG base_image + +FROM ${base_image} +LABEL maintainer="rccl-maintainer@amd.com" + +#empty for now diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-ubuntu b/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-ubuntu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-ubuntu rename to common/base/pytorch/3rdparty/rccl-tests/docker/dockerfile-install-ubuntu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/install.sh b/common/base/pytorch/3rdparty/rccl-tests/install.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/install.sh rename to common/base/pytorch/3rdparty/rccl-tests/install.sh diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/CMakeLists.txt b/common/base/pytorch/3rdparty/rccl-tests/src/CMakeLists.txt similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/CMakeLists.txt rename to common/base/pytorch/3rdparty/rccl-tests/src/CMakeLists.txt diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/Makefile b/common/base/pytorch/3rdparty/rccl-tests/src/Makefile similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/Makefile rename to common/base/pytorch/3rdparty/rccl-tests/src/Makefile diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/all_gather.cu b/common/base/pytorch/3rdparty/rccl-tests/src/all_gather.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/all_gather.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/all_gather.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/all_reduce.cu b/common/base/pytorch/3rdparty/rccl-tests/src/all_reduce.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/all_reduce.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/all_reduce.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/alltoall.cu b/common/base/pytorch/3rdparty/rccl-tests/src/alltoall.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/alltoall.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/alltoall.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/alltoallv.cu b/common/base/pytorch/3rdparty/rccl-tests/src/alltoallv.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/alltoallv.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/alltoallv.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/broadcast.cu b/common/base/pytorch/3rdparty/rccl-tests/src/broadcast.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/broadcast.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/broadcast.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/cmake/git_version.cmake b/common/base/pytorch/3rdparty/rccl-tests/src/cmake/git_version.cmake similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/cmake/git_version.cmake rename to common/base/pytorch/3rdparty/rccl-tests/src/cmake/git_version.cmake diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/common.cu b/common/base/pytorch/3rdparty/rccl-tests/src/common.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/common.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/common.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/common.h b/common/base/pytorch/3rdparty/rccl-tests/src/common.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/common.h rename to common/base/pytorch/3rdparty/rccl-tests/src/common.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/gather.cu b/common/base/pytorch/3rdparty/rccl-tests/src/gather.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/gather.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/gather.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/git_version.h b/common/base/pytorch/3rdparty/rccl-tests/src/git_version.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/git_version.h rename to common/base/pytorch/3rdparty/rccl-tests/src/git_version.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/hypercube.cu b/common/base/pytorch/3rdparty/rccl-tests/src/hypercube.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/hypercube.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/hypercube.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/nccl1_compat.h b/common/base/pytorch/3rdparty/rccl-tests/src/nccl1_compat.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/nccl1_compat.h rename to common/base/pytorch/3rdparty/rccl-tests/src/nccl1_compat.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/rccl_float8.h b/common/base/pytorch/3rdparty/rccl-tests/src/rccl_float8.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/rccl_float8.h rename to common/base/pytorch/3rdparty/rccl-tests/src/rccl_float8.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/reduce.cu b/common/base/pytorch/3rdparty/rccl-tests/src/reduce.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/reduce.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/reduce.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/reduce_scatter.cu b/common/base/pytorch/3rdparty/rccl-tests/src/reduce_scatter.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/reduce_scatter.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/reduce_scatter.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/scatter.cu b/common/base/pytorch/3rdparty/rccl-tests/src/scatter.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/scatter.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/scatter.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/sendrecv.cu b/common/base/pytorch/3rdparty/rccl-tests/src/sendrecv.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/sendrecv.cu rename to common/base/pytorch/3rdparty/rccl-tests/src/sendrecv.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/timer.cc b/common/base/pytorch/3rdparty/rccl-tests/src/timer.cc similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/timer.cc rename to common/base/pytorch/3rdparty/rccl-tests/src/timer.cc diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/timer.h b/common/base/pytorch/3rdparty/rccl-tests/src/timer.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/src/timer.h rename to common/base/pytorch/3rdparty/rccl-tests/src/timer.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/__init__.py b/common/base/pytorch/3rdparty/rccl-tests/test/__init__.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/__init__.py rename to common/base/pytorch/3rdparty/rccl-tests/test/__init__.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/conftest.py b/common/base/pytorch/3rdparty/rccl-tests/test/conftest.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/conftest.py rename to common/base/pytorch/3rdparty/rccl-tests/test/conftest.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_AllGather.py b/common/base/pytorch/3rdparty/rccl-tests/test/test_AllGather.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_AllGather.py rename to common/base/pytorch/3rdparty/rccl-tests/test/test_AllGather.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_AllReduce.py b/common/base/pytorch/3rdparty/rccl-tests/test/test_AllReduce.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_AllReduce.py rename to common/base/pytorch/3rdparty/rccl-tests/test/test_AllReduce.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_Broadcast.py b/common/base/pytorch/3rdparty/rccl-tests/test/test_Broadcast.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_Broadcast.py rename to common/base/pytorch/3rdparty/rccl-tests/test/test_Broadcast.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_Reduce.py b/common/base/pytorch/3rdparty/rccl-tests/test/test_Reduce.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_Reduce.py rename to common/base/pytorch/3rdparty/rccl-tests/test/test_Reduce.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_ReduceScatter.py b/common/base/pytorch/3rdparty/rccl-tests/test/test_ReduceScatter.py similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/test/test_ReduceScatter.py rename to common/base/pytorch/3rdparty/rccl-tests/test/test_ReduceScatter.py diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/Makefile b/common/base/pytorch/3rdparty/rccl-tests/verifiable/Makefile similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/Makefile rename to common/base/pytorch/3rdparty/rccl-tests/verifiable/Makefile diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/inexact_regress.cu b/common/base/pytorch/3rdparty/rccl-tests/verifiable/inexact_regress.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/inexact_regress.cu rename to common/base/pytorch/3rdparty/rccl-tests/verifiable/inexact_regress.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.cu b/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.cu similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.cu rename to common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.cu diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.h b/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.h similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.h rename to common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.h diff --git a/hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.mk b/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.mk similarity index 100% rename from hygon-hub/common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.mk rename to common/base/pytorch/3rdparty/rccl-tests/verifiable/verifiable.mk diff --git a/common/base/pytorch/README.md b/common/base/pytorch/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2e68a0d85e21626bdfc256057cfbc119a94f9370 --- /dev/null +++ b/common/base/pytorch/README.md @@ -0,0 +1,10 @@ +# 镜像构建 +```bash +cd common/base/pytorch + +docker build --network=host -f dockerfile \ + -t aicompute.tencentcloudcr.com/hyperdrive/hygon:pytorch2.7.1_dtk26.04_v2.0_Hygon . +``` + +### 镜像列表 +- aicompute.tencentcloudcr.com/hyperdrive/hygon:pytorch2.7.1_dtk26.04_v2.0_Hygon diff --git a/common/base/pytorch/dockerfile b/common/base/pytorch/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..50afad170c0bffc33ca14e54f49308d233c99e17 --- /dev/null +++ b/common/base/pytorch/dockerfile @@ -0,0 +1,148 @@ +ARG VERSION=2.7.1-ubuntu22.04-dtk26.04-py3.10 +ARG BASE_IMAGE=harbor.sourcefind.cn:5443/dcu/admin/base/pytorch:${VERSION} +FROM ${BASE_IMAGE} + +ARG COS_BASE_URL="https://haihub-model-1251001002.cos.ap-shanghai.myqcloud.com/HyperDrive/haiguang/hygon-bench/train" + +# Ubuntu apt source +RUN UBUNTU_VERSION=$(cat /etc/os-release | grep 'VERSION_ID' | cut -d '=' -f2 | tr -d '"') && \ +echo "Ubuntu version detected: $UBUNTU_VERSION" && \ +if [ "$UBUNTU_VERSION" = "22.04" ]; then \ + printf '%s\n' \ + 'deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse' \ + 'deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse' \ + 'deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse' \ + 'deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse' \ + > /etc/apt/sources.list; \ +elif [ "$UBUNTU_VERSION" = "24.04" ]; then \ + wget -O /etc/apt/sources.list.d/ubuntu.sources https://haihub-model-1251001002.cos.accelerate.myqcloud.com/TCCL/sources_2404.list; \ +else \ + echo "Unsupported Ubuntu version: $UBUNTU_VERSION"; exit 1; \ +fi + +RUN apt update && apt install -y \ + cmake net-tools pdsh tmux vim iputils-ping libnuma-dev libcap2 lrzsz curl python3-tk \ + aria2 zstd pv + +# Configure timezone +RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + apt update && apt install -y tzdata && \ + dpkg-reconfigure --frontend noninteractive tzdata + +# Support Chinese language +RUN apt install -y language-pack-zh-hans +ENV LANG="zh_CN.UTF-8" +ENV LANGUAGE="zh_CN:zh:en_US:en" + +# Allow OpenSSH to talk to containers without asking for confirmation +RUN mkdir -p /run/sshd && \ + mkdir -p /root/.ssh/ && \ + ssh-keygen -A && \ + ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -y && \ + ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -y && \ + ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -y && \ + ssh-keygen -t rsa -C "" -f ~/.ssh/id_rsa -P "" && \ + cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \ + chmod 0600 /root/.ssh/authorized_keys && \ + printf "Host * \n ForwardAgent yes \nHost * \n StrictHostKeyChecking no \nPort 3333" > /root/.ssh/config && \ + sed -i 's/#Port 22/Port 3333/g' /etc/ssh/sshd_config + +# Tsinghua pip source +RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple +RUN pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn + +RUN mkdir -p /workspace + +# Install OFED UMD +RUN UBUNTU_VERSION=$(cat /etc/os-release | grep 'VERSION_ID' | cut -d '=' -f2 | tr -d '"') && \ + echo "Ubuntu version detected: $UBUNTU_VERSION" && \ + OFED_PKG="MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu22.04-x86_64" && \ + OFED_URL="https://haihub-model-1251001002.cos.accelerate.myqcloud.com/TCCL/${OFED_PKG}.tgz"; \ + if [ "$UBUNTU_VERSION" = "22.04" ]; then \ + EXTRA_OPTS=""; \ + NEED_SED="false"; \ + elif [ "$UBUNTU_VERSION" = "24.04" ]; then \ + EXTRA_OPTS="--skip-distro-check"; \ + NEED_SED="true"; \ + else \ + echo "Unsupported Ubuntu version: $UBUNTU_VERSION"; exit 1; \ + fi && \ + aria2c --enable-color=false --show-console-readout=false -s 8 -x 8 "$OFED_URL" && \ + tar xf ${OFED_PKG}.tgz && cd ${OFED_PKG} && \ + if [ "$NEED_SED" = "true" ]; then \ + sed -i 's/dpatch//g' mlnxofedinstall && \ + sed -i 's/ubuntu22/ubuntu2[24]/g' mlnxofedinstall; \ + fi && \ + ./mlnxofedinstall --user-space-only --without-fw-update --without-ucx-cuda --force $EXTRA_OPTS && \ + cd ../ && rm -rf MLNX_OFED_LINUX* + +# Download Hyhal for compile if the base image does not already provide it. +RUN if [ -e /opt/hyhal/lib ]; then \ + echo "Use existing /opt/hyhal"; \ + else \ + aria2c --enable-color=false --show-console-readout=false -x 8 -s 8 -k 1M -d /tmp -o hyhal.tar.gz ${COS_BASE_URL}/common/hyhal.tar.gz && \ + mkdir -p /opt/hyhal && \ + tar -zxf /tmp/hyhal.tar.gz --strip-components=2 -C /opt/hyhal && \ + rm -rf /tmp/hyhal.tar.gz; \ + fi + +# install rccl-tests +COPY 3rdparty/rccl-tests /workspace/rccl-tests +RUN cd /workspace/rccl-tests && \ + LD_LIBRARY_PATH=/opt/hyhal/lib:$LD_LIBRARY_PATH make ROCM_HOME=/opt/dtk NCCL_HOME=/opt/dtk/rccl CUSTOM_RCCL_LIB=/opt/dtk/rccl/lib/librccl.so MPI=1 MPI_HOME=/usr/mpi/gcc/openmpi-4.1.5a1 && \ + cp build/*perf /usr/local/bin/ && \ + cd .. && rm -rf /workspace/rccl-tests + +# Remove hyhal for runtime +RUN rm -rf /opt/hyhal + +# install scripts +COPY scripts/run_rccl_test.sh /workspace/run_rccl_test.sh + +# workaround for rccl perf +RUN mkdir -p /opt/dtk/rccl/patch/ +COPY misc/fix_rccl/fix_graph.xml /opt/dtk/rccl/patch/fix_graph.xml +COPY misc/fix_rccl/fix_topo.xml /opt/dtk/rccl/patch/fix_topo.xml +RUN mkdir -p /workspace/scripts +COPY scripts/bssh.sh /workspace/scripts/bssh.sh +COPY scripts/bscp.sh /workspace/scripts/bscp.sh +COPY scripts/cluster_check.sh /workspace/scripts/cluster_check.sh +COPY scripts/get_rdma_order_by_ip.sh /workspace/scripts/get_rdma_order_by_ip.sh +COPY scripts/rdma_bw_check.py /workspace/scripts/rdma_bw_check.py +COPY scripts/rdma_monitor /workspace/scripts/rdma_monitor +COPY scripts/rdma_nic_check.py /workspace/scripts/rdma_nic_check.py + +# nccl settings +ENV NCCL_SOCKET_IFNAME=eth0 +ENV NCCL_IB_GID_INDEX=3 +ENV NCCL_IB_DISABLE=0 +ENV NCCL_NET_GDR_LEVEL=2 +ENV NCCL_IB_QPS_PER_CONNECTION=4 +ENV NCCL_IB_TC=160 +ENV NCCL_IB_TIMEOUT=22 +ENV GLOO_SOCKET_IFNAME=eth0 + +#ENV NCCL_GRAPH_FILE=/opt/dtk/rccl/patch/fix_graph.xml +ENV NCCL_TOPO_FILE=/opt/dtk/rccl/patch/fix_topo.xml +ENV NCCL_ROCE_SRC_PORT_LIST=60000,60051,57663,57804 +ENV RCCL_MODEL_MATCHING_DISABLE=1 +ENV HSA_FORCE_FINE_GRAIN_PCIE=1 +ENV NCCL_PXN_DISABLE=1 +ENV NCCL_ALGO=Ring + +# workaround for the issue that env get lost over ssh login +RUN env > /etc/environment && \ + printf "\nexport LD_LIBRARY_PATH=\"/opt/hyhal/lib:\$LD_LIBRARY_PATH\"\n\n" | tee -a /root/.bashrc /root/.hygon_base_env + +RUN printf '%s\n' \ + "FASTPT_TORCH_LIB_PATH=/usr/local/lib/python3.10/dist-packages/torch/lib" \ + "FASTPT_CUDA_LIB_PATH=/opt/dtk/cuda/cuda-12/lib64/" "" \ + "export LD_LIBRARY_PATH=\"\$FASTPT_TORCH_LIB_PATH:\$LD_LIBRARY_PATH\"" \ + "export LD_LIBRARY_PATH=\"\$FASTPT_CUDA_LIB_PATH:\$LD_LIBRARY_PATH\"" "" | tee -a /root/.bashrc /root/.hygon_base_env + +# ulimit +RUN echo 'root soft nofile 4194304' | tee -a /etc/security/limits.conf && echo 'root hard nofile 4194304' | tee -a /etc/security/limits.conf + +WORKDIR "/workspace/" + +ENTRYPOINT service ssh restart && bash diff --git a/hygon-hub/common/base/pytorch/misc/fix_rccl/fix_graph.xml b/common/base/pytorch/misc/fix_rccl/fix_graph.xml similarity index 100% rename from hygon-hub/common/base/pytorch/misc/fix_rccl/fix_graph.xml rename to common/base/pytorch/misc/fix_rccl/fix_graph.xml diff --git a/hygon-hub/common/base/pytorch/misc/fix_rccl/fix_topo.xml b/common/base/pytorch/misc/fix_rccl/fix_topo.xml similarity index 100% rename from hygon-hub/common/base/pytorch/misc/fix_rccl/fix_topo.xml rename to common/base/pytorch/misc/fix_rccl/fix_topo.xml diff --git a/hygon-hub/common/base/pytorch/scripts/bscp.sh b/common/base/pytorch/scripts/bscp.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/bscp.sh rename to common/base/pytorch/scripts/bscp.sh diff --git a/hygon-hub/common/base/pytorch/scripts/bssh.sh b/common/base/pytorch/scripts/bssh.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/bssh.sh rename to common/base/pytorch/scripts/bssh.sh diff --git a/hygon-hub/common/base/pytorch/scripts/cluster_check.sh b/common/base/pytorch/scripts/cluster_check.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/cluster_check.sh rename to common/base/pytorch/scripts/cluster_check.sh diff --git a/hygon-hub/common/base/pytorch/scripts/get_rdma_order_by_ip.sh b/common/base/pytorch/scripts/get_rdma_order_by_ip.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/get_rdma_order_by_ip.sh rename to common/base/pytorch/scripts/get_rdma_order_by_ip.sh diff --git a/hygon-hub/common/base/pytorch/scripts/rdma_bw_check.py b/common/base/pytorch/scripts/rdma_bw_check.py similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/rdma_bw_check.py rename to common/base/pytorch/scripts/rdma_bw_check.py diff --git a/hygon-hub/common/base/pytorch/scripts/rdma_monitor b/common/base/pytorch/scripts/rdma_monitor similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/rdma_monitor rename to common/base/pytorch/scripts/rdma_monitor diff --git a/hygon-hub/common/base/pytorch/scripts/rdma_nic_check.py b/common/base/pytorch/scripts/rdma_nic_check.py similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/rdma_nic_check.py rename to common/base/pytorch/scripts/rdma_nic_check.py diff --git a/hygon-hub/common/base/pytorch/scripts/run_rccl_test.sh b/common/base/pytorch/scripts/run_rccl_test.sh old mode 100644 new mode 100755 similarity index 100% rename from hygon-hub/common/base/pytorch/scripts/run_rccl_test.sh rename to common/base/pytorch/scripts/run_rccl_test.sh diff --git a/hygon-hub/common/utils/check_existence.sh b/common/utils/check_existence.sh similarity index 100% rename from hygon-hub/common/utils/check_existence.sh rename to common/utils/check_existence.sh diff --git a/hygon-hub/common/utils/download_utils.sh b/common/utils/download_utils.sh similarity index 100% rename from hygon-hub/common/utils/download_utils.sh rename to common/utils/download_utils.sh diff --git a/hygon-hub/common/utils/parse_torchrun_args.sh b/common/utils/parse_torchrun_args.sh similarity index 100% rename from hygon-hub/common/utils/parse_torchrun_args.sh rename to common/utils/parse_torchrun_args.sh diff --git a/hygon-hub/common/utils/run_cmd.sh b/common/utils/run_cmd.sh similarity index 100% rename from hygon-hub/common/utils/run_cmd.sh rename to common/utils/run_cmd.sh diff --git a/docker-hub/BEVFormer/BEVFormer/docs/getting_started.md b/docker-hub/BEVFormer/BEVFormer/docs/getting_started.md deleted file mode 100644 index 13ff695ffaaf2c8ce2eff18f86de23f07501c3e0..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/docs/getting_started.md +++ /dev/null @@ -1,31 +0,0 @@ -# Prerequisites - -**Please ensure you have prepared the environment and the nuScenes dataset.** - -# Train and Test - -Train BEVFormer with 8 GPUs -``` -./tools/dist_train.sh ./projects/configs/bevformer/bevformer_base.py 8 -``` - -Eval BEVFormer with 8 GPUs -``` -./tools/dist_test.sh ./projects/configs/bevformer/bevformer_base.py ./path/to/ckpts.pth 8 -``` -Note: using 1 GPU to eval can obtain slightly higher performance because continuous video may be truncated with multiple GPUs. By default we report the score evaled with 8 GPUs. - - - -# Using FP16 to train the model. -The above training script can not support FP16 training, -and we provide another script to train BEVFormer with FP16. - -``` -./tools/fp16/dist_train.sh ./projects/configs/bevformer_fp16/bevformer_tiny_fp16.py 8 -``` - - -# Visualization - -see [visual.py](../tools/analysis_tools/visual.py) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/docs/prepare_dataset.md b/docker-hub/BEVFormer/BEVFormer/docs/prepare_dataset.md deleted file mode 100644 index fc73fd871af62d9091ddb9f542b7c1737981cc2b..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/docs/prepare_dataset.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## NuScenes -Download nuScenes V1.0 full dataset data and CAN bus expansion data [HERE](https://www.nuscenes.org/download). Prepare nuscenes data by running - - -**Download CAN bus expansion** -``` -# download 'can_bus.zip' -unzip can_bus.zip -# move can_bus to data dir -``` - -**Prepare nuScenes data** - -*We genetate custom annotation files which are different from mmdet3d's* -``` -python tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes --version v1.0 --canbus ./data -``` - -Using the above code will generate `nuscenes_infos_temporal_{train,val}.pkl`. - -**Folder structure** -``` -bevformer -├── projects/ -├── tools/ -├── configs/ -├── ckpts/ -│ ├── r101_dcn_fcos3d_pretrain.pth -├── data/ -│ ├── can_bus/ -│ ├── nuscenes/ -│ │ ├── maps/ -│ │ ├── samples/ -│ │ ├── sweeps/ -│ │ ├── v1.0-test/ -| | ├── v1.0-trainval/ -| | ├── nuscenes_infos_temporal_train.pkl -| | ├── nuscenes_infos_temporal_val.pkl -``` diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_base.py b/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_base.py deleted file mode 100644 index dc2ec5ae5cda01ef9ea12bc8b4a4ec2aa4311ae0..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_base.py +++ /dev/null @@ -1,259 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -voxel_size = [0.2, 0.2, 8] - - - -img_norm_cfg = dict( - mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 4 -bev_h_ = 200 -bev_w_ = 200 -queue_length = 4 # each sequence contains `queue_length` frames. - -model = dict( - type='BEVFormer', - use_grid_mask=True, - video_test_mode=True, - img_backbone=dict( - type='ResNet', - depth=101, - num_stages=4, - out_indices=(1, 2, 3), - frozen_stages=1, - norm_cfg=dict(type='BN2d', requires_grad=False), - norm_eval=True, - style='caffe', - dcn=dict(type='DCNv2', deform_groups=1, fallback_on_stride=False), # original DCNv2 will print log when perform load_state_dict - stage_with_dcn=(False, False, True, True)), - img_neck=dict( - type='FPN', - in_channels=[512, 1024, 2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=4, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='BEVFormerHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_classes=10, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - transformer=dict( - type='PerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=6, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='DetectionTransformerDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='NMSFreeCoder', - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - pc_range=point_cloud_range, - max_num=300, - voxel_size=voxel_size, - num_classes=10), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.25), - loss_iou=dict(type='GIoULoss', loss_weight=0.0)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='HungarianAssigner3D', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - iou_cost=dict(type='IoUCost', weight=0.0), # Fake cost. This is just to make it compatible with DETR head. - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=1, - workers_per_gpu=32, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - samples_per_gpu=1, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=2e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01, - fused=True) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 1 -evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) -load_from = 'ckpts/r101_dcn_fcos3d_pretrain.pth' -log_config = dict( - interval=1, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) - -checkpoint_config = dict(interval=1) diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_tiny.py b/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_tiny.py deleted file mode 100644 index 78858ee9a0f4b26395ae1f871ab3ed80c46e95ee..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer/bevformer_tiny.py +++ /dev/null @@ -1,270 +0,0 @@ -# BEvFormer-tiny consumes at lease 6700M GPU memory -# compared to bevformer_base, bevformer_tiny has -# smaller backbone: R101-DCN -> R50 -# smaller BEV: 200*200 -> 50*50 -# less encoder layers: 6 -> 3 -# smaller input size: 1600*900 -> 800*450 -# multi-scale feautres -> single scale features (C5) - - -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -voxel_size = [0.2, 0.2, 8] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -bev_h_ = 50 -bev_w_ = 50 -queue_length = 3 # each sequence contains `queue_length` frames. - -model = dict( - type='BEVFormer', - use_grid_mask=True, - video_test_mode=True, - pretrained=dict(img='torchvision://resnet50'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='BEVFormerHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_classes=10, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - transformer=dict( - type='PerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=3, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='DetectionTransformerDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='NMSFreeCoder', - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - pc_range=point_cloud_range, - max_num=300, - voxel_size=voxel_size, - num_classes=10), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.25), - loss_iou=dict(type='GIoULoss', loss_weight=0.0)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='HungarianAssigner3D', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - iou_cost=dict(type='IoUCost', weight=0.0), # Fake cost. This is just to make it compatible with DETR head. - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=1, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=2e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) - -checkpoint_config = dict(interval=1) diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py b/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py deleted file mode 100644 index aa1e0437fdc182042a7c5513136f57f78ab81044..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py +++ /dev/null @@ -1,272 +0,0 @@ -# BEvFormer-tiny consumes at lease 6700M GPU memory -# compared to bevformer_base, bevformer_tiny has -# smaller backbone: R101-DCN -> R50 -# smaller BEV: 200*200 -> 50*50 -# less encoder layers: 6 -> 3 -# smaller input size: 1600*900 -> 800*450 -# multi-scale feautres -> single scale features (C5) - - -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -voxel_size = [0.2, 0.2, 8] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -bev_h_ = 50 -bev_w_ = 50 -queue_length = 3 # each sequence contains `queue_length` frames. - -model = dict( - type='BEVFormer_fp16', - use_grid_mask=True, - video_test_mode=True, - pretrained=dict(img='torchvision://resnet50'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='BEVFormerHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_classes=10, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - transformer=dict( - type='PerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=3, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='DetectionTransformerDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='NMSFreeCoder', - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - pc_range=point_cloud_range, - max_num=300, - voxel_size=voxel_size, - num_classes=10), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.25), - loss_iou=dict(type='GIoULoss', loss_weight=0.0)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='HungarianAssigner3D', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - iou_cost=dict(type='IoUCost', weight=0.0), # Fake cost. This is just to make it compatible with DETR head. - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=2, - workers_per_gpu=8, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=2.8e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner_video', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) - -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) -custom_hooks = [dict(type='TransferWeight',priority='LOWEST')] \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_lyft-3d.py b/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_lyft-3d.py deleted file mode 100644 index 5a95d898c91e463b731a08f7c52b8186e99da83a..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_lyft-3d.py +++ /dev/null @@ -1,136 +0,0 @@ -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-80, -80, -5, 80, 80, 3] -# For Lyft we usually do 9-class detection -class_names = [ - 'car', 'truck', 'bus', 'emergency_vehicle', 'other_vehicle', 'motorcycle', - 'bicycle', 'pedestrian', 'animal' -] -dataset_type = 'CustomLyftDataset' -data_root = 'data/lyft/' -# Input modality for Lyft dataset, this is consistent with the submission -# format which requires the information in input_modality. -input_modality = dict( - use_lidar=True, - use_camera=False, - use_radar=False, - use_map=False, - use_external=True) -file_client_args = dict(backend='disk') -# Uncomment the following if use ceph or other file clients. -# See https://mmcv.readthedocs.io/en/latest/api.html#mmcv.fileio.FileClient -# for more details. -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/lyft/': 's3://lyft/lyft/', -# 'data/lyft/': 's3://lyft/lyft/' -# })) -train_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True), - dict( - type='GlobalRotScaleTrans', - rot_range=[-0.3925, 0.3925], - scale_ratio_range=[0.95, 1.05], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D', flip_ratio_bev_horizontal=0.5), - dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='PointShuffle'), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) -] -test_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='GlobalRotScaleTrans', - rot_range=[0, 0], - scale_ratio_range=[1., 1.], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D'), - dict( - type='PointsRangeFilter', point_cloud_range=point_cloud_range), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points']) - ]) -] -# construct a pipeline for data and gt loading in show function -# please keep its loading function consistent with test_pipeline (e.g. client) -eval_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points']) -] - -data = dict( - samples_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_val.pkl', - pipeline=test_pipeline, - classes=class_names, - modality=input_modality, - test_mode=True), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_val.pkl', - pipeline=test_pipeline, - classes=class_names, - modality=input_modality, - test_mode=True)) -# For Lyft dataset, we usually evaluate the model at the end of training. -# Since the models are trained by 24 epochs by default, we set evaluation -# interval to be 24. Please change the interval accordingly if you do not -# use a default schedule. -evaluation = dict(interval=24, pipeline=eval_pipeline) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_waymo-3d.py b/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_waymo-3d.py deleted file mode 100644 index 4100e13546badb06e69fd0b1ed20158de8acf893..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/configs/datasets/custom_waymo-3d.py +++ /dev/null @@ -1,112 +0,0 @@ -# dataset settings -# D5 in the config name means the whole dataset is divided into 5 folds -# We only use one fold for efficient experiments -dataset_type = 'CustomWaymoDataset' -data_root = 'data/waymo/kitti_format/' -file_client_args = dict(backend='disk') -# Uncomment the following if use ceph or other file clients. -# See https://mmcv.readthedocs.io/en/latest/api.html#mmcv.fileio.FileClient -# for more details. -# file_client_args = dict( -# backend='petrel', path_mapping=dict(data='s3://waymo_data/')) - -img_norm_cfg = dict( - mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) -class_names = ['Car', 'Pedestrian', 'Cyclist'] -point_cloud_range = [-74.88, -74.88, -2, 74.88, 74.88, 4] -input_modality = dict(use_lidar=False, use_camera=True) -db_sampler = dict( - data_root=data_root, - info_path=data_root + 'waymo_dbinfos_train.pkl', - rate=1.0, - prepare=dict( - filter_by_difficulty=[-1], - filter_by_min_points=dict(Car=5, Pedestrian=10, Cyclist=10)), - classes=class_names, - sample_groups=dict(Car=15, Pedestrian=10, Cyclist=10), - points_loader=dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=[0, 1, 2, 3, 4], - file_client_args=file_client_args)) - - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1920, 1280), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - - -# construct a pipeline for data and gt loading in show function -# please keep its loading function consistent with test_pipeline (e.g. client) - -data = dict( - samples_per_gpu=2, - workers_per_gpu=4, - train=dict( - type='RepeatDataset', - times=2, - dataset=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_train.pkl', - split='training', - pipeline=train_pipeline, - modality=input_modality, - classes=class_names, - test_mode=False, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR', - # load one frame every five frames - load_interval=5)), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_val.pkl', - split='training', - pipeline=test_pipeline, - modality=input_modality, - classes=class_names, - test_mode=True, - box_type_3d='LiDAR'), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_val.pkl', - split='training', - pipeline=test_pipeline, - modality=input_modality, - classes=class_names, - test_mode=True, - box_type_3d='LiDAR')) - -evaluation = dict(interval=24, pipeline=test_pipeline) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/__init__.py deleted file mode 100755 index 48d0ee270ce1c76f4a4acb726c864edde0e61ef1..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from .core.bbox.assigners.hungarian_assigner_3d import HungarianAssigner3D -from .core.bbox.coders.nms_free_coder import NMSFreeCoder -from .core.bbox.match_costs import BBox3DL1Cost -from .core.evaluation.eval_hooks import CustomDistEvalHook -from .datasets.pipelines import ( - PhotoMetricDistortionMultiViewImage, PadMultiViewImage, - NormalizeMultiviewImage, CustomCollect3D) -from .models.utils import * -from .models.opt.adamw import AdamW2 -from .bevformer import * -from .dd3d import * diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/__init__.py deleted file mode 100644 index 15dff22b7478a0f30151d376d41f3dc46e88ba7d..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .train import custom_train_model -from .mmdet_train import custom_train_detector -# from .test import custom_multi_gpu_test \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py deleted file mode 100644 index 3c62a9ff29ca1fbb72c055f39260122aa48d6a7a..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py +++ /dev/null @@ -1,283 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import random -import warnings - -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, - Fp16OptimizerHook, OptimizerHook, build_optimizer, - build_runner, get_dist_info) -from mmcv.utils import build_from_cfg - -from mmdet.core import EvalHook - -from mmdet.datasets import (build_dataset, - replace_ImageToTensor) -from mmdet.utils import get_root_logger -import time -import os.path as osp -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.core.evaluation.eval_hooks import CustomDistEvalHook -from projects.mmdet3d_plugin.datasets import custom_build_dataset - - -from mmcv.runner import Hook - -class ProfilerHook(Hook): - def __init__(self, profiler, total_steps): - self.profiler = profiler - self.total_steps = total_steps # 总步数 (wait + warmup + active) * repeat - self.stopped = False - - def after_train_iter(self, runner): - - if self.profiler.step_num == self.total_steps and not self.stopped: - # 停止Profiler - self.profiler.stop() - self.stopped = True - - # 只在rank 0上打印结果 - rank, _ = get_dist_info() - if rank == 0: - # 获取并打印关键指标 - # table = self.profiler.key_averages().table( - # sort_by="self_cuda_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - # table = self.profiler.key_averages().table( - # sort_by="self_cpu_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - - results = self.profiler.key_averages().table(sort_by="cuda_time_total") - log_file = "/workspace/BEVFormer/profiler_logs/BW_log_step{}.txt".format(self.total_steps) - with open(log_file, mode='w') as file: - file.write(str(results)) - # self.profiler.start() - if not self.stopped: - self.profiler.step() - - -def custom_train_detector(model, - dataset, - cfg, - distributed=False, - validate=False, - timestamp=None, - eval_model=None, - meta=None): - logger = get_root_logger(cfg.log_level) - - # prepare data loaders - - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - #assert len(dataset)==1s - if 'imgs_per_gpu' in cfg.data: - logger.warning('"imgs_per_gpu" is deprecated in MMDet V2.0. ' - 'Please use "samples_per_gpu" instead') - if 'samples_per_gpu' in cfg.data: - logger.warning( - f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' - f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' - f'={cfg.data.imgs_per_gpu} is used in this experiments') - else: - logger.warning( - 'Automatically set "samples_per_gpu"="imgs_per_gpu"=' - f'{cfg.data.imgs_per_gpu} in this experiments') - cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu - - data_loaders = [ - build_dataloader( - ds, - cfg.data.samples_per_gpu, - cfg.data.workers_per_gpu, - # cfg.gpus will be ignored if distributed - len(cfg.gpu_ids), - dist=distributed, - seed=cfg.seed, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) for ds in dataset - ] - - # put model on gpus - if distributed: - find_unused_parameters = cfg.get('find_unused_parameters', False) - # Sets the `find_unused_parameters` parameter in - # torch.nn.parallel.DistributedDataParallel - model = MMDistributedDataParallel( - model.to(device='cuda', memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - if eval_model is not None: - eval_model = MMDistributedDataParallel( - eval_model.to(device='cuda', memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - else: - model = MMDataParallel( - model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - if eval_model is not None: - eval_model = MMDataParallel( - eval_model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - - if 'runner' not in cfg: - cfg.runner = { - 'type': 'EpochBasedRunner', - 'max_epochs': cfg.total_epochs - } - warnings.warn( - 'config is now expected to have a `runner` section, ' - 'please set `runner` in your config.', UserWarning) - else: - if 'total_epochs' in cfg: - assert cfg.total_epochs == cfg.runner.max_epochs - if eval_model is not None: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - eval_model=eval_model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - else: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - - # an ugly workaround to make .log and .log.json filenames the same - runner.timestamp = timestamp - - # fp16 setting - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=distributed) - elif distributed and 'type' not in cfg.optimizer_config: - optimizer_config = OptimizerHook(**cfg.optimizer_config) - else: - optimizer_config = cfg.optimizer_config - - # register hooks - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config, - cfg.get('momentum_config', None)) - - # register profiler hook - #trace_config = dict(type='tb_trace', dir_name='work_dir') - #profiler_config = dict(on_trace_ready=trace_config) - #runner.register_profiler_hook(profiler_config) - - if distributed: - if isinstance(runner, EpochBasedRunner): - runner.register_hook(DistSamplerSeedHook()) - - # register eval hooks - if validate: - # Support batch_size > 1 in validation - val_samples_per_gpu = cfg.data.val.pop('samples_per_gpu', 1) - if val_samples_per_gpu > 1: - assert False - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.val.pipeline = replace_ImageToTensor( - cfg.data.val.pipeline) - val_dataset = custom_build_dataset(cfg.data.val, dict(test_mode=True)) - - val_dataloader = build_dataloader( - val_dataset, - samples_per_gpu=val_samples_per_gpu, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) - eval_cfg = cfg.get('evaluation', {}) - eval_cfg['by_epoch'] = cfg.runner['type'] != 'IterBasedRunner' - eval_cfg['jsonfile_prefix'] = osp.join('val', cfg.work_dir, time.ctime().replace(' ','_').replace(':','_')) - eval_hook = CustomDistEvalHook if distributed else EvalHook - runner.register_hook(eval_hook(val_dataloader, **eval_cfg)) - - # user-defined hooks - if cfg.get('custom_hooks', None): - custom_hooks = cfg.custom_hooks - assert isinstance(custom_hooks, list), \ - f'custom_hooks expect list type, but got {type(custom_hooks)}' - for hook_cfg in cfg.custom_hooks: - assert isinstance(hook_cfg, dict), \ - 'Each item in custom_hooks expects dict type, but got ' \ - f'{type(hook_cfg)}' - hook_cfg = hook_cfg.copy() - priority = hook_cfg.pop('priority', 'NORMAL') - hook = build_from_cfg(hook_cfg, HOOKS) - runner.register_hook(hook, priority=priority) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - - if False: - # 创建profiler配置 - total_steps = (1 + 20 + 1) * 1 # 22 steps - profiler = torch.profiler.profile( - activities=[ - torch.profiler.ProfilerActivity.CPU, - torch.profiler.ProfilerActivity.CUDA - ], - schedule=torch.profiler.schedule( - wait=1, # 跳过前1个step - warmup=20, # 预热1个step(不计入结果) - active=1, # 分析3个step - repeat=1 # 只执行一轮 - ), - on_trace_ready=torch.profiler.tensorboard_trace_handler( - # f"{cfg.work_dir}/profiler_logs" # 输出目录 - "/workspace/BEVFormer/profiler_logs" - # "./profiler_logs" - ), - with_stack=True, # 收集调用栈信息 - profile_memory=False, # 分析内存使用 - record_shapes=False # 记录张量形状 - ) - # 创建并注册ProfilerHook - # profiler_hook = ProfilerHook(profiler) - profiler_hook = ProfilerHook(profiler,total_steps) - runner.register_hook(profiler_hook) - # 启动profiler - profiler.start() - print("==================================== profiler.start()===================================================================") - try: - # 运行训练 - runner.run(data_loaders, cfg.workflow) - finally: - # 确保profiler停止 - profiler.stop() - else: - # 正常训练 - runner.run(data_loaders, cfg.workflow) - - # runner.run(data_loaders, cfg.workflow) - #runner.run(data_loaders, cfg.workflow) - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old deleted file mode 100644 index 0c812ae3572daab8283d0278217de1b448b16041..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old +++ /dev/null @@ -1,200 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import random -import warnings - -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, - Fp16OptimizerHook, OptimizerHook, build_optimizer, - build_runner, get_dist_info) -from mmcv.utils import build_from_cfg - -from mmdet.core import EvalHook - -from mmdet.datasets import (build_dataset, - replace_ImageToTensor) -from mmdet.utils import get_root_logger -import time -import os.path as osp -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.core.evaluation.eval_hooks import CustomDistEvalHook -from projects.mmdet3d_plugin.datasets import custom_build_dataset -def custom_train_detector(model, - dataset, - cfg, - distributed=False, - validate=False, - timestamp=None, - eval_model=None, - meta=None): - logger = get_root_logger(cfg.log_level) - - # prepare data loaders - - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - #assert len(dataset)==1s - if 'imgs_per_gpu' in cfg.data: - logger.warning('"imgs_per_gpu" is deprecated in MMDet V2.0. ' - 'Please use "samples_per_gpu" instead') - if 'samples_per_gpu' in cfg.data: - logger.warning( - f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' - f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' - f'={cfg.data.imgs_per_gpu} is used in this experiments') - else: - logger.warning( - 'Automatically set "samples_per_gpu"="imgs_per_gpu"=' - f'{cfg.data.imgs_per_gpu} in this experiments') - cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu - - data_loaders = [ - build_dataloader( - ds, - cfg.data.samples_per_gpu, - cfg.data.workers_per_gpu, - # cfg.gpus will be ignored if distributed - len(cfg.gpu_ids), - dist=distributed, - seed=cfg.seed, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) for ds in dataset - ] - - # put model on gpus - if distributed: - find_unused_parameters = cfg.get('find_unused_parameters', False) - # Sets the `find_unused_parameters` parameter in - # torch.nn.parallel.DistributedDataParallel - model = MMDistributedDataParallel( - model.to(device='cuda', memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - if eval_model is not None: - eval_model = MMDistributedDataParallel( - eval_model.to(device='cuda', memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - else: - model = MMDataParallel( - model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - if eval_model is not None: - eval_model = MMDataParallel( - eval_model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - - if 'runner' not in cfg: - cfg.runner = { - 'type': 'EpochBasedRunner', - 'max_epochs': cfg.total_epochs - } - warnings.warn( - 'config is now expected to have a `runner` section, ' - 'please set `runner` in your config.', UserWarning) - else: - if 'total_epochs' in cfg: - assert cfg.total_epochs == cfg.runner.max_epochs - if eval_model is not None: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - eval_model=eval_model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - else: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - - # an ugly workaround to make .log and .log.json filenames the same - runner.timestamp = timestamp - - # fp16 setting - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=distributed) - elif distributed and 'type' not in cfg.optimizer_config: - optimizer_config = OptimizerHook(**cfg.optimizer_config) - else: - optimizer_config = cfg.optimizer_config - - # register hooks - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config, - cfg.get('momentum_config', None)) - - # register profiler hook - #trace_config = dict(type='tb_trace', dir_name='work_dir') - #profiler_config = dict(on_trace_ready=trace_config) - #runner.register_profiler_hook(profiler_config) - - if distributed: - if isinstance(runner, EpochBasedRunner): - runner.register_hook(DistSamplerSeedHook()) - - # register eval hooks - if validate: - # Support batch_size > 1 in validation - val_samples_per_gpu = cfg.data.val.pop('samples_per_gpu', 1) - if val_samples_per_gpu > 1: - assert False - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.val.pipeline = replace_ImageToTensor( - cfg.data.val.pipeline) - val_dataset = custom_build_dataset(cfg.data.val, dict(test_mode=True)) - - val_dataloader = build_dataloader( - val_dataset, - samples_per_gpu=val_samples_per_gpu, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) - eval_cfg = cfg.get('evaluation', {}) - eval_cfg['by_epoch'] = cfg.runner['type'] != 'IterBasedRunner' - eval_cfg['jsonfile_prefix'] = osp.join('val', cfg.work_dir, time.ctime().replace(' ','_').replace(':','_')) - eval_hook = CustomDistEvalHook if distributed else EvalHook - runner.register_hook(eval_hook(val_dataloader, **eval_cfg)) - - # user-defined hooks - if cfg.get('custom_hooks', None): - custom_hooks = cfg.custom_hooks - assert isinstance(custom_hooks, list), \ - f'custom_hooks expect list type, but got {type(custom_hooks)}' - for hook_cfg in cfg.custom_hooks: - assert isinstance(hook_cfg, dict), \ - 'Each item in custom_hooks expects dict type, but got ' \ - f'{type(hook_cfg)}' - hook_cfg = hook_cfg.copy() - priority = hook_cfg.pop('priority', 'NORMAL') - hook = build_from_cfg(hook_cfg, HOOKS) - runner.register_hook(hook, priority=priority) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - runner.run(data_loaders, cfg.workflow) - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bev_head.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bev_head.py deleted file mode 100644 index a2aa03665b6ffd2c917e805fdd8d12f060741a4f..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bev_head.py +++ /dev/null @@ -1,132 +0,0 @@ -import copy -from re import I -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import Linear, bias_init_with_prob -from mmcv.utils import TORCH_VERSION, digit_version - -from mmdet.core import (multi_apply, multi_apply, reduce_mean) -from mmdet.models.utils.transformer import inverse_sigmoid -from mmdet.models import HEADS -from mmdet.models.dense_heads import DETRHead -from mmdet3d.core.bbox.coders import build_bbox_coder -from traitlets import import_item -from projects.mmdet3d_plugin.core.bbox.util import normalize_bbox -from mmcv.cnn.bricks.transformer import build_positional_encoding -from mmcv.runner import BaseModule, force_fp32 -from projects.mmdet3d_plugin.models.utils.bricks import run_time -import numpy as np -import mmcv -import cv2 as cv -from projects.mmdet3d_plugin.bevformer.modules import PerceptionTransformerBEVEncoder -from mmdet.models.utils import build_transformer -from mmdet3d.models.builder import build_head -from mmdet3d.models.dense_heads.free_anchor3d_head import FreeAnchor3DHead - -@HEADS.register_module() -class BEVHead(BaseModule): - def __init__(self, - bev_h, - bev_w, - pc_range, - embed_dims, - transformer, - positional_encoding: dict, - pts_bbox_head_3d: dict, - init_cfg=None, - **kwargs, - ): - super(BEVHead, self).__init__(init_cfg=init_cfg) - self.bev_h = bev_h - self.bev_w = bev_w - self.embed_dims = embed_dims - self.pc_range = pc_range - self.fp16_enabled = False - self.transformer :PerceptionTransformerBEVEncoder = build_transformer(transformer) - self.positional_encoding = build_positional_encoding(positional_encoding) - - pts_bbox_head_3d.update(kwargs) - self.pts_bbox_head_3d = build_head(pts_bbox_head_3d) - self.real_w = self.pc_range[3] - self.pc_range[0] - self.real_h = self.pc_range[4] - self.pc_range[1] - - self._init_layers() - def init_weights(self): - """Initialize weights of the Multi View BEV Encoder""" - self.transformer.init_weights() - - def _init_layers(self): - """Initialize classification branch and regression branch of head.""" - - self.bev_embedding = nn.Embedding(self.bev_h * self.bev_w, self.embed_dims) - - @force_fp32(apply_to=('mlvl_feats', 'pred_bev')) - def forward(self, mlvl_feats, img_metas, prev_bev=None, only_bev=False): - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - - bev_embed = self.transformer( - mlvl_feats, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - ) - - if only_bev: - return bev_embed - - bev_feature = bev_embed.permute(0, 2, 1).reshape(bs, self.embed_dims, self.bev_h, self.bev_w) - ret = {} - ret['pred'] = self.pts_bbox_head_3d([bev_feature,]) - if not self.training: - ret['bev_embed'] = bev_embed - return ret - - - @force_fp32(apply_to=('ret')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - ret, - gt_bboxes_ignore=None, - img_metas=None): - assert gt_bboxes_ignore is None - return self.pts_bbox_head_3d.loss(gt_bboxes_list, gt_labels_list, ret['pred'], gt_bboxes_ignore=gt_bboxes_ignore, img_metas=img_metas) - - @force_fp32(apply_to=('ret')) - def get_bboxes(self, ret, img_metas, rescale=False): - return self.pts_bbox_head_3d.get_bboxes(ret['pred'], img_metas) - -@HEADS.register_module() -class FreeAnchor3DHeadV2(FreeAnchor3DHead): - @force_fp32(apply_to=('pred')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - pred, - gt_bboxes_ignore=None, - img_metas=None): - cls_scores, bbox_preds, dir_cls_preds = pred - - return super().loss(cls_scores, bbox_preds, dir_cls_preds, gt_bboxes_list, gt_labels_list, img_metas, gt_bboxes_ignore) - @force_fp32(apply_to=('pred')) - def get_bboxes(self, pred, img_metas, rescale=False): - cls_scores, bbox_preds, dir_cls_preds = pred - return super().get_bboxes( - cls_scores, - bbox_preds, - dir_cls_preds, - img_metas, - cfg=None, - rescale=rescale) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py deleted file mode 100644 index 93c7cd73241bdb02c4bfda44f1d8ec1a20d5db2c..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py +++ /dev/null @@ -1,683 +0,0 @@ -import copy -import torch -import torch.nn as nn - -from mmcv.cnn import Linear, bias_init_with_prob -from mmcv.utils import TORCH_VERSION, digit_version -from mmdet.core import (multi_apply, multi_apply, reduce_mean) -from mmdet.models.utils.transformer import inverse_sigmoid -from mmdet.models import HEADS -from mmdet.models.dense_heads import DETRHead -from mmdet3d.core.bbox.coders import build_bbox_coder -from projects.mmdet3d_plugin.core.bbox.util import normalize_bbox -from mmcv.runner import force_fp32, auto_fp16 - - -@HEADS.register_module() -class BEVFormerHead(DETRHead): - """Head of Detr3D. - Args: - with_box_refine (bool): Whether to refine the reference points - in the decoder. Defaults to False. - as_two_stage (bool) : Whether to generate the proposal from - the outputs of encoder. - transformer (obj:`ConfigDict`): ConfigDict is used for building - the Encoder and Decoder. - bev_h, bev_w (int): spatial shape of BEV queries. - """ - - def __init__(self, - *args, - with_box_refine=False, - as_two_stage=False, - transformer=None, - bbox_coder=None, - num_cls_fcs=2, - code_weights=None, - bev_h=30, - bev_w=30, - **kwargs): - - self.bev_h = bev_h - self.bev_w = bev_w - self.fp16_enabled = False - - self.with_box_refine = with_box_refine - self.as_two_stage = as_two_stage - if self.as_two_stage: - transformer['as_two_stage'] = self.as_two_stage - if 'code_size' in kwargs: - self.code_size = kwargs['code_size'] - else: - self.code_size = 10 - if code_weights is not None: - self.code_weights = code_weights - else: - self.code_weights = [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2] - - self.bbox_coder = build_bbox_coder(bbox_coder) - self.pc_range = self.bbox_coder.pc_range - self.real_w = self.pc_range[3] - self.pc_range[0] - self.real_h = self.pc_range[4] - self.pc_range[1] - self.num_cls_fcs = num_cls_fcs - 1 - super(BEVFormerHead, self).__init__( - *args, transformer=transformer, **kwargs) - self.code_weights = nn.Parameter(torch.tensor( - self.code_weights, requires_grad=False), requires_grad=False) - - def _init_layers(self): - """Initialize classification branch and regression branch of head.""" - cls_branch = [] - for _ in range(self.num_reg_fcs): - cls_branch.append(Linear(self.embed_dims, self.embed_dims)) - cls_branch.append(nn.LayerNorm(self.embed_dims)) - cls_branch.append(nn.ReLU(inplace=True)) - cls_branch.append(Linear(self.embed_dims, self.cls_out_channels)) - fc_cls = nn.Sequential(*cls_branch) - - reg_branch = [] - for _ in range(self.num_reg_fcs): - reg_branch.append(Linear(self.embed_dims, self.embed_dims)) - reg_branch.append(nn.ReLU()) - reg_branch.append(Linear(self.embed_dims, self.code_size)) - reg_branch = nn.Sequential(*reg_branch) - - def _get_clones(module, N): - return nn.ModuleList([copy.deepcopy(module) for i in range(N)]) - - # last reg_branch is used to generate proposal from - # encode feature map when as_two_stage is True. - num_pred = (self.transformer.decoder.num_layers + 1) if \ - self.as_two_stage else self.transformer.decoder.num_layers - - if self.with_box_refine: - self.cls_branches = _get_clones(fc_cls, num_pred) - self.reg_branches = _get_clones(reg_branch, num_pred) - else: - self.cls_branches = nn.ModuleList( - [fc_cls for _ in range(num_pred)]) - self.reg_branches = nn.ModuleList( - [reg_branch for _ in range(num_pred)]) - - if not self.as_two_stage: - self.bev_embedding = nn.Embedding( - self.bev_h * self.bev_w, self.embed_dims) - self.query_embedding = nn.Embedding(self.num_query, - self.embed_dims * 2) - - def init_weights(self): - """Initialize weights of the DeformDETR head.""" - self.transformer.init_weights() - if self.loss_cls.use_sigmoid: - bias_init = bias_init_with_prob(0.01) - for m in self.cls_branches: - nn.init.constant_(m[-1].bias, bias_init) - - @auto_fp16(apply_to=('mlvl_feats')) - def forward(self, mlvl_feats, img_metas, prev_bev=None, only_bev=False): - """Forward function. - Args: - mlvl_feats (tuple[Tensor]): Features from the upstream - network, each is a 5D-tensor with shape - (B, N, C, H, W). - prev_bev: previous bev featues - only_bev: only compute BEV features with encoder. - Returns: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, theta, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - """ - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - object_query_embeds = self.query_embedding.weight.to(dtype) - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - - if only_bev: # only use encoder to obtain BEV features, TODO: refine the workaround - return self.transformer.get_bev_features( - mlvl_feats, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - ) - else: - outputs = self.transformer( - mlvl_feats, - bev_queries, - object_query_embeds, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - reg_branches=self.reg_branches if self.with_box_refine else None, # noqa:E501 - cls_branches=self.cls_branches if self.as_two_stage else None, - img_metas=img_metas, - prev_bev=prev_bev - ) - - bev_embed, hs, init_reference, inter_references = outputs - hs = hs.permute(0, 2, 1, 3) - outputs_classes = [] - outputs_coords = [] - for lvl in range(hs.shape[0]): - if lvl == 0: - reference = init_reference - else: - reference = inter_references[lvl - 1] - reference = inverse_sigmoid(reference) - outputs_class = self.cls_branches[lvl](hs[lvl]) - tmp = self.reg_branches[lvl](hs[lvl]) - - # TODO: check the shape of reference - assert reference.shape[-1] == 3 - tmp[..., 0:2] += reference[..., 0:2] - tmp[..., 0:2] = tmp[..., 0:2].sigmoid() - tmp[..., 4:5] += reference[..., 2:3] - tmp[..., 4:5] = tmp[..., 4:5].sigmoid() - tmp[..., 0:1] = (tmp[..., 0:1] * (self.pc_range[3] - - self.pc_range[0]) + self.pc_range[0]) - tmp[..., 1:2] = (tmp[..., 1:2] * (self.pc_range[4] - - self.pc_range[1]) + self.pc_range[1]) - tmp[..., 4:5] = (tmp[..., 4:5] * (self.pc_range[5] - - self.pc_range[2]) + self.pc_range[2]) - - # TODO: check if using sigmoid - outputs_coord = tmp - outputs_classes.append(outputs_class) - outputs_coords.append(outputs_coord) - - outputs_classes = torch.stack(outputs_classes) - outputs_coords = torch.stack(outputs_coords) - - outs = { - 'bev_embed': bev_embed, - 'all_cls_scores': outputs_classes, - 'all_bbox_preds': outputs_coords, - 'enc_cls_scores': None, - 'enc_bbox_preds': None, - } - - return outs - - def _get_target_single(self, - cls_score, - bbox_pred, - gt_labels, - gt_bboxes, - gt_bboxes_ignore=None): - """"Compute regression and classification targets for one image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_score (Tensor): Box score logits from a single decoder layer - for one image. Shape [num_query, cls_out_channels]. - bbox_pred (Tensor): Sigmoid outputs from a single decoder layer - for one image, with normalized coordinate (cx, cy, w, h) and - shape [num_query, 4]. - gt_bboxes (Tensor): Ground truth bboxes for one image with - shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels (Tensor): Ground truth class indices for one image - with shape (num_gts, ). - gt_bboxes_ignore (Tensor, optional): Bounding boxes - which can be ignored. Default None. - Returns: - tuple[Tensor]: a tuple containing the following for one image. - - labels (Tensor): Labels of each image. - - label_weights (Tensor]): Label weights of each image. - - bbox_targets (Tensor): BBox targets of each image. - - bbox_weights (Tensor): BBox weights of each image. - - pos_inds (Tensor): Sampled positive indices for each image. - - neg_inds (Tensor): Sampled negative indices for each image. - """ - - num_bboxes = bbox_pred.size(0) - # assigner and sampler - gt_c = gt_bboxes.shape[-1] - - assign_result = self.assigner.assign(bbox_pred, cls_score, gt_bboxes, - gt_labels, gt_bboxes_ignore) - - sampling_result = self.sampler.sample(assign_result, bbox_pred, - gt_bboxes) - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - - # label targets - labels = gt_bboxes.new_full((num_bboxes,), - self.num_classes, - dtype=torch.long) - labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] - label_weights = gt_bboxes.new_ones(num_bboxes) - - # bbox targets - bbox_targets = torch.zeros_like(bbox_pred)[..., :gt_c] - bbox_weights = torch.zeros_like(bbox_pred) - bbox_weights[pos_inds] = 1.0 - - # DETR - bbox_targets[pos_inds] = sampling_result.pos_gt_bboxes - return (labels, label_weights, bbox_targets, bbox_weights, - pos_inds, neg_inds) - - def get_targets(self, - cls_scores_list, - bbox_preds_list, - gt_bboxes_list, - gt_labels_list, - gt_bboxes_ignore_list=None): - """"Compute regression and classification targets for a batch image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_scores_list (list[Tensor]): Box score logits from a single - decoder layer for each image with shape [num_query, - cls_out_channels]. - bbox_preds_list (list[Tensor]): Sigmoid outputs from a single - decoder layer for each image, with normalized coordinate - (cx, cy, w, h) and shape [num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - tuple: a tuple containing the following targets. - - labels_list (list[Tensor]): Labels for all images. - - label_weights_list (list[Tensor]): Label weights for all \ - images. - - bbox_targets_list (list[Tensor]): BBox targets for all \ - images. - - bbox_weights_list (list[Tensor]): BBox weights for all \ - images. - - num_total_pos (int): Number of positive samples in all \ - images. - - num_total_neg (int): Number of negative samples in all \ - images. - """ - assert gt_bboxes_ignore_list is None, \ - 'Only supports for gt_bboxes_ignore setting to None.' - num_imgs = len(cls_scores_list) - gt_bboxes_ignore_list = [ - gt_bboxes_ignore_list for _ in range(num_imgs) - ] - - (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pos_inds_list, neg_inds_list) = multi_apply( - self._get_target_single, cls_scores_list, bbox_preds_list, - gt_labels_list, gt_bboxes_list, gt_bboxes_ignore_list) - num_total_pos = sum((inds.numel() for inds in pos_inds_list)) - num_total_neg = sum((inds.numel() for inds in neg_inds_list)) - return (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, num_total_pos, num_total_neg) - - def loss_single(self, - cls_scores, - bbox_preds, - gt_bboxes_list, - gt_labels_list, - gt_bboxes_ignore_list=None): - """"Loss function for outputs from a single decoder layer of a single - feature level. - Args: - cls_scores (Tensor): Box score logits from a single decoder layer - for all images. Shape [bs, num_query, cls_out_channels]. - bbox_preds (Tensor): Sigmoid outputs from a single decoder layer - for all images, with normalized coordinate (cx, cy, w, h) and - shape [bs, num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components for outputs from - a single decoder layer. - """ - num_imgs = cls_scores.size(0) - cls_scores_list = [cls_scores[i] for i in range(num_imgs)] - bbox_preds_list = [bbox_preds[i] for i in range(num_imgs)] - cls_reg_targets = self.get_targets(cls_scores_list, bbox_preds_list, - gt_bboxes_list, gt_labels_list, - gt_bboxes_ignore_list) - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - labels = torch.cat(labels_list, 0) - label_weights = torch.cat(label_weights_list, 0) - bbox_targets = torch.cat(bbox_targets_list, 0) - bbox_weights = torch.cat(bbox_weights_list, 0) - - # classification loss - cls_scores = cls_scores.reshape(-1, self.cls_out_channels) - # construct weighted avg_factor to match with the official DETR repo - cls_avg_factor = num_total_pos * 1.0 + \ - num_total_neg * self.bg_cls_weight - if self.sync_cls_avg_factor: - cls_avg_factor = reduce_mean( - cls_scores.new_tensor([cls_avg_factor])) - - cls_avg_factor = max(cls_avg_factor, 1) - loss_cls = self.loss_cls( - cls_scores, labels, label_weights, avg_factor=cls_avg_factor) - - # Compute the average number of gt boxes accross all gpus, for - # normalization purposes - num_total_pos = loss_cls.new_tensor([num_total_pos]) - num_total_pos = torch.clamp(reduce_mean(num_total_pos), min=1).item() - - # regression L1 loss - bbox_preds = bbox_preds.reshape(-1, bbox_preds.size(-1)) - normalized_bbox_targets = normalize_bbox(bbox_targets, self.pc_range) - isnotnan = torch.isfinite(normalized_bbox_targets).all(dim=-1) - bbox_weights = bbox_weights * self.code_weights - - loss_bbox = self.loss_bbox( - bbox_preds[isnotnan, :10], normalized_bbox_targets[isnotnan, - :10], bbox_weights[isnotnan, :10], - avg_factor=num_total_pos) - if digit_version(TORCH_VERSION) >= digit_version('1.8'): - loss_cls = torch.nan_to_num(loss_cls) - loss_bbox = torch.nan_to_num(loss_bbox) - return loss_cls, loss_bbox - - @force_fp32(apply_to=('preds_dicts')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - preds_dicts, - gt_bboxes_ignore=None, - img_metas=None): - """"Loss function. - Args: - - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - preds_dicts: - all_cls_scores (Tensor): Classification score of all - decoder layers, has shape - [nb_dec, bs, num_query, cls_out_channels]. - all_bbox_preds (Tensor): Sigmoid regression - outputs of all decode layers. Each is a 4D-tensor with - normalized coordinate format (cx, cy, w, h) and shape - [nb_dec, bs, num_query, 4]. - enc_cls_scores (Tensor): Classification scores of - points on encode feature map , has shape - (N, h*w, num_classes). Only be passed when as_two_stage is - True, otherwise is None. - enc_bbox_preds (Tensor): Regression results of each points - on the encode feature map, has shape (N, h*w, 4). Only be - passed when as_two_stage is True, otherwise is None. - gt_bboxes_ignore (list[Tensor], optional): Bounding boxes - which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components. - """ - assert gt_bboxes_ignore is None, \ - f'{self.__class__.__name__} only supports ' \ - f'for gt_bboxes_ignore setting to None.' - - all_cls_scores = preds_dicts['all_cls_scores'] - all_bbox_preds = preds_dicts['all_bbox_preds'] - enc_cls_scores = preds_dicts['enc_cls_scores'] - enc_bbox_preds = preds_dicts['enc_bbox_preds'] - - num_dec_layers = len(all_cls_scores) - device = gt_labels_list[0].device - - gt_bboxes_list = [torch.cat( - (gt_bboxes.gravity_center, gt_bboxes.tensor[:, 3:]), - dim=1).to(device) for gt_bboxes in gt_bboxes_list] - - all_gt_bboxes_list = [gt_bboxes_list for _ in range(num_dec_layers)] - all_gt_labels_list = [gt_labels_list for _ in range(num_dec_layers)] - all_gt_bboxes_ignore_list = [ - gt_bboxes_ignore for _ in range(num_dec_layers) - ] - - losses_cls, losses_bbox = multi_apply( - self.loss_single, all_cls_scores, all_bbox_preds, - all_gt_bboxes_list, all_gt_labels_list, - all_gt_bboxes_ignore_list) - - loss_dict = dict() - # loss of proposal generated from encode feature map. - if enc_cls_scores is not None: - binary_labels_list = [ - torch.zeros_like(gt_labels_list[i]) - for i in range(len(all_gt_labels_list)) - ] - enc_loss_cls, enc_losses_bbox = \ - self.loss_single(enc_cls_scores, enc_bbox_preds, - gt_bboxes_list, binary_labels_list, gt_bboxes_ignore) - loss_dict['enc_loss_cls'] = enc_loss_cls - loss_dict['enc_loss_bbox'] = enc_losses_bbox - - # loss from the last decoder layer - loss_dict['loss_cls'] = losses_cls[-1] - loss_dict['loss_bbox'] = losses_bbox[-1] - - # loss from other decoder layers - num_dec_layer = 0 - for loss_cls_i, loss_bbox_i in zip(losses_cls[:-1], - losses_bbox[:-1]): - loss_dict[f'd{num_dec_layer}.loss_cls'] = loss_cls_i - loss_dict[f'd{num_dec_layer}.loss_bbox'] = loss_bbox_i - num_dec_layer += 1 - return loss_dict - - @force_fp32(apply_to=('preds_dicts')) - def get_bboxes(self, preds_dicts, img_metas, rescale=False): - """Generate bboxes from bbox head predictions. - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - img_metas (list[dict]): Point cloud and image's meta info. - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - """ - - preds_dicts = self.bbox_coder.decode(preds_dicts) - - num_samples = len(preds_dicts) - ret_list = [] - for i in range(num_samples): - preds = preds_dicts[i] - bboxes = preds['bboxes'] - - bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - - code_size = bboxes.shape[-1] - bboxes = img_metas[i]['box_type_3d'](bboxes, code_size) - scores = preds['scores'] - labels = preds['labels'] - - ret_list.append([bboxes, scores, labels]) - - return ret_list - - -@HEADS.register_module() -class BEVFormerHead_GroupDETR(BEVFormerHead): - def __init__(self, - *args, - group_detr=1, - **kwargs): - self.group_detr = group_detr - assert 'num_query' in kwargs - kwargs['num_query'] = group_detr * kwargs['num_query'] - super().__init__(*args, **kwargs) - - def forward(self, mlvl_feats, img_metas, prev_bev=None, only_bev=False): - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - object_query_embeds = self.query_embedding.weight.to(dtype) - if not self.training: # NOTE: Only difference to bevformer head - object_query_embeds = object_query_embeds[:self.num_query // self.group_detr] - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - - if only_bev: - return self.transformer.get_bev_features( - mlvl_feats, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - ) - else: - outputs = self.transformer( - mlvl_feats, - bev_queries, - object_query_embeds, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - reg_branches=self.reg_branches if self.with_box_refine else None, # noqa:E501 - cls_branches=self.cls_branches if self.as_two_stage else None, - img_metas=img_metas, - prev_bev=prev_bev - ) - - bev_embed, hs, init_reference, inter_references = outputs - hs = hs.permute(0, 2, 1, 3) - outputs_classes = [] - outputs_coords = [] - for lvl in range(hs.shape[0]): - if lvl == 0: - reference = init_reference - else: - reference = inter_references[lvl - 1] - reference = inverse_sigmoid(reference) - outputs_class = self.cls_branches[lvl](hs[lvl]) - tmp = self.reg_branches[lvl](hs[lvl]) - assert reference.shape[-1] == 3 - tmp[..., 0:2] += reference[..., 0:2] - tmp[..., 0:2] = tmp[..., 0:2].sigmoid() - tmp[..., 4:5] += reference[..., 2:3] - tmp[..., 4:5] = tmp[..., 4:5].sigmoid() - tmp[..., 0:1] = (tmp[..., 0:1] * (self.pc_range[3] - - self.pc_range[0]) + self.pc_range[0]) - tmp[..., 1:2] = (tmp[..., 1:2] * (self.pc_range[4] - - self.pc_range[1]) + self.pc_range[1]) - tmp[..., 4:5] = (tmp[..., 4:5] * (self.pc_range[5] - - self.pc_range[2]) + self.pc_range[2]) - outputs_coord = tmp - outputs_classes.append(outputs_class) - outputs_coords.append(outputs_coord) - - outputs_classes = torch.stack(outputs_classes) - outputs_coords = torch.stack(outputs_coords) - - outs = { - 'bev_embed': bev_embed, - 'all_cls_scores': outputs_classes, - 'all_bbox_preds': outputs_coords, - 'enc_cls_scores': None, - 'enc_bbox_preds': None, - } - - return outs - - def loss(self, - gt_bboxes_list, - gt_labels_list, - preds_dicts, - gt_bboxes_ignore=None, - img_metas=None): - """"Loss function. - Args: - - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - preds_dicts: - all_cls_scores (Tensor): Classification score of all - decoder layers, has shape - [nb_dec, bs, num_query, cls_out_channels]. - all_bbox_preds (Tensor): Sigmoid regression - outputs of all decode layers. Each is a 4D-tensor with - normalized coordinate format (cx, cy, w, h) and shape - [nb_dec, bs, num_query, 4]. - enc_cls_scores (Tensor): Classification scores of - points on encode feature map , has shape - (N, h*w, num_classes). Only be passed when as_two_stage is - True, otherwise is None. - enc_bbox_preds (Tensor): Regression results of each points - on the encode feature map, has shape (N, h*w, 4). Only be - passed when as_two_stage is True, otherwise is None. - gt_bboxes_ignore (list[Tensor], optional): Bounding boxes - which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components. - """ - assert gt_bboxes_ignore is None, \ - f'{self.__class__.__name__} only supports ' \ - f'for gt_bboxes_ignore setting to None.' - - all_cls_scores = preds_dicts['all_cls_scores'] - all_bbox_preds = preds_dicts['all_bbox_preds'] - enc_cls_scores = preds_dicts['enc_cls_scores'] - enc_bbox_preds = preds_dicts['enc_bbox_preds'] - assert enc_cls_scores is None and enc_bbox_preds is None - - num_dec_layers = len(all_cls_scores) - device = gt_labels_list[0].device - - gt_bboxes_list = [torch.cat( - (gt_bboxes.gravity_center, gt_bboxes.tensor[:, 3:]), - dim=1).to(device) for gt_bboxes in gt_bboxes_list] - - all_gt_bboxes_list = [gt_bboxes_list for _ in range(num_dec_layers)] - all_gt_labels_list = [gt_labels_list for _ in range(num_dec_layers)] - all_gt_bboxes_ignore_list = [ - gt_bboxes_ignore for _ in range(num_dec_layers) - ] - - loss_dict = dict() - loss_dict['loss_cls'] = 0 - loss_dict['loss_bbox'] = 0 - for num_dec_layer in range(all_cls_scores.shape[0] - 1): - loss_dict[f'd{num_dec_layer}.loss_cls'] = 0 - loss_dict[f'd{num_dec_layer}.loss_bbox'] = 0 - num_query_per_group = self.num_query // self.group_detr - for group_index in range(self.group_detr): - group_query_start = group_index * num_query_per_group - group_query_end = (group_index+1) * num_query_per_group - group_cls_scores = all_cls_scores[:, :,group_query_start:group_query_end, :] - group_bbox_preds = all_bbox_preds[:, :,group_query_start:group_query_end, :] - losses_cls, losses_bbox = multi_apply( - self.loss_single, group_cls_scores, group_bbox_preds, - all_gt_bboxes_list, all_gt_labels_list, - all_gt_bboxes_ignore_list) - loss_dict['loss_cls'] += losses_cls[-1] / self.group_detr - loss_dict['loss_bbox'] += losses_bbox[-1] / self.group_detr - # loss from other decoder layers - num_dec_layer = 0 - for loss_cls_i, loss_bbox_i in zip(losses_cls[:-1], losses_bbox[:-1]): - loss_dict[f'd{num_dec_layer}.loss_cls'] += loss_cls_i / self.group_detr - loss_dict[f'd{num_dec_layer}.loss_bbox'] += loss_bbox_i / self.group_detr - num_dec_layer += 1 - return loss_dict \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/__init__.py deleted file mode 100644 index 059bffb1ebec21b517620a743229244f93c66a15..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .bevformer import BEVFormer -from .bevformer_fp16 import BEVFormer_fp16 -from .bevformerV2 import BEVFormerV2 \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformerV2.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformerV2.py deleted file mode 100644 index 79efa12735dad1aaaa594696f52d4b604620365b..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformerV2.py +++ /dev/null @@ -1,269 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import copy -from collections import OrderedDict -import torch -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from mmdet3d.models.builder import build_head -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask - - -@DETECTORS.register_module() -class BEVFormerV2(MVXTwoStageDetector): - """BEVFormer. - Args: - video_test_mode (bool): Decide whether to use temporal information during inference. - """ - - def __init__(self, - use_grid_mask=False, - pts_voxel_layer=None, - pts_voxel_encoder=None, - pts_middle_encoder=None, - pts_fusion_layer=None, - img_backbone=None, - pts_backbone=None, - img_neck=None, - pts_neck=None, - pts_bbox_head=None, - fcos3d_bbox_head=None, - img_roi_head=None, - img_rpn_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None, - video_test_mode=False, - num_levels=None, - num_mono_levels=None, - mono_loss_weight=1.0, - frames=(0,), - ): - - super(BEVFormerV2, - self).__init__(pts_voxel_layer, pts_voxel_encoder, - pts_middle_encoder, pts_fusion_layer, - img_backbone, pts_backbone, img_neck, pts_neck, - pts_bbox_head, img_roi_head, img_rpn_head, - train_cfg, test_cfg, pretrained) - self.grid_mask = GridMask( - True, True, rotate=1, offset=False, ratio=0.5, mode=1, prob=0.7) - self.use_grid_mask = use_grid_mask - self.fp16_enabled = False - assert not self.fp16_enabled # not support fp16 yet - # temporal - self.video_test_mode = video_test_mode - assert not self.video_test_mode # not support video_test_mode yet - - # fcos3d head - self.fcos3d_bbox_head = build_head(fcos3d_bbox_head) if fcos3d_bbox_head else None - # loss weight - self.mono_loss_weight = mono_loss_weight - - # levels of features - self.num_levels = num_levels - self.num_mono_levels = num_mono_levels - self.frames = frames - def extract_img_feat(self, img): - """Extract features of images.""" - B = img.size(0) - if img is not None: - if img.dim() == 5 and img.size(0) == 1: - img.squeeze_() - elif img.dim() == 5 and img.size(0) > 1: - B, N, C, H, W = img.size() - img = img.reshape(B * N, C, H, W) - if self.use_grid_mask: - img = self.grid_mask(img) - - img_feats = self.img_backbone(img) - if isinstance(img_feats, dict): - img_feats = list(img_feats.values()) - else: - return None - if self.with_img_neck: - img_feats = self.img_neck(img_feats) - - img_feats_reshaped = [] - for img_feat in img_feats: - BN, C, H, W = img_feat.size() - img_feats_reshaped.append(img_feat.view(B, int(BN / B), C, H, W)) - return img_feats_reshaped - - def extract_feat(self, img, img_metas, len_queue=None): - """Extract features from images and points.""" - - img_feats = self.extract_img_feat(img) - if 'aug_param' in img_metas[0] and img_metas[0]['aug_param']['CropResizeFlipImage_param'][-1] is True: - # flip feature - img_feats = [torch.flip(x, dims=[-1, ]) for x in img_feats] - return img_feats - - def forward_pts_train(self, - pts_feats, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None, - prev_bev=None): - outs = self.pts_bbox_head( - pts_feats, img_metas, prev_bev) - loss_inputs = [gt_bboxes_3d, gt_labels_3d, outs] - losses = self.pts_bbox_head.loss(*loss_inputs, img_metas=img_metas) - return losses - - def forward_mono_train(self, img_feats, mono_input_dict): - """ - img_feats (list[Tensor]): 5-D tensor for each level, (B, N, C, H, W) - gt_bboxes (list[list[Tensor]]): Ground truth bboxes for each image with - shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels (list[list[Tensor]]): class indices corresponding to each box - gt_bboxes_3d (list[list[[Tensor]]): 3D boxes ground truth with shape of - (num_gts, code_size). - gt_labels_3d (list[list[Tensor]]): same as gt_labels - centers2d (list[list[Tensor]]): 2D centers on the image with shape of - (num_gts, 2). - depths (list[list[Tensor]]): Depth ground truth with shape of - (num_gts, ). - attr_labels (list[list[Tensor]]): Attributes indices of each box. - img_metas (list[list[dict]]): Meta information of each image, e.g., - image size, scaling factor, etc. - ann_idx (list[list[idx]]): indicate which image has mono annotation. - """ - bsz = img_feats[0].shape[0]; - num_lvls = len(img_feats) - - img_feats_select = [[] for lvl in range(num_lvls)] - for lvl, img_feat in enumerate(img_feats): - for i in range(bsz): - img_feats_select[lvl].append(img_feat[i, mono_input_dict['mono_ann_idx'][i]]) - img_feats_select[lvl] = torch.cat(img_feats_select[lvl], dim=0) - bsz_new = img_feats_select[0].shape[0] - assert bsz == len(mono_input_dict['mono_input_dict']) - input_dict = [] - for i in range(bsz): - input_dict.extend(mono_input_dict['mono_input_dict'][i]) - assert bsz_new == len(input_dict) - losses = self.fcos3d_bbox_head.forward_train(img_feats_select, input_dict) - return losses - - def forward_dummy(self, img): - dummy_metas = None - return self.forward_test(img=img, img_metas=[[dummy_metas]]) - - def forward(self, return_loss=True, **kwargs): - if return_loss: - return self.forward_train(**kwargs) - else: - return self.forward_test(**kwargs) - - def obtain_history_bev(self, img_dict, img_metas_dict): - """Obtain history BEV features iteratively. To save GPU memory, gradients are not calculated. - """ - # Modify: roll back to previous version for single frame - is_training = self.training - self.eval() - prev_bev = OrderedDict({i: None for i in self.frames}) - with torch.no_grad(): - for t in img_dict.keys(): - img = img_dict[t] - img_metas = [img_metas_dict[t], ] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - if self.num_levels: - img_feats = img_feats[:self.num_levels] - bev = self.pts_bbox_head( - img_feats, img_metas, None, only_bev=True) - prev_bev[t] = bev.detach() - if is_training: - self.train() - return list(prev_bev.values()) - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - img=None, - gt_bboxes_ignore=None, - **mono_input_dict, - ): - img_metas = OrderedDict(sorted(img_metas[0].items())) - img_dict = {} - for ind, t in enumerate(img_metas.keys()): - img_dict[t] = img[:, ind, ...] - - img = img_dict[0] - img_dict.pop(0) - - prev_img_metas = copy.deepcopy(img_metas) - prev_img_metas.pop(0) - prev_bev = self.obtain_history_bev(img_dict, prev_img_metas) - - img_metas = [img_metas[0], ] - - img_feats = self.extract_feat(img=img, img_metas=img_metas) - losses = dict() - losses_pts = self.forward_pts_train(img_feats if self.num_levels is None - else img_feats[:self.num_levels], gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev) - losses.update(losses_pts) - - if self.fcos3d_bbox_head: - losses_mono = self.forward_mono_train(img_feats=img_feats if self.num_mono_levels is None - else img_feats[:self.num_mono_levels], - mono_input_dict=mono_input_dict) - for k, v in losses_mono.items(): - losses[f'{k}_mono'] = v * self.mono_loss_weight - - return losses - - def forward_test(self, img_metas, img=None, **kwargs): - for var, name in [(img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - img = [img] if img is None else img - new_prev_bev, bbox_results = self.simple_test(img_metas[0], img[0], prev_bev=None, **kwargs) - return bbox_results - - def simple_test_pts(self, x, img_metas, prev_bev=None, rescale=False): - """Test function""" - outs = self.pts_bbox_head(x, img_metas, prev_bev=prev_bev) - - bbox_list = self.pts_bbox_head.get_bboxes( - outs, img_metas, rescale=rescale) - bbox_results = [ - bbox3d2result(bboxes, scores, labels) - for bboxes, scores, labels in bbox_list - ] - return outs['bev_embed'], bbox_results - - def simple_test(self, img_metas, img=None, prev_bev=None, rescale=False, **kwargs): - """Test function without augmentaiton.""" - img_metas = OrderedDict(sorted(img_metas[0].items())) - img_dict = {} - for ind, t in enumerate(img_metas.keys()): - img_dict[t] = img[:, ind, ...] - img = img_dict[0] - img_dict.pop(0) - - prev_img_metas = copy.deepcopy(img_metas) - prev_bev = self.obtain_history_bev(img_dict, prev_img_metas) - - img_metas = [img_metas[0], ] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - if self.num_levels: - img_feats = img_feats[:self.num_levels] - - bbox_list = [dict() for i in range(len(img_metas))] - new_prev_bev, bbox_pts = self.simple_test_pts( - img_feats, img_metas, prev_bev, rescale=rescale) - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return new_prev_bev, bbox_list diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py deleted file mode 100644 index 5325e3ccb8ac576a6764df3f0094ac5ea1bbc7cb..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py +++ /dev/null @@ -1,89 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from tkinter.messagebox import NO -import torch -from mmcv.runner import force_fp32, auto_fp16 -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask -from projects.mmdet3d_plugin.bevformer.detectors.bevformer import BEVFormer -import time -import copy -import numpy as np -import mmdet3d -from projects.mmdet3d_plugin.models.utils.bricks import run_time - - -@DETECTORS.register_module() -class BEVFormer_fp16(BEVFormer): - """ - The default version BEVFormer currently can not support FP16. - We provide this version to resolve this issue. - """ - - @auto_fp16(apply_to=('img', 'prev_bev', 'points')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - prev_bev=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - - img_feats = self.extract_feat(img=img, img_metas=img_metas) - - losses = dict() - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev=prev_bev) - losses.update(losses_pts) - return losses - - - def val_step(self, data, optimizer): - """ - In BEVFormer_fp16, we use this `val_step` function to inference the `prev_pev`. - This is not the standard function of `val_step`. - """ - - img = data['img'] - img_metas = data['img_metas'] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - prev_bev = data.get('prev_bev', None) - prev_bev = self.pts_bbox_head(img_feats, img_metas, prev_bev=prev_bev, only_bev=True) - return prev_bev \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/__init__.py deleted file mode 100644 index aa04ec16df5b0bb9f21cadf22f9172c3cc9a58c1..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .custom_hooks import TransferWeight \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py deleted file mode 100644 index 1fd599c786805c4273e0c826d4a2632a98dbec52..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py +++ /dev/null @@ -1,13 +0,0 @@ -from mmcv.runner.hooks.hook import HOOKS, Hook -from projects.mmdet3d_plugin.models.utils import run_time - - -@HOOKS.register_module() -class TransferWeight(Hook): - - def __init__(self, every_n_inters=1): - self.every_n_inters=every_n_inters - - def after_train_iter(self, runner): - if self.every_n_inner_iters(runner, self.every_n_inters): - runner.eval_model.load_state_dict(runner.model.state_dict()) diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/__init__.py deleted file mode 100644 index 9c8cc0d48fc71f17c7ef6f8607a826b6299880c8..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from .transformer import PerceptionTransformer -from .transformerV2 import PerceptionTransformerV2, PerceptionTransformerBEVEncoder -from .spatial_cross_attention import SpatialCrossAttention, MSDeformableAttention3D -from .temporal_self_attention import TemporalSelfAttention -from .encoder import BEVFormerEncoder, BEVFormerLayer -from .decoder import DetectionTransformerDecoder -from .group_attention import GroupMultiheadAttention - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/decoder.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/decoder.py deleted file mode 100644 index 8c8bd63fd8992e5e30533fb2f14114db565f686d..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/decoder.py +++ /dev/null @@ -1,346 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from mmcv.ops.multi_scale_deform_attn import multi_scale_deformable_attn_pytorch -import mmcv -import cv2 as cv -import copy -import warnings -from matplotlib import pyplot as plt -import numpy as np -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init, constant_init -from mmcv.cnn.bricks.registry import (ATTENTION, - TRANSFORMER_LAYER_SEQUENCE) -from mmcv.cnn.bricks.transformer import TransformerLayerSequence -import math -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential -from mmcv.utils import (ConfigDict, build_from_cfg, deprecated_api_warning, - to_2tuple) - -from mmcv.utils import ext_loader -from .multi_scale_deformable_attn_function import MultiScaleDeformableAttnFunction_fp32, \ - MultiScaleDeformableAttnFunction_fp16 - -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - - -def inverse_sigmoid(x, eps=1e-5): - """Inverse function of sigmoid. - Args: - x (Tensor): The tensor to do the - inverse. - eps (float): EPS avoid numerical - overflow. Defaults 1e-5. - Returns: - Tensor: The x has passed the inverse - function of sigmoid, has same - shape with input. - """ - x = x.clamp(min=0, max=1) - x1 = x.clamp(min=eps) - x2 = (1 - x).clamp(min=eps) - return torch.log(x1 / x2) - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class DetectionTransformerDecoder(TransformerLayerSequence): - """Implements the decoder in DETR3D transformer. - Args: - return_intermediate (bool): Whether to return intermediate outputs. - coder_norm_cfg (dict): Config of last normalization layer. Default: - `LN`. - """ - - def __init__(self, *args, return_intermediate=False, **kwargs): - super(DetectionTransformerDecoder, self).__init__(*args, **kwargs) - self.return_intermediate = return_intermediate - self.fp16_enabled = False - - @torch.compile(mode="max-autotune-no-cudagraphs") - def forward(self, - query, - *args, - reference_points=None, - reg_branches=None, - key_padding_mask=None, - **kwargs): - """Forward function for `Detr3DTransformerDecoder`. - Args: - query (Tensor): Input query with shape - `(num_query, bs, embed_dims)`. - reference_points (Tensor): The reference - points of offset. has shape - (bs, num_query, 4) when as_two_stage, - otherwise has shape ((bs, num_query, 2). - reg_branch: (obj:`nn.ModuleList`): Used for - refining the regression results. Only would - be passed when with_box_refine is True, - otherwise would be passed a `None`. - Returns: - Tensor: Results with shape [1, num_query, bs, embed_dims] when - return_intermediate is `False`, otherwise it has shape - [num_layers, num_query, bs, embed_dims]. - """ - output = query - intermediate = [] - intermediate_reference_points = [] - for lid, layer in enumerate(self.layers): - - reference_points_input = reference_points[..., :2].unsqueeze( - 2) # BS NUM_QUERY NUM_LEVEL 2 - output = layer( - output, - *args, - reference_points=reference_points_input, - key_padding_mask=key_padding_mask, - **kwargs) - output = output.permute(1, 0, 2) - - if reg_branches is not None: - tmp = reg_branches[lid](output) - - assert reference_points.shape[-1] == 3 - - new_reference_points = torch.zeros_like(reference_points) - new_reference_points[..., :2] = tmp[ - ..., :2] + inverse_sigmoid(reference_points[..., :2]) - new_reference_points[..., 2:3] = tmp[ - ..., 4:5] + inverse_sigmoid(reference_points[..., 2:3]) - - new_reference_points = new_reference_points.sigmoid() - - reference_points = new_reference_points.detach() - - output = output.permute(1, 0, 2) - if self.return_intermediate: - intermediate.append(output) - intermediate_reference_points.append(reference_points) - - if self.return_intermediate: - return torch.stack(intermediate), torch.stack( - intermediate_reference_points) - - return output, reference_points - - -@ATTENTION.register_module() -class CustomMSDeformableAttention(BaseModule): - """An attention module used in Deformable-Detr. - - `Deformable DETR: Deformable Transformers for End-to-End Object Detection. - `_. - - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_heads (int): Parallel attention heads. Default: 64. - num_levels (int): The number of feature map used in - Attention. Default: 4. - num_points (int): The number of sampling points for - each query in each head. Default: 4. - im2col_step (int): The step used in image_to_column. - Default: 64. - dropout (float): A Dropout layer on `inp_identity`. - Default: 0.1. - batch_first (bool): Key, Query and Value are shape of - (batch, n, embed_dim) - or (n, batch, embed_dim). Default to False. - norm_cfg (dict): Config dict for normalization layer. - Default: None. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims=256, - num_heads=8, - num_levels=4, - num_points=4, - im2col_step=64, - dropout=0.1, - batch_first=False, - norm_cfg=None, - init_cfg=None): - super().__init__(init_cfg) - if embed_dims % num_heads != 0: - raise ValueError(f'embed_dims must be divisible by num_heads, ' - f'but got {embed_dims} and {num_heads}') - dim_per_head = embed_dims // num_heads - self.norm_cfg = norm_cfg - self.dropout = nn.Dropout(dropout) - self.batch_first = batch_first - self.fp16_enabled = False - - # you'd better set dim_per_head to a power of 2 - # which is more efficient in the CUDA implementation - def _is_power_of_2(n): - if (not isinstance(n, int)) or (n < 0): - raise ValueError( - 'invalid input for _is_power_of_2: {} (type: {})'.format( - n, type(n))) - return (n & (n - 1) == 0) and n != 0 - - if not _is_power_of_2(dim_per_head): - warnings.warn( - "You'd better set embed_dims in " - 'MultiScaleDeformAttention to make ' - 'the dimension of each attention head a power of 2 ' - 'which is more efficient in our CUDA implementation.') - - self.im2col_step = im2col_step - self.embed_dims = embed_dims - self.num_levels = num_levels - self.num_heads = num_heads - self.num_points = num_points - self.sampling_offsets = nn.Linear( - embed_dims, num_heads * num_levels * num_points * 2) - self.attention_weights = nn.Linear(embed_dims, - num_heads * num_levels * num_points) - self.value_proj = nn.Linear(embed_dims, embed_dims) - self.output_proj = nn.Linear(embed_dims, embed_dims) - self.init_weights() - - def init_weights(self): - """Default initialization for Parameters of Module.""" - constant_init(self.sampling_offsets, 0.) - thetas = torch.arange( - self.num_heads, - dtype=torch.float32) * (2.0 * math.pi / self.num_heads) - grid_init = torch.stack([thetas.cos(), thetas.sin()], -1) - grid_init = (grid_init / - grid_init.abs().max(-1, keepdim=True)[0]).view( - self.num_heads, 1, 1, - 2).repeat(1, self.num_levels, self.num_points, 1) - for i in range(self.num_points): - grid_init[:, :, i, :] *= i + 1 - - self.sampling_offsets.bias.data = grid_init.view(-1) - constant_init(self.attention_weights, val=0., bias=0.) - xavier_init(self.value_proj, distribution='uniform', bias=0.) - xavier_init(self.output_proj, distribution='uniform', bias=0.) - self._is_init = True - - @deprecated_api_warning({'residual': 'identity'}, - cls_name='MultiScaleDeformableAttention') - def forward(self, - query, - key=None, - value=None, - identity=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - level_start_index=None, - flag='decoder', - **kwargs): - """Forward Function of MultiScaleDeformAttention. - - Args: - query (Tensor): Query of Transformer with shape - (num_query, bs, embed_dims). - key (Tensor): The key tensor with shape - `(num_key, bs, embed_dims)`. - value (Tensor): The value tensor with shape - `(num_key, bs, embed_dims)`. - identity (Tensor): The tensor used for addition, with the - same shape as `query`. Default None. If None, - `query` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, num_levels, 2), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different levels. With shape (num_levels, 2), - last dimension represents (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape ``(num_levels, )`` and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if value is None: - value = query - - if identity is None: - identity = query - if query_pos is not None: - query = query + query_pos - if not self.batch_first: - # change to (bs, num_query ,embed_dims) - query = query.permute(1, 0, 2) - value = value.permute(1, 0, 2) - - bs, num_query, _ = query.shape - bs, num_value, _ = value.shape - assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value - - value = self.value_proj(value) - if key_padding_mask is not None: - value = value.masked_fill(key_padding_mask[..., None], 0.0) - value = value.view(bs, num_value, self.num_heads, -1) - - sampling_offsets = self.sampling_offsets(query).view( - bs, num_query, self.num_heads, self.num_levels, self.num_points, 2) - attention_weights = self.attention_weights(query).view( - bs, num_query, self.num_heads, self.num_levels * self.num_points) - attention_weights = attention_weights.softmax(-1) - - attention_weights = attention_weights.view(bs, num_query, - self.num_heads, - self.num_levels, - self.num_points) - if reference_points.shape[-1] == 2: - offset_normalizer = torch.stack( - [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1) - sampling_locations = reference_points[:, :, None, :, None, :] \ - + sampling_offsets \ - / offset_normalizer[None, None, None, :, None, :] - elif reference_points.shape[-1] == 4: - sampling_locations = reference_points[:, :, None, :, None, :2] \ - + sampling_offsets / self.num_points \ - * reference_points[:, :, None, :, None, 2:] \ - * 0.5 - else: - raise ValueError( - f'Last dim of reference_points must be' - f' 2 or 4, but get {reference_points.shape[-1]} instead.') - if torch.cuda.is_available() and value.is_cuda: - - # using fp16 deformable attention is unstable because it performs many sum operations - if value.dtype == torch.float16: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - else: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - output = MultiScaleDeformableAttnFunction.apply( - value, spatial_shapes, level_start_index, sampling_locations, - attention_weights, self.im2col_step) - else: - output = multi_scale_deformable_attn_pytorch( - value, spatial_shapes, sampling_locations, attention_weights) - - output = self.output_proj(output) - - if not self.batch_first: - # (num_query, bs ,embed_dims) - output = output.permute(1, 0, 2) - - return self.dropout(output) + identity diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py deleted file mode 100644 index 1c717d8ed1f819002bbcceaba0e00ba772ed70e0..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py +++ /dev/null @@ -1,194 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import torch -from torch.cuda.amp import custom_bwd, custom_fwd -from torch.autograd.function import Function, once_differentiable -from mmcv.utils import ext_loader -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - -@torch.library.custom_op("mmcv::ms_deform_attn_forward_warper", mutates_args=()) -def ms_deform_attn_forward_warper( - value: torch.Tensor, - value_spatial_shapes: torch.Tensor, - value_level_start_index: torch.Tensor, - sampling_locations: torch.Tensor, - attention_weights: torch.Tensor, - im2col_step: int) -> torch.Tensor: - return ext_module.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - im2col_step=im2col_step) - -@ms_deform_attn_forward_warper.register_fake -def _( - value: torch.Tensor, - value_spatial_shapes: torch.Tensor, - value_level_start_index: torch.Tensor, - sampling_locations: torch.Tensor, - attention_weights: torch.Tensor, - im2col_step: int) -> torch.Tensor: - bs = value.shape[0] - num_queries = sampling_locations.shape[1] - embed_dims = value.shape[3] * sampling_locations.shape[2] - result = torch.empty(bs, num_queries, embed_dims, device=value.device, dtype=value.dtype) - return result - - -class MultiScaleDeformableAttnFunction_fp16(Function): - - @staticmethod - @custom_fwd(cast_inputs=torch.float16) - def forward(ctx, value, value_spatial_shapes, value_level_start_index, - sampling_locations, attention_weights, im2col_step): - """GPU version of multi-scale deformable attention. - - Args: - value (Tensor): The value has shape - (bs, num_keys, mum_heads, embed_dims//num_heads) - value_spatial_shapes (Tensor): Spatial shape of - each feature map, has shape (num_levels, 2), - last dimension 2 represent (h, w) - sampling_locations (Tensor): The location of sampling points, - has shape - (bs ,num_queries, num_heads, num_levels, num_points, 2), - the last dimension 2 represent (x, y). - attention_weights (Tensor): The weight of sampling points used - when calculate the attention, has shape - (bs ,num_queries, num_heads, num_levels, num_points), - im2col_step (Tensor): The step used in image to column. - - Returns: - Tensor: has shape (bs, num_queries, embed_dims) - """ - ctx.im2col_step = im2col_step - output = ext_module.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - im2col_step=ctx.im2col_step) - ctx.save_for_backward(value, value_spatial_shapes, - value_level_start_index, sampling_locations, - attention_weights) - return output - - @staticmethod - @once_differentiable - @custom_bwd - def backward(ctx, grad_output): - """GPU version of backward function. - - Args: - grad_output (Tensor): Gradient - of output tensor of forward. - - Returns: - Tuple[Tensor]: Gradient - of input tensors in forward. - """ - value, value_spatial_shapes, value_level_start_index, \ - sampling_locations, attention_weights = ctx.saved_tensors - grad_value = torch.zeros_like(value) - grad_sampling_loc = torch.zeros_like(sampling_locations) - grad_attn_weight = torch.zeros_like(attention_weights) - - ext_module.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output.contiguous(), - grad_value, - grad_sampling_loc, - grad_attn_weight, - im2col_step=ctx.im2col_step) - - return grad_value, None, None, \ - grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttnFunction_fp32(Function): - - @staticmethod - @custom_fwd(cast_inputs=torch.float32) - def forward(ctx, value, value_spatial_shapes, value_level_start_index, - sampling_locations, attention_weights, im2col_step): - """GPU version of multi-scale deformable attention. - - Args: - value (Tensor): The value has shape - (bs, num_keys, mum_heads, embed_dims//num_heads) - value_spatial_shapes (Tensor): Spatial shape of - each feature map, has shape (num_levels, 2), - last dimension 2 represent (h, w) - sampling_locations (Tensor): The location of sampling points, - has shape - (bs ,num_queries, num_heads, num_levels, num_points, 2), - the last dimension 2 represent (x, y). - attention_weights (Tensor): The weight of sampling points used - when calculate the attention, has shape - (bs ,num_queries, num_heads, num_levels, num_points), - im2col_step (Tensor): The step used in image to column. - - Returns: - Tensor: has shape (bs, num_queries, embed_dims) - """ - - ctx.im2col_step = im2col_step - output = ext_module.ms_deform_attn_forward( - #output = ms_deform_attn_forward_warper( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - im2col_step=ctx.im2col_step) - ctx.save_for_backward(value, value_spatial_shapes, - value_level_start_index, sampling_locations, - attention_weights) - return output - - @staticmethod - @once_differentiable - @custom_bwd - def backward(ctx, grad_output): - """GPU version of backward function. - - Args: - grad_output (Tensor): Gradient - of output tensor of forward. - - Returns: - Tuple[Tensor]: Gradient - of input tensors in forward. - """ - value, value_spatial_shapes, value_level_start_index, \ - sampling_locations, attention_weights = ctx.saved_tensors - grad_value = torch.zeros_like(value) - grad_sampling_loc = torch.zeros_like(sampling_locations) - grad_attn_weight = torch.zeros_like(attention_weights) - - ext_module.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output.contiguous(), - grad_value, - grad_sampling_loc, - grad_attn_weight, - im2col_step=ctx.im2col_step) - - return grad_value, None, None, \ - grad_sampling_loc, grad_attn_weight, None diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py deleted file mode 100644 index c9f4e8e73fc12e512560d1432ec25adf2be7ee6d..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py +++ /dev/null @@ -1,404 +0,0 @@ - -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from mmcv.ops.multi_scale_deform_attn import multi_scale_deformable_attn_pytorch -import warnings -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init, constant_init -from mmcv.cnn.bricks.registry import (ATTENTION, - TRANSFORMER_LAYER, - TRANSFORMER_LAYER_SEQUENCE) -from mmcv.cnn.bricks.transformer import build_attention -import math -from mmcv.runner import force_fp32, auto_fp16 - -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential - -from mmcv.utils import ext_loader -from .multi_scale_deformable_attn_function import MultiScaleDeformableAttnFunction_fp32, \ - MultiScaleDeformableAttnFunction_fp16 -from projects.mmdet3d_plugin.models.utils.bricks import run_time -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - - -@ATTENTION.register_module() -class SpatialCrossAttention(BaseModule): - """An attention module used in BEVFormer. - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_cams (int): The number of cameras - dropout (float): A Dropout layer on `inp_residual`. - Default: 0.. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - deformable_attention: (dict): The config for the deformable attention used in SCA. - """ - - def __init__(self, - embed_dims=256, - num_cams=6, - pc_range=None, - dropout=0.1, - init_cfg=None, - batch_first=False, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=256, - num_levels=4), - **kwargs - ): - super(SpatialCrossAttention, self).__init__(init_cfg) - - self.init_cfg = init_cfg - self.dropout = nn.Dropout(dropout) - self.pc_range = pc_range - self.fp16_enabled = False - self.deformable_attention = build_attention(deformable_attention) - self.embed_dims = embed_dims - self.num_cams = num_cams - self.output_proj = nn.Linear(embed_dims, embed_dims) - self.batch_first = batch_first - self.init_weight() - - def init_weight(self): - """Default initialization for Parameters of Module.""" - xavier_init(self.output_proj, distribution='uniform', bias=0.) - - @force_fp32(apply_to=('query', 'key', 'value', 'query_pos', 'reference_points_cam')) - def forward(self, - query, - key, - value, - residual=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - reference_points_cam=None, - bev_mask=None, - level_start_index=None, - flag='encoder', - indexes=None, - **kwargs): - """Forward Function of Detr3DCrossAtten. - Args: - query (Tensor): Query of Transformer with shape - (num_query, bs, embed_dims). - key (Tensor): The key tensor with shape - `(num_key, bs, embed_dims)`. - value (Tensor): The value tensor with shape - `(num_key, bs, embed_dims)`. (B, N, C, H, W) - residual (Tensor): The tensor used for addition, with the - same shape as `x`. Default None. If None, `x` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, 4), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different level. With shape (num_levels, 2), - last dimension represent (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape (num_levels) and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - if key is None: - key = query - if value is None: - value = key - - if residual is None: - inp_residual = query - slots = torch.zeros_like(query) - if query_pos is not None: - query = query + query_pos - - bs, num_query, _ = query.size() - - D = reference_points_cam.size(3) - ''' - indexes = [] - for i, mask_per_img in enumerate(bev_mask): - index_query_per_img = mask_per_img[0].sum(-1).nonzero().squeeze(-1) - indexes.append(index_query_per_img) - max_len = max([len(each) for each in indexes]) - ''' - lengths = torch.tensor([len(each) for each in indexes], device="cpu", pin_memory=True).to(query.device, non_blocking=True) - max_len = torch.max(lengths).item() - - - # each camera only interacts with its corresponding BEV queries. This step can greatly save GPU memory. - queries_rebatch = query.new_zeros( - [bs, self.num_cams, max_len, self.embed_dims]) - reference_points_rebatch = reference_points_cam.new_zeros( - [bs, self.num_cams, max_len, D, 2]) - - for j in range(bs): - for i, reference_points_per_img in enumerate(reference_points_cam): - index_query_per_img = indexes[i] - queries_rebatch[j, i, :len(index_query_per_img)] = query[j, index_query_per_img] - reference_points_rebatch[j, i, :len(index_query_per_img)] = reference_points_per_img[j, index_query_per_img] - - num_cams, l, bs, embed_dims = key.shape - - key = key.permute(2, 0, 1, 3).reshape( - bs * self.num_cams, l, self.embed_dims) - value = value.permute(2, 0, 1, 3).reshape( - bs * self.num_cams, l, self.embed_dims) - - queries = self.deformable_attention(query=queries_rebatch.view(bs*self.num_cams, max_len, self.embed_dims), key=key, value=value, - reference_points=reference_points_rebatch.view(bs*self.num_cams, max_len, D, 2), spatial_shapes=spatial_shapes, - level_start_index=level_start_index).view(bs, self.num_cams, max_len, self.embed_dims) - for j in range(bs): - for i, index_query_per_img in enumerate(indexes): - slots[j, index_query_per_img] += queries[j, i, :len(index_query_per_img)] - - count = bev_mask.sum(-1) > 0 - count = count.permute(1, 2, 0).sum(-1) - count = torch.clamp(count, min=1.0) - slots = slots / count[..., None] - slots = self.output_proj(slots) - - return self.dropout(slots) + inp_residual - - -@ATTENTION.register_module() -class MSDeformableAttention3D(BaseModule): - """An attention module used in BEVFormer based on Deformable-Detr. - `Deformable DETR: Deformable Transformers for End-to-End Object Detection. - `_. - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_heads (int): Parallel attention heads. Default: 64. - num_levels (int): The number of feature map used in - Attention. Default: 4. - num_points (int): The number of sampling points for - each query in each head. Default: 4. - im2col_step (int): The step used in image_to_column. - Default: 64. - dropout (float): A Dropout layer on `inp_identity`. - Default: 0.1. - batch_first (bool): Key, Query and Value are shape of - (batch, n, embed_dim) - or (n, batch, embed_dim). Default to False. - norm_cfg (dict): Config dict for normalization layer. - Default: None. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims=256, - num_heads=8, - num_levels=4, - num_points=8, - im2col_step=64, - dropout=0.1, - batch_first=True, - norm_cfg=None, - init_cfg=None): - super().__init__(init_cfg) - if embed_dims % num_heads != 0: - raise ValueError(f'embed_dims must be divisible by num_heads, ' - f'but got {embed_dims} and {num_heads}') - dim_per_head = embed_dims // num_heads - self.norm_cfg = norm_cfg - self.batch_first = batch_first - self.output_proj = None - self.fp16_enabled = False - - # you'd better set dim_per_head to a power of 2 - # which is more efficient in the CUDA implementation - def _is_power_of_2(n): - if (not isinstance(n, int)) or (n < 0): - raise ValueError( - 'invalid input for _is_power_of_2: {} (type: {})'.format( - n, type(n))) - return (n & (n - 1) == 0) and n != 0 - - if not _is_power_of_2(dim_per_head): - warnings.warn( - "You'd better set embed_dims in " - 'MultiScaleDeformAttention to make ' - 'the dimension of each attention head a power of 2 ' - 'which is more efficient in our CUDA implementation.') - - self.im2col_step = im2col_step - self.embed_dims = embed_dims - self.num_levels = num_levels - self.num_heads = num_heads - self.num_points = num_points - self.sampling_offsets = nn.Linear( - embed_dims, num_heads * num_levels * num_points * 2) - self.attention_weights = nn.Linear(embed_dims, - num_heads * num_levels * num_points) - self.value_proj = nn.Linear(embed_dims, embed_dims) - - self.init_weights() - - def init_weights(self): - """Default initialization for Parameters of Module.""" - constant_init(self.sampling_offsets, 0.) - thetas = torch.arange( - self.num_heads, - dtype=torch.float32) * (2.0 * math.pi / self.num_heads) - grid_init = torch.stack([thetas.cos(), thetas.sin()], -1) - grid_init = (grid_init / - grid_init.abs().max(-1, keepdim=True)[0]).view( - self.num_heads, 1, 1, - 2).repeat(1, self.num_levels, self.num_points, 1) - for i in range(self.num_points): - grid_init[:, :, i, :] *= i + 1 - - self.sampling_offsets.bias.data = grid_init.view(-1) - constant_init(self.attention_weights, val=0., bias=0.) - xavier_init(self.value_proj, distribution='uniform', bias=0.) - xavier_init(self.output_proj, distribution='uniform', bias=0.) - self._is_init = True - - def forward(self, - query, - key=None, - value=None, - identity=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - level_start_index=None, - **kwargs): - """Forward Function of MultiScaleDeformAttention. - Args: - query (Tensor): Query of Transformer with shape - ( bs, num_query, embed_dims). - key (Tensor): The key tensor with shape - `(bs, num_key, embed_dims)`. - value (Tensor): The value tensor with shape - `(bs, num_key, embed_dims)`. - identity (Tensor): The tensor used for addition, with the - same shape as `query`. Default None. If None, - `query` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, num_levels, 2), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different levels. With shape (num_levels, 2), - last dimension represents (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape ``(num_levels, )`` and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if value is None: - value = query - if identity is None: - identity = query - if query_pos is not None: - query = query + query_pos - - if not self.batch_first: - # change to (bs, num_query ,embed_dims) - query = query.permute(1, 0, 2) - value = value.permute(1, 0, 2) - - bs, num_query, _ = query.shape - bs, num_value, _ = value.shape - assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value - - value = self.value_proj(value) - if key_padding_mask is not None: - value = value.masked_fill(key_padding_mask[..., None], 0.0) - value = value.view(bs, num_value, self.num_heads, -1) - sampling_offsets = self.sampling_offsets(query).view( - bs, num_query, self.num_heads, self.num_levels, self.num_points, 2) - attention_weights = self.attention_weights(query).view( - bs, num_query, self.num_heads, self.num_levels * self.num_points) - - attention_weights = attention_weights.softmax(-1) - - attention_weights = attention_weights.view(bs, num_query, - self.num_heads, - self.num_levels, - self.num_points) - - if reference_points.shape[-1] == 2: - """ - For each BEV query, it owns `num_Z_anchors` in 3D space that having different heights. - After proejcting, each BEV query has `num_Z_anchors` reference points in each 2D image. - For each referent point, we sample `num_points` sampling points. - For `num_Z_anchors` reference points, it has overall `num_points * num_Z_anchors` sampling points. - """ - offset_normalizer = torch.stack( - [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1) - - bs, num_query, num_Z_anchors, xy = reference_points.shape - reference_points = reference_points[:, :, None, None, None, :, :] - sampling_offsets = sampling_offsets / \ - offset_normalizer[None, None, None, :, None, :] - bs, num_query, num_heads, num_levels, num_all_points, xy = sampling_offsets.shape - sampling_offsets = sampling_offsets.view( - bs, num_query, num_heads, num_levels, num_all_points // num_Z_anchors, num_Z_anchors, xy) - sampling_locations = reference_points + sampling_offsets - bs, num_query, num_heads, num_levels, num_points, num_Z_anchors, xy = sampling_locations.shape - assert num_all_points == num_points * num_Z_anchors - - sampling_locations = sampling_locations.view( - bs, num_query, num_heads, num_levels, num_all_points, xy) - - elif reference_points.shape[-1] == 4: - assert False - else: - raise ValueError( - f'Last dim of reference_points must be' - f' 2 or 4, but get {reference_points.shape[-1]} instead.') - - # sampling_locations.shape: bs, num_query, num_heads, num_levels, num_all_points, 2 - # attention_weights.shape: bs, num_query, num_heads, num_levels, num_all_points - # - - if torch.cuda.is_available() and value.is_cuda: - if value.dtype == torch.float16: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - else: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - output = MultiScaleDeformableAttnFunction.apply( - value, spatial_shapes, level_start_index, sampling_locations, - attention_weights, self.im2col_step) - else: - output = multi_scale_deformable_attn_pytorch( - value, spatial_shapes, sampling_locations, attention_weights) - if not self.batch_first: - output = output.permute(1, 0, 2) - - return output diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/transformerV2.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/transformerV2.py deleted file mode 100644 index 41587ded45c618c454869ac1f8be1d4c6263ba5d..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/modules/transformerV2.py +++ /dev/null @@ -1,353 +0,0 @@ -import torch -import torch.nn as nn -from mmcv.cnn import xavier_init -from mmcv.cnn.bricks.transformer import build_transformer_layer_sequence -from mmdet.models.utils.builder import TRANSFORMER -from torch.nn.init import normal_ -from mmcv.runner.base_module import BaseModule -from .temporal_self_attention import TemporalSelfAttention -from .spatial_cross_attention import MSDeformableAttention3D -from .decoder import CustomMSDeformableAttention -from mmcv.cnn import build_norm_layer, build_conv_layer -import torch.utils.checkpoint as checkpoint -from mmdet.models.backbones.resnet import Bottleneck, BasicBlock - - -class ResNetFusion(BaseModule): - def __init__(self, in_channels, out_channels, inter_channels, num_layer, norm_cfg=dict(type='SyncBN'), - with_cp=False): - super(ResNetFusion, self).__init__() - layers = [] - self.inter_channels = inter_channels - for i in range(num_layer): - if i == 0: - if inter_channels == in_channels: - layers.append(BasicBlock(in_channels, inter_channels, stride=1, norm_cfg=norm_cfg)) - else: - downsample = nn.Sequential( - build_conv_layer(None, in_channels, inter_channels, 3, stride=1, padding=1, dilation=1, - bias=False), - build_norm_layer(norm_cfg, inter_channels)[1]) - layers.append( - BasicBlock(in_channels, inter_channels, stride=1, norm_cfg=norm_cfg, downsample=downsample)) - else: - layers.append(BasicBlock(inter_channels, inter_channels, stride=1, norm_cfg=norm_cfg)) - self.layers = nn.Sequential(*layers) - self.layer_norm = nn.Sequential( - nn.Linear(inter_channels, out_channels), - nn.LayerNorm(out_channels)) - self.with_cp = with_cp - - def forward(self, x): - x = torch.cat(x, 1).contiguous() - # x should be [1, in_channels, bev_h, bev_w] - for lid, layer in enumerate(self.layers): - if self.with_cp and x.requires_grad: - x = checkpoint.checkpoint(layer, x) - else: - x = layer(x) - x = x.reshape(x.shape[0], x.shape[1], -1).permute(0, 2, 1) # nchw -> n(hw)c - x = self.layer_norm(x) - return x - - -@TRANSFORMER.register_module() -class PerceptionTransformerBEVEncoder(BaseModule): - def __init__(self, - num_feature_levels=4, - num_cams=6, - two_stage_num_proposals=300, - encoder=None, - embed_dims=256, - use_cams_embeds=True, - rotate_center=[100, 100], - **kwargs): - super(PerceptionTransformerBEVEncoder, self).__init__(**kwargs) - self.encoder = build_transformer_layer_sequence(encoder) - self.embed_dims = embed_dims - self.num_feature_levels = num_feature_levels - self.num_cams = num_cams - self.fp16_enabled = False - - self.use_cams_embeds = use_cams_embeds - - self.two_stage_num_proposals = two_stage_num_proposals - self.rotate_center = rotate_center - """Initialize layers of the Detr3DTransformer.""" - self.level_embeds = nn.Parameter(torch.Tensor(self.num_feature_levels, self.embed_dims)) - if self.use_cams_embeds: - self.cams_embeds = nn.Parameter(torch.Tensor(self.num_cams, self.embed_dims)) - - def init_weights(self): - """Initialize the transformer weights.""" - for p in self.parameters(): - if p.dim() > 1: - nn.init.xavier_uniform_(p) - for m in self.modules(): - if isinstance(m, MSDeformableAttention3D) or isinstance(m, TemporalSelfAttention) \ - or isinstance(m, CustomMSDeformableAttention): - try: - m.init_weight() - except AttributeError: - m.init_weights() - normal_(self.level_embeds) - if self.use_cams_embeds: - normal_(self.cams_embeds) - - def forward(self, - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - prev_bev=None, - **kwargs): - """ - obtain bev features. - """ - bs = mlvl_feats[0].size(0) - bev_queries = bev_queries.unsqueeze(1).repeat(1, bs, 1) - bev_pos = bev_pos.flatten(2).permute(2, 0, 1) - - feat_flatten = [] - spatial_shapes = [] - for lvl, feat in enumerate(mlvl_feats): - bs, num_cam, c, h, w = feat.shape - spatial_shape = (h, w) - feat = feat.flatten(3).permute(1, 0, 3, 2) - if self.use_cams_embeds: - feat = feat + self.cams_embeds[:, None, None, :].to(feat.dtype) - feat = feat + self.level_embeds[None, None, lvl:lvl + 1, :].to(feat.dtype) - spatial_shapes.append(spatial_shape) - feat_flatten.append(feat) - - feat_flatten = torch.cat(feat_flatten, 2) - spatial_shapes = torch.as_tensor(spatial_shapes, dtype=torch.long, device=bev_pos.device) - level_start_index = torch.cat((spatial_shapes.new_zeros((1,)), spatial_shapes.prod(1).cumsum(0)[:-1])) - - feat_flatten = feat_flatten.permute(0, 2, 1, 3) # (num_cam, H*W, bs, embed_dims) - - bev_embed = self.encoder(bev_queries, - feat_flatten, - feat_flatten, - bev_h=bev_h, - bev_w=bev_w, - bev_pos=bev_pos, - spatial_shapes=spatial_shapes, - level_start_index=level_start_index, - prev_bev=None, - shift=bev_queries.new_tensor([0, 0]).unsqueeze(0), - **kwargs) - # rotate current bev to final aligned - prev_bev = bev_embed - if 'aug_param' in kwargs['img_metas'][0] and 'GlobalRotScaleTransImage_param' in kwargs['img_metas'][0][ - 'aug_param']: - rot_angle, scale_ratio, flip_dx, flip_dy, bda_mat, only_gt = kwargs['img_metas'][0]['aug_param'][ - 'GlobalRotScaleTransImage_param'] - prev_bev = prev_bev.reshape(bs, bev_h, bev_w, -1).permute(0, 3, 1, 2) # bchw - if only_gt: - # rot angle - # prev_bev = torchvision.transforms.functional.rotate(prev_bev, -30, InterpolationMode.BILINEAR) - ref_y, ref_x = torch.meshgrid( - torch.linspace(0.5, bev_h - 0.5, bev_h, dtype=bev_queries.dtype, device=bev_queries.device), - torch.linspace(0.5, bev_w - 0.5, bev_w, dtype=bev_queries.dtype, device=bev_queries.device)) - ref_y = (ref_y / bev_h) - ref_x = (ref_x / bev_w) - grid = torch.stack((ref_x, ref_y), -1) - grid_shift = grid * 2.0 - 1.0 - grid_shift = grid_shift.unsqueeze(0).unsqueeze(-1) - # bda_mat = ( bda_mat[:2, :2] / scale_ratio).to(grid_shift).view(1, 1, 1, 2,2).repeat(grid_shift.shape[0], grid_shift.shape[1], grid_shift.shape[2], 1, 1) - bda_mat = bda_mat[:2, :2].to(grid_shift).view(1, 1, 1, 2, 2).repeat(grid_shift.shape[0], - grid_shift.shape[1], - grid_shift.shape[2], 1, 1) - grid_shift = torch.matmul(bda_mat, grid_shift).squeeze(-1) - # grid_shift = grid_shift / scale_ratio - prev_bev = torch.nn.functional.grid_sample(prev_bev, grid_shift, align_corners=False) - # if flip_dx: - # prev_bev = torch.flip(prev_bev, dims=[-1]) - # if flip_dy: - # prev_bev = torch.flip(prev_bev, dims=[-2]) - prev_bev = prev_bev.reshape(bs, -1, bev_h * bev_w) - prev_bev = prev_bev.permute(0, 2, 1) - return prev_bev - - -@TRANSFORMER.register_module() -class PerceptionTransformerV2(PerceptionTransformerBEVEncoder): - """Implements the Detr3D transformer. - Args: - as_two_stage (bool): Generate query from encoder features. - Default: False. - num_feature_levels (int): Number of feature maps from FPN: - Default: 4. - two_stage_num_proposals (int): Number of proposals when set - `as_two_stage` as True. Default: 300. - """ - - def __init__(self, - num_feature_levels=4, - num_cams=6, - two_stage_num_proposals=300, - encoder=None, - embed_dims=256, - use_cams_embeds=True, - rotate_center=[100, 100], - frames=(0,), - decoder=None, - num_fusion=3, - inter_channels=None, - **kwargs): - super(PerceptionTransformerV2, self).__init__(num_feature_levels, num_cams, two_stage_num_proposals, encoder, - embed_dims, use_cams_embeds, rotate_center, - **kwargs) - self.decoder = build_transformer_layer_sequence(decoder) - """Initialize layers of the Detr3DTransformer.""" - self.reference_points = nn.Linear(self.embed_dims, 3) - self.frames = frames - if len(self.frames) > 1: - self.fusion = ResNetFusion(len(self.frames) * self.embed_dims, self.embed_dims, - inter_channels if inter_channels is not None else len( - self.frames) * self.embed_dims, - num_fusion) - - def init_weights(self): - """Initialize the transformer weights.""" - super().init_weights() - for p in self.parameters(): - if p.dim() > 1: - nn.init.xavier_uniform_(p) - for m in self.modules(): - if isinstance(m, MSDeformableAttention3D) or isinstance(m, TemporalSelfAttention) \ - or isinstance(m, CustomMSDeformableAttention): - try: - m.init_weight() - except AttributeError: - m.init_weights() - xavier_init(self.reference_points, distribution='uniform', bias=0.) - - def get_bev_features( - self, - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - prev_bev=None, - **kwargs): - return super().forward( - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length, - bev_pos, - prev_bev, - **kwargs - ) - - def forward(self, - mlvl_feats, - bev_queries, - object_query_embed, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - reg_branches=None, - cls_branches=None, - prev_bev=None, - **kwargs): - """Forward function for `Detr3DTransformer`. - Args: - mlvl_feats (list(Tensor)): Input queries from - different level. Each element has shape - [bs, num_cams, embed_dims, h, w]. - bev_queries (Tensor): (bev_h*bev_w, c) - bev_pos (Tensor): (bs, embed_dims, bev_h, bev_w) - object_query_embed (Tensor): The query embedding for decoder, - with shape [num_query, c]. - reg_branches (obj:`nn.ModuleList`): Regression heads for - feature maps from each decoder layer. Only would - be passed when `with_box_refine` is True. Default to None. - Returns: - tuple[Tensor]: results of decoder containing the following tensor. - - bev_embed: BEV features - - inter_states: Outputs from decoder. If - return_intermediate_dec is True output has shape \ - (num_dec_layers, bs, num_query, embed_dims), else has \ - shape (1, bs, num_query, embed_dims). - - init_reference_out: The initial value of reference \ - points, has shape (bs, num_queries, 4). - - inter_references_out: The internal value of reference \ - points in decoder, has shape \ - (num_dec_layers, bs,num_query, embed_dims) - - enc_outputs_class: The classification score of \ - proposals generated from \ - encoder's feature maps, has shape \ - (batch, h*w, num_classes). \ - Only would be returned when `as_two_stage` is True, \ - otherwise None. - - enc_outputs_coord_unact: The regression results \ - generated from encoder's feature maps., has shape \ - (batch, h*w, 4). Only would \ - be returned when `as_two_stage` is True, \ - otherwise None. - """ - bev_embed = self.get_bev_features( - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length=grid_length, - bev_pos=bev_pos, - prev_bev=None, - **kwargs) # bev_embed shape: bs, bev_h*bev_w, embed_dims - - if len(self.frames) > 1: - cur_ind = list(self.frames).index(0) - assert prev_bev[cur_ind] is None and len(prev_bev) == len(self.frames) - prev_bev[cur_ind] = bev_embed - - # fill prev frame feature - for i in range(1, cur_ind + 1): - if prev_bev[cur_ind - i] is None: - prev_bev[cur_ind - i] = prev_bev[cur_ind - i + 1].detach() - - # fill next frame feature - for i in range(cur_ind + 1, len(self.frames)): - if prev_bev[i] is None: - prev_bev[i] = prev_bev[i - 1].detach() - bev_embed = [x.reshape(x.shape[0], bev_h, bev_w, x.shape[-1]).permute(0, 3, 1, 2).contiguous() for x in - prev_bev] - bev_embed = self.fusion(bev_embed) - - bs = mlvl_feats[0].size(0) - query_pos, query = torch.split( - object_query_embed, self.embed_dims, dim=1) - query_pos = query_pos.unsqueeze(0).expand(bs, -1, -1) - query = query.unsqueeze(0).expand(bs, -1, -1) - reference_points = self.reference_points(query_pos) - reference_points = reference_points.sigmoid() - init_reference_out = reference_points - - query = query.permute(1, 0, 2) - query_pos = query_pos.permute(1, 0, 2) - bev_embed = bev_embed.permute(1, 0, 2) - - inter_states, inter_references = self.decoder( - query=query, - key=None, - value=bev_embed, - query_pos=query_pos, - reference_points=reference_points, - reg_branches=reg_branches, - cls_branches=cls_branches, - spatial_shapes=torch.tensor([[bev_h, bev_w]], device=query.device), - level_start_index=torch.tensor([0], device=query.device), - **kwargs) - - inter_references_out = inter_references - - return bev_embed, inter_states, init_reference_out, inter_references_out diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/__init__.py deleted file mode 100644 index 03f906ce601e2dfac207af680774086067808830..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .epoch_based_runner import EpochBasedRunner_video \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py deleted file mode 100644 index bd3fb34b0c9b1851a8bb3f8f40fddc642def981f..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import os.path as osp -import torch -import mmcv -from mmcv.runner.base_runner import BaseRunner -from mmcv.runner.epoch_based_runner import EpochBasedRunner -from mmcv.runner.builder import RUNNERS -from mmcv.runner.checkpoint import save_checkpoint -from mmcv.runner.utils import get_host_info -from pprint import pprint -from mmcv.parallel.data_container import DataContainer - - -@RUNNERS.register_module() -class EpochBasedRunner_video(EpochBasedRunner): - - ''' - # basic logic - - input_sequence = [a, b, c] # given a sequence of samples - - prev_bev = None - for each in input_sequcene[:-1] - prev_bev = eval_model(each, prev_bev)) # inference only. - - model(input_sequcene[-1], prev_bev) # train the last sample. - ''' - - def __init__(self, - model, - eval_model=None, - batch_processor=None, - optimizer=None, - work_dir=None, - logger=None, - meta=None, - keys=['gt_bboxes_3d', 'gt_labels_3d', 'img'], - max_iters=None, - max_epochs=None): - super().__init__(model, - batch_processor, - optimizer, - work_dir, - logger, - meta, - max_iters, - max_epochs) - keys.append('img_metas') - self.keys = keys - self.eval_model = eval_model - self.eval_model.eval() - - def run_iter(self, data_batch, train_mode, **kwargs): - if self.batch_processor is not None: - assert False - # outputs = self.batch_processor( - # self.model, data_batch, train_mode=train_mode, **kwargs) - elif train_mode: - - num_samples = data_batch['img'].data[0].size(1) - data_list = [] - prev_bev = None - for i in range(num_samples): - data = {} - for key in self.keys: - if key not in ['img_metas', 'img', 'points']: - data[key] = data_batch[key] - else: - if key == 'img': - data['img'] = DataContainer(data=[data_batch['img'].data[0][:, i]], cpu_only=data_batch['img'].cpu_only, stack=True) - elif key == 'img_metas': - data['img_metas'] = DataContainer(data=[[each[i] for each in data_batch['img_metas'].data[0]]], cpu_only=data_batch['img_metas'].cpu_only) - else: - assert False - data_list.append(data) - with torch.no_grad(): - for i in range(num_samples-1): - if data_list[i]['img_metas'].data[0][0]['prev_bev_exists']: - data_list[i]['prev_bev'] = DataContainer(data=[prev_bev], cpu_only=False) - prev_bev = self.eval_model.val_step(data_list[i], self.optimizer, **kwargs) - if data_list[-1]['img_metas'].data[0][0]['prev_bev_exists']: - data_list[-1]['prev_bev'] = DataContainer(data=[prev_bev], cpu_only=False) - outputs = self.model.train_step(data_list[-1], self.optimizer, **kwargs) - else: - assert False - # outputs = self.model.val_step(data_batch, self.optimizer, **kwargs) - - if not isinstance(outputs, dict): - raise TypeError('"batch_processor()" or "model.train_step()"' - 'and "model.val_step()" must return a dict') - if 'log_vars' in outputs: - self.log_buffer.update(outputs['log_vars'], outputs['num_samples']) - self.outputs = outputs \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py deleted file mode 100755 index 583fcab72f6b2bbf20bda90b8f877cc1f81072d9..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py +++ /dev/null @@ -1,136 +0,0 @@ -import torch - -from mmdet.core.bbox.builder import BBOX_ASSIGNERS -from mmdet.core.bbox.assigners import AssignResult -from mmdet.core.bbox.assigners import BaseAssigner -from mmdet.core.bbox.match_costs import build_match_cost -from mmdet.models.utils.transformer import inverse_sigmoid -from projects.mmdet3d_plugin.core.bbox.util import normalize_bbox - -try: - from scipy.optimize import linear_sum_assignment -except ImportError: - linear_sum_assignment = None - - -@BBOX_ASSIGNERS.register_module() -class HungarianAssigner3D(BaseAssigner): - """Computes one-to-one matching between predictions and ground truth. - This class computes an assignment between the targets and the predictions - based on the costs. The costs are weighted sum of three components: - classification cost, regression L1 cost and regression iou cost. The - targets don't include the no_object, so generally there are more - predictions than targets. After the one-to-one matching, the un-matched - are treated as backgrounds. Thus each query prediction will be assigned - with `0` or a positive integer indicating the ground truth index: - - 0: negative sample, no assigned gt - - positive integer: positive sample, index (1-based) of assigned gt - Args: - cls_weight (int | float, optional): The scale factor for classification - cost. Default 1.0. - bbox_weight (int | float, optional): The scale factor for regression - L1 cost. Default 1.0. - iou_weight (int | float, optional): The scale factor for regression - iou cost. Default 1.0. - iou_calculator (dict | optional): The config for the iou calculation. - Default type `BboxOverlaps2D`. - iou_mode (str | optional): "iou" (intersection over union), "iof" - (intersection over foreground), or "giou" (generalized - intersection over union). Default "giou". - """ - - def __init__(self, - cls_cost=dict(type='ClassificationCost', weight=1.), - reg_cost=dict(type='BBoxL1Cost', weight=1.0), - iou_cost=dict(type='IoUCost', weight=0.0), - pc_range=None): - self.cls_cost = build_match_cost(cls_cost) - self.reg_cost = build_match_cost(reg_cost) - self.iou_cost = build_match_cost(iou_cost) - self.pc_range = pc_range - - def assign(self, - bbox_pred, - cls_pred, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - eps=1e-7): - """Computes one-to-one matching based on the weighted costs. - This method assign each query prediction to a ground truth or - background. The `assigned_gt_inds` with -1 means don't care, - 0 means negative sample, and positive number is the index (1-based) - of assigned gt. - The assignment is done in the following steps, the order matters. - 1. assign every prediction to -1 - 2. compute the weighted costs - 3. do Hungarian matching on CPU based on the costs - 4. assign all to 0 (background) first, then for each matched pair - between predictions and gts, treat this prediction as foreground - and assign the corresponding gt index (plus 1) to it. - Args: - bbox_pred (Tensor): Predicted boxes with normalized coordinates - (cx, cy, w, h), which are all in range [0, 1]. Shape - [num_query, 4]. - cls_pred (Tensor): Predicted classification logits, shape - [num_query, num_class]. - gt_bboxes (Tensor): Ground truth boxes with unnormalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). - gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are - labelled as `ignored`. Default None. - eps (int | float, optional): A value added to the denominator for - numerical stability. Default 1e-7. - Returns: - :obj:`AssignResult`: The assigned result. - """ - assert gt_bboxes_ignore is None, \ - 'Only case when gt_bboxes_ignore is None is supported.' - num_gts, num_bboxes = gt_bboxes.size(0), bbox_pred.size(0) - - # 1. assign -1 by default - assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - assigned_labels = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - if num_gts == 0 or num_bboxes == 0: - # No ground truth or boxes, return empty assignment - if num_gts == 0: - # No ground truth, assign all to background - assigned_gt_inds[:] = 0 - return AssignResult( - num_gts, assigned_gt_inds, None, labels=assigned_labels) - - # 2. compute the weighted costs - # classification and bboxcost. - cls_cost = self.cls_cost(cls_pred, gt_labels) - # regression L1 cost - - normalized_gt_bboxes = normalize_bbox(gt_bboxes, self.pc_range) - - reg_cost = self.reg_cost(bbox_pred[:, :8], normalized_gt_bboxes[:, :8]) - - # weighted sum of above two costs - cost = cls_cost + reg_cost - - # 3. do Hungarian matching on CPU using linear_sum_assignment - cost = cost.detach().cpu() - if linear_sum_assignment is None: - raise ImportError('Please run "pip install scipy" ' - 'to install scipy first.') - matched_row_inds, matched_col_inds = linear_sum_assignment(cost) - matched_row_inds = torch.from_numpy(matched_row_inds).to( - bbox_pred.device) - matched_col_inds = torch.from_numpy(matched_col_inds).to( - bbox_pred.device) - - # 4. assign backgrounds and foregrounds - # assign all indices to backgrounds first - assigned_gt_inds[:] = 0 - # assign foregrounds based on matching results - assigned_gt_inds[matched_row_inds] = matched_col_inds + 1 - assigned_labels[matched_row_inds] = gt_labels[matched_col_inds] - return AssignResult( - num_gts, assigned_gt_inds, None, labels=assigned_labels) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py deleted file mode 100755 index 15321f5b2f376fa938588c4480cd12b77e0e864e..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py +++ /dev/null @@ -1,122 +0,0 @@ -import torch - -from mmdet.core.bbox import BaseBBoxCoder -from mmdet.core.bbox.builder import BBOX_CODERS -from projects.mmdet3d_plugin.core.bbox.util import denormalize_bbox -import numpy as np - - -@BBOX_CODERS.register_module() -class NMSFreeCoder(BaseBBoxCoder): - """Bbox coder for NMS-free detector. - Args: - pc_range (list[float]): Range of point cloud. - post_center_range (list[float]): Limit of the center. - Default: None. - max_num (int): Max number to be kept. Default: 100. - score_threshold (float): Threshold to filter boxes based on score. - Default: None. - code_size (int): Code size of bboxes. Default: 9 - """ - - def __init__(self, - pc_range, - voxel_size=None, - post_center_range=None, - max_num=100, - score_threshold=None, - num_classes=10): - self.pc_range = pc_range - self.voxel_size = voxel_size - self.post_center_range = post_center_range - self.max_num = max_num - self.score_threshold = score_threshold - self.num_classes = num_classes - - def encode(self): - - pass - - def decode_single(self, cls_scores, bbox_preds): - """Decode bboxes. - Args: - cls_scores (Tensor): Outputs from the classification head, \ - shape [num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - bbox_preds (Tensor): Outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [num_query, 9]. - Returns: - list[dict]: Decoded boxes. - """ - max_num = self.max_num - - cls_scores = cls_scores.sigmoid() - scores, indexs = cls_scores.view(-1).topk(max_num) - labels = indexs % self.num_classes - bbox_index = indexs // self.num_classes - bbox_preds = bbox_preds[bbox_index] - - final_box_preds = denormalize_bbox(bbox_preds, self.pc_range) - final_scores = scores - final_preds = labels - - # use score threshold - if self.score_threshold is not None: - thresh_mask = final_scores > self.score_threshold - tmp_score = self.score_threshold - while thresh_mask.sum() == 0: - tmp_score *= 0.9 - if tmp_score < 0.01: - thresh_mask = final_scores > -1 - break - thresh_mask = final_scores >= tmp_score - - if self.post_center_range is not None: - self.post_center_range = torch.tensor( - self.post_center_range, device=scores.device) - mask = (final_box_preds[..., :3] >= - self.post_center_range[:3]).all(1) - mask &= (final_box_preds[..., :3] <= - self.post_center_range[3:]).all(1) - - if self.score_threshold: - mask &= thresh_mask - - boxes3d = final_box_preds[mask] - scores = final_scores[mask] - - labels = final_preds[mask] - predictions_dict = { - 'bboxes': boxes3d, - 'scores': scores, - 'labels': labels - } - - else: - raise NotImplementedError( - 'Need to reorganize output as a batch, only ' - 'support post_center_range is not None for now!') - return predictions_dict - - def decode(self, preds_dicts): - """Decode bboxes. - Args: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - Returns: - list[dict]: Decoded boxes. - """ - all_cls_scores = preds_dicts['all_cls_scores'][-1] - all_bbox_preds = preds_dicts['all_bbox_preds'][-1] - - batch_size = all_cls_scores.size()[0] - predictions_list = [] - for i in range(batch_size): - predictions_list.append(self.decode_single(all_cls_scores[i], all_bbox_preds[i])) - return predictions_list - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py deleted file mode 100755 index b6e9baaf95fd406987b974fecc48f2a93ac50d25..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from mmdet.core.bbox.match_costs import build_match_cost -from .match_cost import BBox3DL1Cost, SmoothL1Cost - -__all__ = ['build_match_cost', 'BBox3DL1Cost', 'SmoothL1Cost'] \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py deleted file mode 100755 index 57f732fd45bc5df06d59c96709100ccc90803393..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py +++ /dev/null @@ -1,90 +0,0 @@ -import torch -import mmcv -from mmdet.core.bbox.match_costs.builder import MATCH_COST - - -@MATCH_COST.register_module() -class BBox3DL1Cost(object): - """BBox3DL1Cost. - Args: - weight (int | float, optional): loss_weight - """ - - def __init__(self, weight=1.): - self.weight = weight - - def __call__(self, bbox_pred, gt_bboxes): - """ - Args: - bbox_pred (Tensor): Predicted boxes with normalized coordinates - (cx, cy, w, h), which are all in range [0, 1]. Shape - [num_query, 4]. - gt_bboxes (Tensor): Ground truth boxes with normalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - Returns: - torch.Tensor: bbox_cost value with weight - """ - bbox_cost = torch.cdist(bbox_pred, gt_bboxes, p=1) - return bbox_cost * self.weight - -@mmcv.jit(derivate=True, coderize=True) -#@weighted_loss -def smooth_l1_loss(pred, target, beta=1.0): - """Smooth L1 loss. - Args: - pred (torch.Tensor): The prediction. - target (torch.Tensor): The learning target of the prediction. - beta (float, optional): The threshold in the piecewise function. - Defaults to 1.0. - Returns: - torch.Tensor: Calculated loss - """ - assert beta > 0 - if target.numel() == 0: - return pred.sum() * 0 - - # assert pred.size() == target.size() - diff = torch.abs(pred - target) - loss = torch.where(diff < beta, 0.5 * diff * diff / beta, - diff - 0.5 * beta) - return loss.sum(-1) - - -@MATCH_COST.register_module() -class SmoothL1Cost(object): - """SmoothL1Cost. - Args: - weight (int | float, optional): loss weight - - Examples: - >>> from mmdet.core.bbox.match_costs.match_cost import IoUCost - >>> import torch - >>> self = IoUCost() - >>> bboxes = torch.FloatTensor([[1,1, 2, 2], [2, 2, 3, 4]]) - >>> gt_bboxes = torch.FloatTensor([[0, 0, 2, 4], [1, 2, 3, 4]]) - >>> self(bboxes, gt_bboxes) - tensor([[-0.1250, 0.1667], - [ 0.1667, -0.5000]]) - """ - - def __init__(self, weight=1.): - self.weight = weight - - def __call__(self, input, target): - """ - Args: - bboxes (Tensor): Predicted boxes with unnormalized coordinates - (x1, y1, x2, y2). Shape [num_query, 4]. - gt_bboxes (Tensor): Ground truth boxes with unnormalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - - Returns: - torch.Tensor: iou_cost value with weight - """ - N1, C = input.shape - N2, C = target.shape - input = input.contiguous().view(N1, C)[:, None, :] - target = target.contiguous().view(N2, C)[None, :, :] - cost = smooth_l1_loss(input, target) - - return cost * self.weight \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/util.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/util.py deleted file mode 100755 index c54bd750246f3d6e2249b7d39888fffa6227beda..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/bbox/util.py +++ /dev/null @@ -1,53 +0,0 @@ -import torch - - -def normalize_bbox(bboxes, pc_range): - - cx = bboxes[..., 0:1] - cy = bboxes[..., 1:2] - cz = bboxes[..., 2:3] - w = bboxes[..., 3:4].log() - l = bboxes[..., 4:5].log() - h = bboxes[..., 5:6].log() - - rot = bboxes[..., 6:7] - if bboxes.size(-1) > 7: - vx = bboxes[..., 7:8] - vy = bboxes[..., 8:9] - normalized_bboxes = torch.cat( - (cx, cy, w, l, cz, h, rot.sin(), rot.cos(), vx, vy), dim=-1 - ) - else: - normalized_bboxes = torch.cat( - (cx, cy, w, l, cz, h, rot.sin(), rot.cos()), dim=-1 - ) - return normalized_bboxes - -def denormalize_bbox(normalized_bboxes, pc_range): - # rotation - rot_sine = normalized_bboxes[..., 6:7] - - rot_cosine = normalized_bboxes[..., 7:8] - rot = torch.atan2(rot_sine, rot_cosine) - - # center in the bev - cx = normalized_bboxes[..., 0:1] - cy = normalized_bboxes[..., 1:2] - cz = normalized_bboxes[..., 4:5] - - # size - w = normalized_bboxes[..., 2:3] - l = normalized_bboxes[..., 3:4] - h = normalized_bboxes[..., 5:6] - - w = w.exp() - l = l.exp() - h = h.exp() - if normalized_bboxes.size(-1) > 8: - # velocity - vx = normalized_bboxes[:, 8:9] - vy = normalized_bboxes[:, 9:10] - denormalized_bboxes = torch.cat([cx, cy, cz, w, l, h, rot, vx, vy], dim=-1) - else: - denormalized_bboxes = torch.cat([cx, cy, cz, w, l, h, rot], dim=-1) - return denormalized_bboxes \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/__init__.py deleted file mode 100644 index d92421c7e84fdc7a33e94aa10fddfccb332d6399..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .eval_hooks import CustomDistEvalHook \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py deleted file mode 100644 index 0477213bd3fe5874c7fe8c7c4fe2d861165e2d58..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py +++ /dev/null @@ -1,91 +0,0 @@ - -# Note: Considering that MMCV's EvalHook updated its interface in V1.3.16, -# in order to avoid strong version dependency, we did not directly -# inherit EvalHook but BaseDistEvalHook. - -import bisect -import os.path as osp - -import mmcv -import torch.distributed as dist -from mmcv.runner import DistEvalHook as BaseDistEvalHook -from mmcv.runner import EvalHook as BaseEvalHook -from torch.nn.modules.batchnorm import _BatchNorm -from mmdet.core.evaluation.eval_hooks import DistEvalHook - - -def _calc_dynamic_intervals(start_interval, dynamic_interval_list): - assert mmcv.is_list_of(dynamic_interval_list, tuple) - - dynamic_milestones = [0] - dynamic_milestones.extend( - [dynamic_interval[0] for dynamic_interval in dynamic_interval_list]) - dynamic_intervals = [start_interval] - dynamic_intervals.extend( - [dynamic_interval[1] for dynamic_interval in dynamic_interval_list]) - return dynamic_milestones, dynamic_intervals - - -class CustomDistEvalHook(BaseDistEvalHook): - - def __init__(self, *args, dynamic_intervals=None, **kwargs): - super(CustomDistEvalHook, self).__init__(*args, **kwargs) - self.use_dynamic_intervals = dynamic_intervals is not None - if self.use_dynamic_intervals: - self.dynamic_milestones, self.dynamic_intervals = \ - _calc_dynamic_intervals(self.interval, dynamic_intervals) - - def _decide_interval(self, runner): - if self.use_dynamic_intervals: - progress = runner.epoch if self.by_epoch else runner.iter - step = bisect.bisect(self.dynamic_milestones, (progress + 1)) - # Dynamically modify the evaluation interval - self.interval = self.dynamic_intervals[step - 1] - - def before_train_epoch(self, runner): - """Evaluate the model only at the start of training by epoch.""" - self._decide_interval(runner) - super().before_train_epoch(runner) - - def before_train_iter(self, runner): - self._decide_interval(runner) - super().before_train_iter(runner) - - def _do_evaluate(self, runner): - """perform evaluation and save ckpt.""" - # Synchronization of BatchNorm's buffer (running_mean - # and running_var) is not supported in the DDP of pytorch, - # which may cause the inconsistent performance of models in - # different ranks, so we broadcast BatchNorm's buffers - # of rank 0 to other ranks to avoid this. - if self.broadcast_bn_buffer: - model = runner.model - for name, module in model.named_modules(): - if isinstance(module, - _BatchNorm) and module.track_running_stats: - dist.broadcast(module.running_var, 0) - dist.broadcast(module.running_mean, 0) - - if not self._should_evaluate(runner): - return - - tmpdir = self.tmpdir - if tmpdir is None: - tmpdir = osp.join(runner.work_dir, '.eval_hook') - - from projects.mmdet3d_plugin.bevformer.apis.test import custom_multi_gpu_test # to solve circlur import - - results = custom_multi_gpu_test( - runner.model, - self.dataloader, - tmpdir=tmpdir, - gpu_collect=self.gpu_collect) - if runner.rank == 0: - print('\n') - runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) - - key_score = self.evaluate(runner, results) - - if self.save_best: - self._save_ckpt(runner, key_score) - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py deleted file mode 100644 index f816974544b57c1561a1fc09b9cf9e48dde03e38..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py +++ /dev/null @@ -1,251 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -r"""Adapted from `Waymo to KITTI converter - `_. -""" - -try: - from waymo_open_dataset import dataset_pb2 as open_dataset - import mmcv - import numpy as np - import tensorflow as tf - from glob import glob - from os.path import join - from waymo_open_dataset import label_pb2 - from waymo_open_dataset.protos import metrics_pb2 -except ImportError: - #pass - raise ImportError( - 'Please run "pip install waymo-open-dataset-tf-2-1-0==1.2.0" ' - 'to install the official devkit first.') - - - - -class KITTI2Waymo(object): - """KITTI predictions to Waymo converter. - This class serves as the converter to change predictions from KITTI to - Waymo format. - Args: - kitti_result_files (list[dict]): Predictions in KITTI format. - waymo_tfrecords_dir (str): Directory to load waymo raw data. - waymo_results_save_dir (str): Directory to save converted predictions - in waymo format (.bin files). - waymo_results_final_path (str): Path to save combined - predictions in waymo format (.bin file), like 'a/b/c.bin'. - prefix (str): Prefix of filename. In general, 0 for training, 1 for - validation and 2 for testing. - workers (str): Number of parallel processes. - """ - - def __init__(self, - kitti_result_files, - waymo_tfrecords_dir, - waymo_results_save_dir, - waymo_results_final_path, - prefix, - workers=64): - - self.kitti_result_files = kitti_result_files - self.waymo_tfrecords_dir = waymo_tfrecords_dir - self.waymo_results_save_dir = waymo_results_save_dir - self.waymo_results_final_path = waymo_results_final_path - self.prefix = prefix - self.workers = int(workers) - self.name2idx = {} - for idx, result in enumerate(kitti_result_files): - if len(result['sample_idx']) > 0: - self.name2idx[str(result['sample_idx'][0])] = idx - - # turn on eager execution for older tensorflow versions - if int(tf.__version__.split('.')[0]) < 2: - tf.enable_eager_execution() - - self.k2w_cls_map = { - 'Car': label_pb2.Label.TYPE_VEHICLE, - 'Pedestrian': label_pb2.Label.TYPE_PEDESTRIAN, - 'Sign': label_pb2.Label.TYPE_SIGN, - 'Cyclist': label_pb2.Label.TYPE_CYCLIST, - } - - self.T_ref_to_front_cam = np.array([[0.0, 0.0, 1.0, 0.0], - [-1.0, 0.0, 0.0, 0.0], - [0.0, -1.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 1.0]]) - - self.get_file_names() - self.create_folder() - - def get_file_names(self): - """Get file names of waymo raw data.""" - self.waymo_tfrecord_pathnames = sorted( - glob(join(self.waymo_tfrecords_dir, '*.tfrecord'))) - print(len(self.waymo_tfrecord_pathnames), 'tfrecords found.') - - def create_folder(self): - """Create folder for data conversion.""" - mmcv.mkdir_or_exist(self.waymo_results_save_dir) - - def parse_objects(self, kitti_result, T_k2w, context_name, - frame_timestamp_micros): - """Parse one prediction with several instances in kitti format and - convert them to `Object` proto. - Args: - kitti_result (dict): Predictions in kitti format. - - name (np.ndarray): Class labels of predictions. - - dimensions (np.ndarray): Height, width, length of boxes. - - location (np.ndarray): Bottom center of boxes (x, y, z). - - rotation_y (np.ndarray): Orientation of boxes. - - score (np.ndarray): Scores of predictions. - T_k2w (np.ndarray): Transformation matrix from kitti to waymo. - context_name (str): Context name of the frame. - frame_timestamp_micros (int): Frame timestamp. - Returns: - :obj:`Object`: Predictions in waymo dataset Object proto. - """ - - def parse_one_object(instance_idx): - """Parse one instance in kitti format and convert them to `Object` - proto. - Args: - instance_idx (int): Index of the instance to be converted. - Returns: - :obj:`Object`: Predicted instance in waymo dataset \ - Object proto. - """ - cls = kitti_result['name'][instance_idx] - length = round(kitti_result['dimensions'][instance_idx, 0], 4) - height = round(kitti_result['dimensions'][instance_idx, 1], 4) - width = round(kitti_result['dimensions'][instance_idx, 2], 4) - x = round(kitti_result['location'][instance_idx, 0], 4) - y = round(kitti_result['location'][instance_idx, 1], 4) - z = round(kitti_result['location'][instance_idx, 2], 4) - rotation_y = round(kitti_result['rotation_y'][instance_idx], 4) - score = round(kitti_result['score'][instance_idx], 4) - - # y: downwards; move box origin from bottom center (kitti) to - # true center (waymo) - y -= height / 2 - # frame transformation: kitti -> waymo - x, y, z = self.transform(T_k2w, x, y, z) - - # different conventions - heading = -(rotation_y + np.pi / 2) - while heading < -np.pi: - heading += 2 * np.pi - while heading > np.pi: - heading -= 2 * np.pi - - box = label_pb2.Label.Box() - box.center_x = x - box.center_y = y - box.center_z = z - box.length = length - box.width = width - box.height = height - box.heading = heading - - o = metrics_pb2.Object() - o.object.box.CopyFrom(box) - o.object.type = self.k2w_cls_map[cls] - o.score = score - - o.context_name = context_name - o.frame_timestamp_micros = frame_timestamp_micros - - return o - - objects = metrics_pb2.Objects() - - for instance_idx in range(len(kitti_result['name'])): - o = parse_one_object(instance_idx) - objects.objects.append(o) - - return objects - - def convert_one(self, file_idx): - """Convert action for single file. - Args: - file_idx (int): Index of the file to be converted. - """ - file_pathname = self.waymo_tfrecord_pathnames[file_idx] - file_data = tf.data.TFRecordDataset(file_pathname, compression_type='') - - for frame_num, frame_data in enumerate(file_data): - frame = open_dataset.Frame() - frame.ParseFromString(bytearray(frame_data.numpy())) - filename = f'{self.prefix}{file_idx:03d}{frame_num:03d}' - - for camera in frame.context.camera_calibrations: - # FRONT = 1, see dataset.proto for details - if camera.name == 1: - T_front_cam_to_vehicle = np.array( - camera.extrinsic.transform).reshape(4, 4) - - T_k2w = T_front_cam_to_vehicle @ self.T_ref_to_front_cam - - context_name = frame.context.name - frame_timestamp_micros = frame.timestamp_micros - - if filename in self.name2idx: - kitti_result = \ - self.kitti_result_files[self.name2idx[filename]] - objects = self.parse_objects(kitti_result, T_k2w, context_name, - frame_timestamp_micros) - else: - print(filename, 'not found.(bevformer)') - objects = metrics_pb2.Objects() - - with open( - join(self.waymo_results_save_dir, f'{filename}.bin'), - 'wb') as f: - f.write(objects.SerializeToString()) - - def convert(self): - """Convert action.""" - print('Start converting ...') - mmcv.track_parallel_progress(self.convert_one, range(len(self)), - self.workers) - print('\nFinished ...') - - # combine all files into one .bin - pathnames = sorted(glob(join(self.waymo_results_save_dir, '*.bin'))) - combined = self.combine(pathnames) - - with open(self.waymo_results_final_path, 'wb') as f: - f.write(combined.SerializeToString()) - - def __len__(self): - """Length of the filename list.""" - return len(self.waymo_tfrecord_pathnames) - - def transform(self, T, x, y, z): - """Transform the coordinates with matrix T. - Args: - T (np.ndarray): Transformation matrix. - x(float): Coordinate in x axis. - y(float): Coordinate in y axis. - z(float): Coordinate in z axis. - Returns: - list: Coordinates after transformation. - """ - pt_bef = np.array([x, y, z, 1.0]).reshape(4, 1) - pt_aft = np.matmul(T, pt_bef) - return pt_aft[:3].flatten().tolist() - - def combine(self, pathnames): - """Combine predictions in waymo format for each sample together. - Args: - pathnames (str): Paths to save predictions. - Returns: - :obj:`Objects`: Combined predictions in Objects proto. - """ - combined = metrics_pb2.Objects() - - for pathname in pathnames: - objects = metrics_pb2.Objects() - with open(pathname, 'rb') as f: - objects.ParseFromString(f.read()) - for o in objects.objects: - combined.objects.append(o) - - return combined \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py deleted file mode 100644 index 404482fde764616d7118507304c738a3a9edc4b9..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py +++ /dev/null @@ -1,240 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - - -@DATASETS.register_module() -class CustomNuScenesDataset(NuScenesDataset): - r"""NuScenes Dataset. - - This datset only add camera intrinsics and extrinsics to the results. - """ - - def __init__(self, queue_length=4, bev_size=(200, 200), overlap_test=False, *args, **kwargs): - super().__init__(*args, **kwargs) - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - queue = [] - index_list = list(range(index-self.queue_length, index)) - random.shuffle(index_list) - index_list = sorted(index_list[1:]) - index_list.append(index) - for i in index_list: - i = max(0, i) - input_dict = self.get_data_info(i) - if input_dict is None: - return None - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - queue.append(example) - return self.union2one(queue) - - - def union2one(self, queue): - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_scene_token = None - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if metas_map[i]['scene_token'] != prev_scene_token: - metas_map[i]['prev_bev_exists'] = False - prev_scene_token = metas_map[i]['scene_token'] - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - else: - metas_map[i]['prev_bev_exists'] = True - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - queue[-1]['img'] = DC(torch.stack(imgs_list), cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - sample_idx=info['token'], - pts_filename=info['lidar_path'], - sweeps=info['sweeps'], - ego2global_translation=info['ego2global_translation'], - ego2global_rotation=info['ego2global_rotation'], - prev_idx=info['prev'], - next_idx=info['next'], - scene_token=info['scene_token'], - can_bus=info['can_bus'], - frame_idx=info['frame_idx'], - timestamp=info['timestamp'] / 1e6, - ) - - if self.modality['use_camera']: - image_paths = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_intrinsics = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['data_path']) - # obtain lidar to image transformation matrix - lidar2cam_r = np.linalg.inv(cam_info['sensor2lidar_rotation']) - lidar2cam_t = cam_info[ - 'sensor2lidar_translation'] @ lidar2cam_r.T - lidar2cam_rt = np.eye(4) - lidar2cam_rt[:3, :3] = lidar2cam_r.T - lidar2cam_rt[3, :3] = -lidar2cam_t - intrinsic = cam_info['cam_intrinsic'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt.T) - lidar2img_rts.append(lidar2img_rt) - - cam_intrinsics.append(viewpad) - lidar2cam_rts.append(lidar2cam_rt.T) - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam_intrinsic=cam_intrinsics, - lidar2cam=lidar2cam_rts, - )) - - if not self.test_mode: - annos = self.get_ann_info(index) - input_dict['ann_info'] = annos - - rotation = Quaternion(input_dict['ego2global_rotation']) - translation = input_dict['ego2global_translation'] - can_bus = input_dict['can_bus'] - can_bus[:3] = translation - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - - return input_dict - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - - def _evaluate_single(self, - result_path, - logger=None, - metric='bbox', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from nuscenes import NuScenes - self.nusc = NuScenes(version=self.version, dataroot=self.data_root, - verbose=True) - - output_dir = osp.join(*osp.split(result_path)[:-1]) - - eval_set_map = { - 'v1.0-mini': 'mini_val', - 'v1.0-trainval': 'val', - } - self.nusc_eval = NuScenesEval_custom( - self.nusc, - config=self.eval_detection_configs, - result_path=result_path, - eval_set=eval_set_map[self.version], - output_dir=output_dir, - verbose=True, - overlap_test=self.overlap_test, - data_infos=self.data_infos - ) - self.nusc_eval.main(plot_examples=0, render_curves=False) - # record metrics - metrics = mmcv.load(osp.join(output_dir, 'metrics_summary.json')) - detail = dict() - metric_prefix = f'{result_name}_NuScenes' - for name in self.CLASSES: - for k, v in metrics['label_aps'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_AP_dist_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['label_tp_errors'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['tp_errors'].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}'.format(metric_prefix, - self.ErrNameMapping[k])] = val - detail['{}/NDS'.format(metric_prefix)] = metrics['nd_score'] - detail['{}/mAP'.format(metric_prefix)] = metrics['mean_ap'] - return detail diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset_v2.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset_v2.py deleted file mode 100644 index 0886c1f7830865944de3fbe16fafc0e522e9afb9..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_dataset_v2.py +++ /dev/null @@ -1,303 +0,0 @@ -import copy -from mmdet3d.datasets import NuScenesDataset -import mmcv -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from mmcv.parallel import DataContainer as DC -from collections import defaultdict, OrderedDict -from projects.mmdet3d_plugin.dd3d.datasets.nuscenes import NuscenesDataset as DD3DNuscenesDataset - - -@DATASETS.register_module() -class CustomNuScenesDatasetV2(NuScenesDataset): - def __init__(self, frames=(),mono_cfg=None, overlap_test=False,*args, **kwargs): - super().__init__(*args, **kwargs) - self.frames = frames - self.queue_length = len(frames) - self.overlap_test = overlap_test - self.mono_cfg = mono_cfg - if not self.test_mode and mono_cfg is not None: - self.mono_dataset = DD3DNuscenesDataset(**mono_cfg) - - def prepare_test_data(self, index): - """Prepare data for testing. - - Args: - index (int): Index for accessing the target data. - - Returns: - dict: Testing data dict of the corresponding index. - """ - data_queue = OrderedDict() - input_dict = self.get_data_info(index) - cur_scene_token = input_dict['scene_token'] - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - data_queue[0] = example - - for frame_idx in self.frames: - chosen_idx = index + frame_idx - if frame_idx ==0 or chosen_idx <0 or chosen_idx >= len(self.data_infos): - continue - info = self.data_infos[chosen_idx] - input_dict = self.prepare_input_dict(info) - if input_dict['scene_token'] == cur_scene_token: - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - data_queue[frame_idx] = example - - data_queue = OrderedDict(sorted(data_queue.items())) - ret = defaultdict(list) - for i in range(len(data_queue[0]['img'])): - single_aug_data_queue = {} - for t in data_queue.keys(): - single_example = {} - for key ,value in data_queue[t].items(): - single_example[key] = value[i] - single_aug_data_queue[t] = single_example - single_aug_data_queue = OrderedDict(sorted(single_aug_data_queue.items())) - single_aug_sample = self.union2one(single_aug_data_queue) - - for key, value in single_aug_sample.items(): - ret[key].append(value) - return ret - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = OrderedDict() - input_dict = self.get_data_info(index) - if input_dict is None: - return None - cur_scene_token = input_dict['scene_token'] - # cur_frame_idx = input_dict['frame_idx'] - ann_info = copy.deepcopy(input_dict['ann_info']) - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - data_queue[0] = example - aug_param = copy.deepcopy(example['aug_param']) if 'aug_param' in example else {} - - # frame_idx_to_idx = self.scene_to_frame_idx_to_idx[cur_scene_token] - for frame_idx in self.frames: - chosen_idx = index + frame_idx - if frame_idx ==0 or chosen_idx <0 or chosen_idx >= len(self.data_infos): - continue - info = self.data_infos[chosen_idx] - input_dict = self.prepare_input_dict(info) - if input_dict['scene_token'] == cur_scene_token: - input_dict['ann_info'] = copy.deepcopy(ann_info) # only for pipeline, should never be used - self.pre_pipeline(input_dict) - input_dict['aug_param'] = copy.deepcopy(aug_param) - example = self.pipeline(input_dict) - data_queue[frame_idx] = example - - data_queue = OrderedDict(sorted(data_queue.items())) - return self.union2one(data_queue) - - def union2one(self, queue: dict): - """ - convert sample queue into one single sample. - """ - imgs_list = [each['img'].data for each in queue.values()] - lidar2ego = np.eye(4, dtype=np.float32) - lidar2ego[:3, :3] = Quaternion(queue[0]['lidar2ego_rotation']).rotation_matrix - lidar2ego[:3, 3] = queue[0]['lidar2ego_translation'] - - egocurr2global = np.eye(4, dtype=np.float32) - egocurr2global[:3,:3] = Quaternion(queue[0]['ego2global_rotation']).rotation_matrix - egocurr2global[:3,3] = queue[0]['ego2global_translation'] - metas_map = {} - for i, each in queue.items(): - metas_map[i] = each['img_metas'].data - metas_map[i]['timestamp'] = each['timestamp'] - if 'aug_param' in each: - metas_map[i]['aug_param'] = each['aug_param'] - if i == 0: - metas_map[i]['lidaradj2lidarcurr'] = None - else: - egoadj2global = np.eye(4, dtype=np.float32) - egoadj2global[:3,:3] = Quaternion(each['ego2global_rotation']).rotation_matrix - egoadj2global[:3,3] = each['ego2global_translation'] - - lidaradj2lidarcurr = np.linalg.inv(lidar2ego) @ np.linalg.inv(egocurr2global) @ egoadj2global @ lidar2ego - metas_map[i]['lidaradj2lidarcurr'] = lidaradj2lidarcurr - for i_cam in range(len(metas_map[i]['lidar2img'])): - metas_map[i]['lidar2img'][i_cam] = metas_map[i]['lidar2img'][i_cam] @ np.linalg.inv(lidaradj2lidarcurr) - queue[0]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[0]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[0] - return queue - - def prepare_input_dict(self, info): - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - sample_idx=info['token'], - pts_filename=info['lidar_path'], - sweeps=info['sweeps'], - ego2global_translation=info['ego2global_translation'], - ego2global_rotation=info['ego2global_rotation'], - lidar2ego_translation=info['lidar2ego_translation'], - lidar2ego_rotation=info['lidar2ego_rotation'], - prev=info['prev'], - next=info['next'], - scene_token=info['scene_token'], - frame_idx=info['frame_idx'], - timestamp=info['timestamp'] / 1e6, - ) - - if self.modality['use_camera']: - image_paths = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_intrinsics = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['data_path']) - # obtain lidar to image transformation matrix - lidar2cam_r = np.linalg.inv(cam_info['sensor2lidar_rotation']) - lidar2cam_t = cam_info[ - 'sensor2lidar_translation'] @ lidar2cam_r.T - lidar2cam_rt = np.eye(4) - lidar2cam_rt[:3, :3] = lidar2cam_r.T - lidar2cam_rt[3, :3] = -lidar2cam_t - intrinsic = cam_info['cam_intrinsic'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt.T) - lidar2img_rts.append(lidar2img_rt) - - cam_intrinsics.append(viewpad) - lidar2cam_rts.append(lidar2cam_rt.T) - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam2img=cam_intrinsics, - lidar2cam=lidar2cam_rts, - )) - - return input_dict - - def filter_crowd_annotations(self, data_dict): - for ann in data_dict["annotations"]: - if ann.get("iscrowd", 0) == 0: - return True - return False - - def get_data_info(self, index): - info = self.data_infos[index] - input_dict = self.prepare_input_dict(info) - if not self.test_mode: - annos = self.get_ann_info(index) - input_dict['ann_info'] = annos - - if not self.test_mode and self.mono_cfg is not None: - if input_dict is None: - return None - info = self.data_infos[index] - img_ids = [] - for cam_type, cam_info in info['cams'].items(): - img_ids.append(cam_info['sample_data_token']) - - mono_input_dict = []; mono_ann_index = [] - for i, img_id in enumerate(img_ids): - tmp_dict = self.mono_dataset.getitem_by_datumtoken(img_id) - if tmp_dict is not None: - if self.filter_crowd_annotations(tmp_dict): - mono_input_dict.append(tmp_dict) - mono_ann_index.append(i) - - # filter empth annotation - if len(mono_ann_index) == 0: - return None - - mono_ann_index = DC(mono_ann_index, cpu_only=True) - input_dict['mono_input_dict'] = mono_input_dict - input_dict['mono_ann_idx'] = mono_ann_index - return input_dict - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - - def _evaluate_single(self, - result_path, - logger=None, - metric='bbox', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from nuscenes import NuScenes - self.nusc = NuScenes(version=self.version, dataroot=self.data_root, - verbose=True) - - output_dir = osp.join(*osp.split(result_path)[:-1]) - - eval_set_map = { - 'v1.0-mini': 'mini_val', - 'v1.0-trainval': 'val', - } - self.nusc_eval = NuScenesEval_custom( - self.nusc, - config=self.eval_detection_configs, - result_path=result_path, - eval_set=eval_set_map[self.version], - output_dir=output_dir, - verbose=True, - overlap_test=self.overlap_test, - data_infos=self.data_infos - ) - self.nusc_eval.main(plot_examples=0, render_curves=False) - # record metrics - metrics = mmcv.load(osp.join(output_dir, 'metrics_summary.json')) - detail = dict() - metric_prefix = f'{result_name}_NuScenes' - for name in self.CLASSES: - for k, v in metrics['label_aps'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_AP_dist_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['label_tp_errors'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['tp_errors'].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}'.format(metric_prefix, - self.ErrNameMapping[k])] = val - detail['{}/NDS'.format(metric_prefix)] = metrics['nd_score'] - detail['{}/mAP'.format(metric_prefix)] = metrics['mean_ap'] - return detail \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py deleted file mode 100644 index b036b87b8b89e2e31ac06f4917b89f8f7682f426..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py +++ /dev/null @@ -1,777 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import copy -import mmcv -import numpy as np -import pyquaternion -import tempfile -import torch -import warnings -from nuscenes.utils.data_classes import Box as NuScenesBox -from os import path as osp - -from mmdet3d.core import bbox3d2result, box3d_multiclass_nms, xywhr2xyxyr -from mmdet.datasets import DATASETS, CocoDataset -from mmdet3d.core import show_multi_modality_result -from mmdet3d.core.bbox import CameraInstance3DBoxes, get_box_type -from mmdet3d.datasets.pipelines import Compose -from mmdet3d.datasets.utils import extract_result_dict, get_loading_pipeline - - -@DATASETS.register_module() -class CustomNuScenesMonoDataset(CocoDataset): - r"""Monocular 3D detection on NuScenes Dataset. - This class serves as the API for experiments on the NuScenes Dataset. - Please refer to `NuScenes Dataset `_ - for data downloading. - Args: - ann_file (str): Path of annotation file. - data_root (str): Path of dataset root. - load_interval (int, optional): Interval of loading the dataset. It is - used to uniformly sample the dataset. Defaults to 1. - with_velocity (bool, optional): Whether include velocity prediction - into the experiments. Defaults to True. - modality (dict, optional): Modality to specify the sensor data used - as input. Defaults to None. - box_type_3d (str, optional): Type of 3D box of this dataset. - Based on the `box_type_3d`, the dataset will encapsulate the box - to its original format then converted them to `box_type_3d`. - Defaults to 'Camera' in this class. Available options includes. - - 'LiDAR': Box in LiDAR coordinates. - - 'Depth': Box in depth coordinates, usually for indoor dataset. - - 'Camera': Box in camera coordinates. - eval_version (str, optional): Configuration version of evaluation. - Defaults to 'detection_cvpr_2019'. - use_valid_flag (bool): Whether to use `use_valid_flag` key in the info - file as mask to filter gt_boxes and gt_names. Defaults to False. - version (str, optional): Dataset version. Defaults to 'v1.0-trainval'. - """ - CLASSES = ('car', 'truck', 'trailer', 'bus', 'construction_vehicle', - 'bicycle', 'motorcycle', 'pedestrian', 'traffic_cone', - 'barrier') - DefaultAttribute = { - 'car': 'vehicle.parked', - 'pedestrian': 'pedestrian.moving', - 'trailer': 'vehicle.parked', - 'truck': 'vehicle.parked', - 'bus': 'vehicle.moving', - 'motorcycle': 'cycle.without_rider', - 'construction_vehicle': 'vehicle.parked', - 'bicycle': 'cycle.without_rider', - 'barrier': '', - 'traffic_cone': '', - } - # https://github.com/nutonomy/nuscenes-devkit/blob/57889ff20678577025326cfc24e57424a829be0a/python-sdk/nuscenes/eval/detection/evaluate.py#L222 # noqa - ErrNameMapping = { - 'trans_err': 'mATE', - 'scale_err': 'mASE', - 'orient_err': 'mAOE', - 'vel_err': 'mAVE', - 'attr_err': 'mAAE' - } - - def __init__(self, - data_root, - load_interval=1, - with_velocity=True, - modality=None, - box_type_3d='Camera', - eval_version='detection_cvpr_2019', - use_valid_flag=False, - overlap_test=False, - version='v1.0-trainval', - **kwargs): - super().__init__(**kwargs) - # overlap_test = True - self.data_root = data_root - self.overlap_test = overlap_test - self.load_interval = load_interval - self.with_velocity = with_velocity - self.modality = modality - self.box_type_3d, self.box_mode_3d = get_box_type(box_type_3d) - self.eval_version = eval_version - self.use_valid_flag = use_valid_flag - self.bbox_code_size = 9 - self.version = version - if self.eval_version is not None: - from nuscenes.eval.detection.config import config_factory - self.eval_detection_configs = config_factory(self.eval_version) - if self.modality is None: - self.modality = dict( - use_camera=True, - use_lidar=False, - use_radar=False, - use_map=False, - use_external=False) - - def pre_pipeline(self, results): - """Initialization before data preparation. - Args: - results (dict): Dict before data preprocessing. - - img_fields (list): Image fields. - - bbox3d_fields (list): 3D bounding boxes fields. - - pts_mask_fields (list): Mask fields of points. - - pts_seg_fields (list): Mask fields of point segments. - - bbox_fields (list): Fields of bounding boxes. - - mask_fields (list): Fields of masks. - - seg_fields (list): Segment fields. - - box_type_3d (str): 3D box type. - - box_mode_3d (str): 3D box mode. - """ - results['img_prefix'] = '' # self.img_prefix - # print('img_prefix', self.img_prefix) - results['seg_prefix'] = self.seg_prefix - results['proposal_file'] = self.proposal_file - results['img_fields'] = [] - results['bbox3d_fields'] = [] - results['pts_mask_fields'] = [] - results['pts_seg_fields'] = [] - results['bbox_fields'] = [] - results['mask_fields'] = [] - results['seg_fields'] = [] - results['box_type_3d'] = self.box_type_3d - results['box_mode_3d'] = self.box_mode_3d - - def _parse_ann_info(self, img_info, ann_info): - """Parse bbox annotation. - Args: - img_info (list[dict]): Image info. - ann_info (list[dict]): Annotation info of an image. - Returns: - dict: A dict containing the following keys: bboxes, labels, \ - gt_bboxes_3d, gt_labels_3d, attr_labels, centers2d, \ - depths, bboxes_ignore, masks, seg_map - """ - gt_bboxes = [] - gt_labels = [] - attr_labels = [] - gt_bboxes_ignore = [] - gt_masks_ann = [] - gt_bboxes_cam3d = [] - centers2d = [] - depths = [] - for i, ann in enumerate(ann_info): - if ann.get('ignore', False): - continue - x1, y1, w, h = ann['bbox'] - inter_w = max(0, min(x1 + w, img_info['width']) - max(x1, 0)) - inter_h = max(0, min(y1 + h, img_info['height']) - max(y1, 0)) - if inter_w * inter_h == 0: - continue - if ann['area'] <= 0 or w < 1 or h < 1: - continue - if ann['category_id'] not in self.cat_ids: - continue - bbox = [x1, y1, x1 + w, y1 + h] - if ann.get('iscrowd', False): - gt_bboxes_ignore.append(bbox) - else: - gt_bboxes.append(bbox) - gt_labels.append(self.cat2label[ann['category_id']]) - attr_labels.append(ann['attribute_id']) - gt_masks_ann.append(ann.get('segmentation', None)) - # 3D annotations in camera coordinates - bbox_cam3d = np.array(ann['bbox_cam3d']).reshape(1, -1) - velo_cam3d = np.array(ann['velo_cam3d']).reshape(1, 2) - nan_mask = np.isnan(velo_cam3d[:, 0]) - velo_cam3d[nan_mask] = [0.0, 0.0] - bbox_cam3d = np.concatenate([bbox_cam3d, velo_cam3d], axis=-1) - gt_bboxes_cam3d.append(bbox_cam3d.squeeze()) - # 2.5D annotations in camera coordinates - center2d = ann['center2d'][:2] - depth = ann['center2d'][2] - centers2d.append(center2d) - depths.append(depth) - - if gt_bboxes: - gt_bboxes = np.array(gt_bboxes, dtype=np.float32) - gt_labels = np.array(gt_labels, dtype=np.int64) - attr_labels = np.array(attr_labels, dtype=np.int64) - else: - gt_bboxes = np.zeros((0, 4), dtype=np.float32) - gt_labels = np.array([], dtype=np.int64) - attr_labels = np.array([], dtype=np.int64) - - if gt_bboxes_cam3d: - gt_bboxes_cam3d = np.array(gt_bboxes_cam3d, dtype=np.float32) - centers2d = np.array(centers2d, dtype=np.float32) - depths = np.array(depths, dtype=np.float32) - else: - gt_bboxes_cam3d = np.zeros((0, self.bbox_code_size), - dtype=np.float32) - centers2d = np.zeros((0, 2), dtype=np.float32) - depths = np.zeros((0), dtype=np.float32) - - gt_bboxes_cam3d = CameraInstance3DBoxes( - gt_bboxes_cam3d, - box_dim=gt_bboxes_cam3d.shape[-1], - origin=(0.5, 0.5, 0.5)) - gt_labels_3d = copy.deepcopy(gt_labels) - - if gt_bboxes_ignore: - gt_bboxes_ignore = np.array(gt_bboxes_ignore, dtype=np.float32) - else: - gt_bboxes_ignore = np.zeros((0, 4), dtype=np.float32) - - seg_map = img_info['filename'].replace('jpg', 'png') - - ann = dict( - bboxes=gt_bboxes, - labels=gt_labels, - gt_bboxes_3d=gt_bboxes_cam3d, - gt_labels_3d=gt_labels_3d, - attr_labels=attr_labels, - centers2d=centers2d, - depths=depths, - bboxes_ignore=gt_bboxes_ignore, - masks=gt_masks_ann, - seg_map=seg_map) - - return ann - - def get_attr_name(self, attr_idx, label_name): - """Get attribute from predicted index. - This is a workaround to predict attribute when the predicted velocity - is not reliable. We map the predicted attribute index to the one - in the attribute set. If it is consistent with the category, we will - keep it. Otherwise, we will use the default attribute. - Args: - attr_idx (int): Attribute index. - label_name (str): Predicted category name. - Returns: - str: Predicted attribute name. - """ - # TODO: Simplify the variable name - AttrMapping_rev2 = [ - 'cycle.with_rider', 'cycle.without_rider', 'pedestrian.moving', - 'pedestrian.standing', 'pedestrian.sitting_lying_down', - 'vehicle.moving', 'vehicle.parked', 'vehicle.stopped', 'None' - ] - if label_name == 'car' or label_name == 'bus' \ - or label_name == 'truck' or label_name == 'trailer' \ - or label_name == 'construction_vehicle': - if AttrMapping_rev2[attr_idx] == 'vehicle.moving' or \ - AttrMapping_rev2[attr_idx] == 'vehicle.parked' or \ - AttrMapping_rev2[attr_idx] == 'vehicle.stopped': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - elif label_name == 'pedestrian': - if AttrMapping_rev2[attr_idx] == 'pedestrian.moving' or \ - AttrMapping_rev2[attr_idx] == 'pedestrian.standing' or \ - AttrMapping_rev2[attr_idx] == \ - 'pedestrian.sitting_lying_down': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - elif label_name == 'bicycle' or label_name == 'motorcycle': - if AttrMapping_rev2[attr_idx] == 'cycle.with_rider' or \ - AttrMapping_rev2[attr_idx] == 'cycle.without_rider': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - Returns: - str: Path of the output json file. - """ - nusc_annos = {} - mapped_class_names = self.CLASSES - - print('Start to convert detection format...') - - CAM_NUM = 6 - - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - - if sample_id % CAM_NUM == 0: - boxes_per_frame = [] - attrs_per_frame = [] - - # need to merge results from images of the same sample - annos = [] - boxes, attrs = output_to_nusc_box(det) - sample_token = self.data_infos[sample_id]['token'] - boxes, attrs = cam_nusc_box_to_global(self.data_infos[sample_id], - boxes, attrs, - mapped_class_names, - self.eval_detection_configs, - self.eval_version) - - boxes_per_frame.extend(boxes) - attrs_per_frame.extend(attrs) - # Remove redundant predictions caused by overlap of images - if (sample_id + 1) % CAM_NUM != 0: - continue - boxes = global_nusc_box_to_cam( - self.data_infos[sample_id + 1 - CAM_NUM], boxes_per_frame, - mapped_class_names, self.eval_detection_configs, - self.eval_version) - cam_boxes3d, scores, labels = nusc_box_to_cam_box3d(boxes) - # box nms 3d over 6 images in a frame - # TODO: move this global setting into config - nms_cfg = dict( - use_rotate_nms=True, - nms_across_levels=False, - nms_pre=4096, - nms_thr=0.05, - score_thr=0.01, - min_bbox_size=0, - max_per_frame=500) - from mmcv import Config - nms_cfg = Config(nms_cfg) - cam_boxes3d_for_nms = xywhr2xyxyr(cam_boxes3d.bev) - boxes3d = cam_boxes3d.tensor - # generate attr scores from attr labels - attrs = labels.new_tensor([attr for attr in attrs_per_frame]) - boxes3d, scores, labels, attrs = box3d_multiclass_nms( - boxes3d, - cam_boxes3d_for_nms, - scores, - nms_cfg.score_thr, - nms_cfg.max_per_frame, - nms_cfg, - mlvl_attr_scores=attrs) - cam_boxes3d = CameraInstance3DBoxes(boxes3d, box_dim=9) - det = bbox3d2result(cam_boxes3d, scores, labels, attrs) - boxes, attrs = output_to_nusc_box(det) - boxes, attrs = cam_nusc_box_to_global( - self.data_infos[sample_id + 1 - CAM_NUM], boxes, attrs, - mapped_class_names, self.eval_detection_configs, - self.eval_version) - - for i, box in enumerate(boxes): - name = mapped_class_names[box.label] - attr = self.get_attr_name(attrs[i], name) - nusc_anno = dict( - sample_token=sample_token, - translation=box.center.tolist(), - size=box.wlh.tolist(), - rotation=box.orientation.elements.tolist(), - velocity=box.velocity[:2].tolist(), - detection_name=name, - detection_score=box.score, - attribute_name=attr) - annos.append(nusc_anno) - # other views results of the same frame should be concatenated - if sample_token in nusc_annos: - nusc_annos[sample_token].extend(annos) - else: - nusc_annos[sample_token] = annos - - nusc_submissions = { - 'meta': self.modality, - 'results': nusc_annos, - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'results_nusc.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def _evaluate_single(self, - result_path, - logger=None, - metric='bbox', - result_name='img_bbox'): - """Evaluation for a single model in nuScenes protocol. - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'img_bbox'. - Returns: - dict: Dictionary of evaluation details. - """ - from nuscenes import NuScenes - #from nuscenes.eval.detection.evaluate import NuScenesEval - from .nuscnes_eval import NuScenesEval_custom - output_dir = osp.join(*osp.split(result_path)[:-1]) - self.nusc = NuScenes( - version=self.version, dataroot=self.data_root, verbose=False) - eval_set_map = { - 'v1.0-mini': 'mini_val', - 'v1.0-trainval': 'val', - } - # nusc_eval = NuScenesEval( - # nusc, - # config=self.eval_detection_configs, - # result_path=result_path, - # eval_set=eval_set_map[self.version], - # output_dir=output_dir, - # verbose=False) - self.nusc_eval = NuScenesEval_custom( - self.nusc, - config=self.eval_detection_configs, - result_path=result_path, - eval_set=eval_set_map[self.version], - output_dir=output_dir, - verbose=True, - overlap_test=self.overlap_test, - data_infos=self.data_infos - ) - - self.nusc_eval.main(render_curves=True) - - # record metrics - metrics = mmcv.load(osp.join(output_dir, 'metrics_summary.json')) - detail = dict() - metric_prefix = f'{result_name}_NuScenes' - for name in self.CLASSES: - for k, v in metrics['label_aps'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_AP_dist_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['label_tp_errors'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['tp_errors'].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}'.format(metric_prefix, - self.ErrNameMapping[k])] = val - - detail['{}/NDS'.format(metric_prefix)] = metrics['nd_score'] - detail['{}/mAP'.format(metric_prefix)] = metrics['mean_ap'] - return detail - - def format_results(self, results, jsonfile_prefix=None, **kwargs): - """Format the results to json (standard format for COCO evaluation). - Args: - results (list[tuple | numpy.ndarray]): Testing results of the - dataset. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - Returns: - tuple: (result_files, tmp_dir), result_files is a dict containing \ - the json filepaths, tmp_dir is the temporal directory created \ - for saving json files when jsonfile_prefix is not specified. - """ - assert isinstance(results, list), 'results must be a list' - assert len(results) == len(self), ( - 'The length of results is not equal to the dataset len: {} != {}'. - format(len(results), len(self))) - - if jsonfile_prefix is None: - tmp_dir = tempfile.TemporaryDirectory() - jsonfile_prefix = osp.join(tmp_dir.name, 'results') - else: - tmp_dir = None - - # currently the output prediction results could be in two formats - # 1. list of dict('boxes_3d': ..., 'scores_3d': ..., 'labels_3d': ...) - # 2. list of dict('pts_bbox' or 'img_bbox': - # dict('boxes_3d': ..., 'scores_3d': ..., 'labels_3d': ...)) - # this is a workaround to enable evaluation of both formats on nuScenes - # refer to https://github.com/open-mmlab/mmdetection3d/issues/449 - if not ('pts_bbox' in results[0] or 'img_bbox' in results[0]): - result_files = self._format_bbox(results, jsonfile_prefix) - else: - # should take the inner dict out of 'pts_bbox' or 'img_bbox' dict - result_files = dict() - for name in results[0]: - # not evaluate 2D predictions on nuScenes - if '2d' in name: - continue - print(f'\nFormating bboxes of {name}') - results_ = [out[name] for out in results] - tmp_file_ = osp.join(jsonfile_prefix, name) - result_files.update( - {name: self._format_bbox(results_, tmp_file_)}) - - return result_files, tmp_dir - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['img_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - Returns: - dict[str, float]: Results of each evaluation metric. - """ - - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name]) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - def _extract_data(self, index, pipeline, key, load_annos=False): - """Load data using input pipeline and extract data according to key. - Args: - index (int): Index for accessing the target data. - pipeline (:obj:`Compose`): Composed data loading pipeline. - key (str | list[str]): One single or a list of data key. - load_annos (bool): Whether to load data annotations. - If True, need to set self.test_mode as False before loading. - Returns: - np.ndarray | torch.Tensor | list[np.ndarray | torch.Tensor]: - A single or a list of loaded data. - """ - assert pipeline is not None, 'data loading pipeline is not provided' - img_info = self.data_infos[index] - input_dict = dict(img_info=img_info) - - if load_annos: - ann_info = self.get_ann_info(index) - input_dict.update(dict(ann_info=ann_info)) - - self.pre_pipeline(input_dict) - example = pipeline(input_dict) - - # extract data items according to keys - if isinstance(key, str): - data = extract_result_dict(example, key) - else: - data = [extract_result_dict(example, k) for k in key] - - return data - - def _get_pipeline(self, pipeline): - """Get data loading pipeline in self.show/evaluate function. - Args: - pipeline (list[dict] | None): Input pipeline. If None is given, \ - get from self.pipeline. - """ - if pipeline is None: - if not hasattr(self, 'pipeline') or self.pipeline is None: - warnings.warn( - 'Use default pipeline for data loading, this may cause ' - 'errors when data is on ceph') - return self._build_default_pipeline() - loading_pipeline = get_loading_pipeline(self.pipeline.transforms) - return Compose(loading_pipeline) - return Compose(pipeline) - - def _build_default_pipeline(self): - """Build the default pipeline for this dataset.""" - pipeline = [ - dict(type='LoadImageFromFileMono3D'), - dict( - type='DefaultFormatBundle3D', - class_names=self.CLASSES, - with_label=False), - dict(type='Collect3D', keys=['img']) - ] - return Compose(pipeline) - - def show(self, results, out_dir, show=True, pipeline=None): - """Results visualization. - Args: - results (list[dict]): List of bounding boxes results. - out_dir (str): Output directory of visualization result. - show (bool): Visualize the results online. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - """ - assert out_dir is not None, 'Expect out_dir, got none.' - pipeline = self._get_pipeline(pipeline) - for i, result in enumerate(results): - if 'img_bbox' in result.keys(): - result = result['img_bbox'] - data_info = self.data_infos[i] - img_path = data_info['file_name'] - file_name = osp.split(img_path)[-1].split('.')[0] - img, img_metas = self._extract_data(i, pipeline, - ['img', 'img_metas']) - # need to transpose channel to first dim - img = img.numpy().transpose(1, 2, 0) - gt_bboxes = self.get_ann_info(i)['gt_bboxes_3d'] - pred_bboxes = result['boxes_3d'] - show_multi_modality_result( - img, - gt_bboxes, - pred_bboxes, - img_metas['cam2img'], - out_dir, - file_name, - box_mode='camera', - show=show) - - -def output_to_nusc_box(detection): - """Convert the output to the box class in the nuScenes. - Args: - detection (dict): Detection results. - - boxes_3d (:obj:`BaseInstance3DBoxes`): Detection bbox. - - scores_3d (torch.Tensor): Detection scores. - - labels_3d (torch.Tensor): Predicted box labels. - - attrs_3d (torch.Tensor, optional): Predicted attributes. - Returns: - list[:obj:`NuScenesBox`]: List of standard NuScenesBoxes. - """ - box3d = detection['boxes_3d'] - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - attrs = None - if 'attrs_3d' in detection: - attrs = detection['attrs_3d'].numpy() - - box_gravity_center = box3d.gravity_center.numpy() - box_dims = box3d.dims.numpy() - box_yaw = box3d.yaw.numpy() - - # convert the dim/rot to nuscbox convention - box_dims[:, [0, 1, 2]] = box_dims[:, [2, 0, 1]] - box_yaw = -box_yaw - - box_list = [] - for i in range(len(box3d)): - q1 = pyquaternion.Quaternion(axis=[0, 0, 1], radians=box_yaw[i]) - q2 = pyquaternion.Quaternion(axis=[1, 0, 0], radians=np.pi / 2) - quat = q2 * q1 - velocity = (box3d.tensor[i, 7], 0.0, box3d.tensor[i, 8]) - box = NuScenesBox( - box_gravity_center[i], - box_dims[i], - quat, - label=labels[i], - score=scores[i], - velocity=velocity) - box_list.append(box) - return box_list, attrs - - -def cam_nusc_box_to_global(info, - boxes, - attrs, - classes, - eval_configs, - eval_version='detection_cvpr_2019'): - """Convert the box from camera to global coordinate. - Args: - info (dict): Info for a specific sample data, including the - calibration information. - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - classes (list[str]): Mapped classes in the evaluation. - eval_configs (object): Evaluation configuration object. - eval_version (str): Evaluation version. - Default: 'detection_cvpr_2019' - Returns: - list: List of standard NuScenesBoxes in the global - coordinate. - """ - box_list = [] - attr_list = [] - for (box, attr) in zip(boxes, attrs): - # Move box to ego vehicle coord system - box.rotate(pyquaternion.Quaternion(info['cam2ego_rotation'])) - box.translate(np.array(info['cam2ego_translation'])) - # filter det in ego. - cls_range_map = eval_configs.class_range - radius = np.linalg.norm(box.center[:2], 2) - det_range = cls_range_map[classes[box.label]] - if radius > det_range: - continue - # Move box to global coord system - box.rotate(pyquaternion.Quaternion(info['ego2global_rotation'])) - box.translate(np.array(info['ego2global_translation'])) - box_list.append(box) - attr_list.append(attr) - return box_list, attr_list - - -def global_nusc_box_to_cam(info, - boxes, - classes, - eval_configs, - eval_version='detection_cvpr_2019'): - """Convert the box from global to camera coordinate. - Args: - info (dict): Info for a specific sample data, including the - calibration information. - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - classes (list[str]): Mapped classes in the evaluation. - eval_configs (object): Evaluation configuration object. - eval_version (str): Evaluation version. - Default: 'detection_cvpr_2019' - Returns: - list: List of standard NuScenesBoxes in the global - coordinate. - """ - box_list = [] - for box in boxes: - # Move box to ego vehicle coord system - box.translate(-np.array(info['ego2global_translation'])) - box.rotate( - pyquaternion.Quaternion(info['ego2global_rotation']).inverse) - # filter det in ego. - cls_range_map = eval_configs.class_range - radius = np.linalg.norm(box.center[:2], 2) - det_range = cls_range_map[classes[box.label]] - if radius > det_range: - continue - # Move box to camera coord system - box.translate(-np.array(info['cam2ego_translation'])) - box.rotate(pyquaternion.Quaternion(info['cam2ego_rotation']).inverse) - box_list.append(box) - return box_list - - -def nusc_box_to_cam_box3d(boxes): - """Convert boxes from :obj:`NuScenesBox` to :obj:`CameraInstance3DBoxes`. - Args: - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - Returns: - tuple (:obj:`CameraInstance3DBoxes` | torch.Tensor | torch.Tensor): \ - Converted 3D bounding boxes, scores and labels. - """ - locs = torch.Tensor([b.center for b in boxes]).view(-1, 3) - dims = torch.Tensor([b.wlh for b in boxes]).view(-1, 3) - rots = torch.Tensor([b.orientation.yaw_pitch_roll[0] - for b in boxes]).view(-1, 1) - velocity = torch.Tensor([b.velocity[:2] for b in boxes]).view(-1, 2) - - # convert nusbox to cambox convention - dims[:, [0, 1, 2]] = dims[:, [1, 2, 0]] - rots = -rots - - boxes_3d = torch.cat([locs, dims, rots, velocity], dim=1).cuda() - cam_boxes3d = CameraInstance3DBoxes( - boxes_3d, box_dim=9, origin=(0.5, 0.5, 0.5)) - scores = torch.Tensor([b.score for b in boxes]).cuda() - labels = torch.LongTensor([b.label for b in boxes]).cuda() - nms_scores = scores.new_zeros(scores.shape[0], 10 + 1) - indices = labels.new_tensor(list(range(scores.shape[0]))) - nms_scores[indices, labels] = scores - return cam_boxes3d, nms_scores, labels \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/__init__.py deleted file mode 100755 index 312c41803c63fcf787c8a3dc52dfcef0e76eaab6..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from .transform_3d import ( - PadMultiViewImage, NormalizeMultiviewImage, - PhotoMetricDistortionMultiViewImage, CustomCollect3D, RandomScaleImageMultiViewImage) -from .formating import CustomDefaultFormatBundle3D -from .augmentation import (CropResizeFlipImage, GlobalRotScaleTransImage) -from .dd3d_mapper import DD3DMapper -__all__ = [ - 'PadMultiViewImage', 'NormalizeMultiviewImage', - 'PhotoMetricDistortionMultiViewImage', 'CustomDefaultFormatBundle3D', 'CustomCollect3D', - 'RandomScaleImageMultiViewImage', - 'CropResizeFlipImage', 'GlobalRotScaleTransImage', - 'DD3DMapper', -] \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/augmentation.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/augmentation.py deleted file mode 100644 index 86e027f4d0ac8eeb30447a4477d7441a71ca394a..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/augmentation.py +++ /dev/null @@ -1,369 +0,0 @@ -import numpy as np -import torch -import mmcv -from mmdet.datasets.builder import PIPELINES -from PIL import Image -import random - - -@PIPELINES.register_module() -class CropResizeFlipImage(object): - """Fixed Crop and then randim resize and flip the image. Note the flip requires to flip the feature in the network - ida_aug_conf = { - "reisze": [576, 608, 640, 672, 704] # stride of 32 based on 640 (0.9, 1.1) - "reisze": [512, 544, 576, 608, 640, 672, 704, 736, 768] # (0.8, 1.2) - "reisze": [448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832] # (0.7, 1.3) - "crop": (0, 260, 1600, 900), - "H": 900, - "W": 1600, - "rand_flip": True, -} - Args: - size (tuple, optional): Fixed padding size. - """ - - def __init__(self, data_aug_conf=None, training=True, debug=False): - self.data_aug_conf = data_aug_conf - self.training = training - self.debug = debug - - def __call__(self, results): - """Call function to pad images, masks, semantic segmentation maps. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Updated result dict. - """ - if not 'aug_param' in results.keys(): - results['aug_param'] = {} - imgs = results["img"] - N = len(imgs) - new_imgs = [] - resize, resize_dims, crop, flip = self._sample_augmentation(results) - - if self.debug: - # unique id per img - from uuid import uuid4 - uid = uuid4() - # lidar is RFU in nuscenes - lidar_pts = np.array([ - [10, 30, -2, 1], - [-10, 30, -2, 1], - [5, 15, -2, 1], - [-5, 15, -2, 1], - [30, 0, -2, 1], - [-30, 0, -2, 1], - [10, -30, -2, 1], - [-10, -30, -2, 1] - ], dtype=np.float32).T - - for i in range(N): - img = Image.fromarray(np.uint8(imgs[i])) - - if self.debug: - pts_to_img_pre_aug = results['lidar2img'][i] @ lidar_pts - pts_to_img_pre_aug = pts_to_img_pre_aug / pts_to_img_pre_aug[2:3, - :] # div by the depth component in homogenous vector - - img_copy = Image.fromarray(np.uint8(imgs[i])) - for j in range(pts_to_img_pre_aug.shape[1]): - x, y = int(pts_to_img_pre_aug[0, j]), int(pts_to_img_pre_aug[1, j]) - if (0 < x < img_copy.width) and (0 < y < img_copy.height): - img_copy.putpixel((x - 1, y - 1), (255, 0, 0)) - img_copy.putpixel((x - 1, y), (255, 0, 0)) - img_copy.putpixel((x - 1, y + 1), (255, 0, 0)) - img_copy.putpixel((x, y - 1), (0, 255, 0)) - img_copy.putpixel((x, y), (0, 255, 0)) - img_copy.putpixel((x, y + 1), (0, 255, 0)) - img_copy.putpixel((x + 1, y - 1), (0, 0, 255)) - img_copy.putpixel((x + 1, y), (0, 0, 255)) - img_copy.putpixel((x + 1, y + 1), (0, 0, 255)) - img_copy.save(f'pre_aug_{uid}_{i}.png') - - # augmentation (resize, crop, horizontal flip, rotate) - # resize, resize_dims, crop, flip, rotate = self._sample_augmentation() ###different view use different aug (BEV Det) - img, ida_mat = self._img_transform( - img, - resize=resize, - resize_dims=resize_dims, - crop=crop, - flip=flip, - ) - new_imgs.append(np.array(img).astype(np.float32)) - results['cam2img'][i][:3, :3] = np.matmul(ida_mat, results['cam2img'][i][:3, :3]) - - if self.debug: - pts_to_img_post_aug = np.matmul(results['cam2img'][i], results['lidar2cam'][i]) @ lidar_pts - pts_to_img_post_aug = pts_to_img_post_aug / pts_to_img_post_aug[2:3, - :] # div by the depth component in homogenous vector - for j in range(pts_to_img_post_aug.shape[1]): - x, y = int(pts_to_img_post_aug[0, j]), int(pts_to_img_post_aug[1, j]) - if (0 < x < img.width) and (0 < y < img.height): - img.putpixel((x - 1, y - 1), (255, 0, 0)) - img.putpixel((x - 1, y), (255, 0, 0)) - img.putpixel((x - 1, y + 1), (255, 0, 0)) - img.putpixel((x, y - 1), (0, 255, 0)) - img.putpixel((x, y), (0, 255, 0)) - img.putpixel((x, y + 1), (0, 255, 0)) - img.putpixel((x + 1, y - 1), (0, 0, 255)) - img.putpixel((x + 1, y), (0, 0, 255)) - img.putpixel((x + 1, y + 1), (0, 0, 255)) - img.save(f'post_aug_{uid}_{i}.png') - - if 'mono_ann_idx' in results.keys(): - # apply transform to dd3d intrinsics - if i in results['mono_ann_idx'].data: - mono_index = results['mono_ann_idx'].data.index(i) - intrinsics = results['mono_input_dict'][mono_index]['intrinsics'] - if torch.is_tensor(intrinsics): - intrinsics = intrinsics.numpy().reshape(3, 3).astype(np.float32) - elif isinstance(intrinsics, np.ndarray): - intrinsics = intrinsics.reshape(3, 3).astype(np.float32) - else: - intrinsics = np.array(intrinsics, dtype=np.float32).reshape(3, 3) - results['mono_input_dict'][mono_index]['intrinsics'] = np.matmul(ida_mat, intrinsics) - results['mono_input_dict'][mono_index]['height'] = img.size[1] - results['mono_input_dict'][mono_index]['width'] = img.size[0] - - # apply transform to dd3d box - for ann in results['mono_input_dict'][mono_index]['annotations']: - # bbox_mode = BoxMode.XYXY_ABS - box = self._box_transform(ann['bbox'], resize, crop, flip, img.size[0])[0] - box = box.clip(min=0) - box = np.minimum(box, list(img.size + img.size)) - ann["bbox"] = box - - results["img"] = new_imgs - results['lidar2img'] = [np.matmul(results['cam2img'][i], results['lidar2cam'][i]) for i in - range(len(results['lidar2cam']))] - - return results - - def _box_transform(self, box, resize, crop, flip, img_width): - box = np.array([box]) - idxs = np.array([(0, 1), (2, 1), (0, 3), (2, 3)]).flatten() - coords = np.asarray(box).reshape(-1, 4)[:, idxs].reshape(-1, 2) - - # crop - coords[:, 0] -= crop[0] - coords[:, 1] -= crop[1] - - # resize - coords[:, 0] = coords[:, 0] * resize - coords[:, 1] = coords[:, 1] * resize - - coords = coords.reshape((-1, 4, 2)) - minxy = coords.min(axis=1) - maxxy = coords.max(axis=1) - trans_box = np.concatenate((minxy, maxxy), axis=1) - - return trans_box - - def _img_transform(self, img, resize, resize_dims, crop, flip): - ida_rot = np.eye(2) - ida_tran = np.zeros(2) - # adjust image - img = img.crop(crop) - img = img.resize(resize_dims) - if flip: - img = img.transpose(method=Image.FLIP_LEFT_RIGHT) - - # post-homography transformation - ida_rot *= resize - ida_tran -= np.array(crop[:2]) * resize - ida_mat = np.eye(3) - ida_mat[:2, :2] = ida_rot - ida_mat[:2, 2] = ida_tran - return img, ida_mat - - def _sample_augmentation(self, results): - if 'CropResizeFlipImage_param' in results['aug_param'].keys(): - return results['aug_param']['CropResizeFlipImage_param'] - crop = self.data_aug_conf["crop"] - - if self.training: - resized_h = random.choice(self.data_aug_conf["reisze"]) - resized_w = resized_h / (crop[3] - crop[1]) * (crop[2] - crop[0]) - resize = resized_h / (crop[3] - crop[1]) - resize_dims = (int(resized_w), int(resized_h)) - flip = False - if self.data_aug_conf["rand_flip"] and np.random.choice([0, 1]): - flip = True - else: - resized_h = random.choice(self.data_aug_conf["reisze"]) - assert len(self.data_aug_conf["reisze"]) == 1 - resized_w = resized_h / (crop[3] - crop[1]) * (crop[2] - crop[0]) - resize = resized_h / (crop[3] - crop[1]) - resize_dims = (int(resized_w), int(resized_h)) - flip = False - results['aug_param']['CropResizeFlipImage_param'] = (resize, resize_dims, crop, flip) - - return resize, resize_dims, crop, flip - - -@PIPELINES.register_module() -class GlobalRotScaleTransImage(object): - """Random resize, Crop and flip the image - Args: - size (tuple, optional): Fixed padding size. - """ - - def __init__( - self, - rot_range=[-0.3925, 0.3925], - scale_ratio_range=[0.95, 1.05], - translation_std=[0, 0, 0], - reverse_angle=False, - training=True, - flip_dx_ratio=0.5, - flip_dy_ratio=0.5, - only_gt=False, - ): - - self.rot_range = rot_range - self.scale_ratio_range = scale_ratio_range - self.translation_std = translation_std - - self.reverse_angle = reverse_angle - self.training = training - - self.flip_dx_ratio = flip_dx_ratio - self.flip_dy_ratio = flip_dy_ratio - self.only_gt = only_gt - - def __call__(self, results): - """Call function to pad images, masks, semantic segmentation maps. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Updated result dict. - """ - if not 'aug_param' in results.keys(): - results['aug_param'] = {} - - rot_angle, scale_ratio, flip_dx, flip_dy, _, _ = self._sample_augmentation(results) - - # random rotate - if not self.only_gt: - self.rotate_bev_along_z(results, rot_angle) - if self.reverse_angle: - rot_angle *= -1 - results["gt_bboxes_3d"].rotate( - np.array(rot_angle) - ) - - # random scale - if not self.only_gt: - self.scale_xyz(results, scale_ratio) - results["gt_bboxes_3d"].scale(scale_ratio) - - # random flip - if flip_dx: - if not self.only_gt: - self.flip_along_x(results) - results["gt_bboxes_3d"].flip(bev_direction='vertical') - if flip_dy: - if not self.only_gt: - self.flip_along_y(results) - results["gt_bboxes_3d"].flip(bev_direction='horizontal') - - # TODO: support translation - return results - - def _sample_augmentation(self, results): - if 'GlobalRotScaleTransImage_param' in results['aug_param'].keys(): - return results['aug_param']['GlobalRotScaleTransImage_param'] - else: - rot_angle = np.random.uniform(*self.rot_range) / 180 * np.pi - scale_ratio = np.random.uniform(*self.scale_ratio_range) - flip_dx = np.random.uniform() < self.flip_dx_ratio - flip_dy = np.random.uniform() < self.flip_dy_ratio - # generate bda_mat - - rot_sin = torch.sin(torch.tensor(rot_angle)) - rot_cos = torch.cos(torch.tensor(rot_angle)) - rot_mat = torch.Tensor([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], - [0, 0, 1]]) - scale_mat = torch.Tensor([[scale_ratio, 0, 0], [0, scale_ratio, 0], - [0, 0, scale_ratio]]) - flip_mat = torch.Tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) - if flip_dx: - flip_mat = flip_mat @ torch.Tensor([[-1, 0, 0], [0, 1, 0], - [0, 0, 1]]) - if flip_dy: - flip_mat = flip_mat @ torch.Tensor([[1, 0, 0], [0, -1, 0], - [0, 0, 1]]) - bda_mat = flip_mat @ (scale_mat @ rot_mat) - bda_mat = torch.inverse(bda_mat) - results['aug_param']['GlobalRotScaleTransImage_param'] = ( - rot_angle, scale_ratio, flip_dx, flip_dy, bda_mat, self.only_gt) - - return rot_angle, scale_ratio, flip_dx, flip_dy, bda_mat, self.only_gt - - def rotate_bev_along_z(self, results, angle): - rot_cos = np.cos(angle) - rot_sin = np.sin(angle) - - rot_mat = np.array([[rot_cos, -rot_sin, 0, 0], [rot_sin, rot_cos, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) - rot_mat_inv = np.linalg.inv(rot_mat) - - num_view = len(results["lidar2img"]) - for view in range(num_view): - results["lidar2img"][view] = np.matmul(results["lidar2img"][view], rot_mat_inv) - results['lidar2cam'][view] = np.matmul(results['lidar2cam'][view], rot_mat_inv) - - return - - def scale_xyz(self, results, scale_ratio): - scale_mat = np.array( - [ - [scale_ratio, 0, 0, 0], - [0, scale_ratio, 0, 0], - [0, 0, scale_ratio, 0], - [0, 0, 0, 1], - ] - ) - - scale_mat_inv = np.linalg.inv(scale_mat) - - num_view = len(results["lidar2img"]) - for view in range(num_view): - results["lidar2img"][view] = np.matmul(results["lidar2img"][view], scale_mat_inv) - results['lidar2cam'][view] = np.matmul(results['lidar2cam'][view], scale_mat_inv) - return - - def flip_along_x(self, results): - flip_mat = np.array( - [ - [-1, 0, 0, 0], - [0, 1, 0, 0], - [0, 0, 1, 0], - [0, 0, 0, 1], - ] - ).astype(np.float32) - - flip_mat_inv = np.linalg.inv(flip_mat) - - num_view = len(results["lidar2img"]) - for view in range(num_view): - results["lidar2img"][view] = np.matmul(results["lidar2img"][view], flip_mat_inv) - results['lidar2cam'][view] = np.matmul(results['lidar2cam'][view], flip_mat_inv) - return - - def flip_along_y(self, results): - flip_mat = np.array( - [ - [1, 0, 0, 0], - [0, -1, 0, 0], - [0, 0, 1, 0], - [0, 0, 0, 1], - ] - ).astype(np.float32) - - flip_mat_inv = np.linalg.inv(flip_mat) - - num_view = len(results["lidar2img"]) - for view in range(num_view): - results["lidar2img"][view] = np.matmul(results["lidar2img"][view], flip_mat_inv) - results['lidar2cam'][view] = np.matmul(results['lidar2cam'][view], flip_mat_inv) - return diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/formating.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/formating.py deleted file mode 100644 index 52878523f5ad82bceba47f3845a58d6468d95849..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/formating.py +++ /dev/null @@ -1,39 +0,0 @@ - -# Copyright (c) OpenMMLab. All rights reserved. -import numpy as np -from mmcv.parallel import DataContainer as DC - -from mmdet3d.core.bbox import BaseInstance3DBoxes -from mmdet3d.core.points import BasePoints -from mmdet.datasets.builder import PIPELINES -from mmdet.datasets.pipelines import to_tensor -from mmdet3d.datasets.pipelines import DefaultFormatBundle3D - -@PIPELINES.register_module() -class CustomDefaultFormatBundle3D(DefaultFormatBundle3D): - """Default formatting bundle. - It simplifies the pipeline of formatting common fields for voxels, - including "proposals", "gt_bboxes", "gt_labels", "gt_masks" and - "gt_semantic_seg". - These fields are formatted as follows. - - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) - - proposals: (1)to tensor, (2)to DataContainer - - gt_bboxes: (1)to tensor, (2)to DataContainer - - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer - - gt_labels: (1)to tensor, (2)to DataContainer - """ - - def __call__(self, results): - """Call function to transform and format common fields in results. - Args: - results (dict): Result dict contains the data to convert. - Returns: - dict: The result dict contains the data that is formatted with - default bundle. - """ - # Format 3D data - results = super(CustomDefaultFormatBundle3D, self).__call__(results) - results['gt_map_masks'] = DC( - to_tensor(results['gt_map_masks']), stack=True) - - return results \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/transform_3d.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/transform_3d.py deleted file mode 100755 index 3171d3e2da8d37815ff5f493d80404a4874a08e8..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/pipelines/transform_3d.py +++ /dev/null @@ -1,330 +0,0 @@ -import numpy as np -from numpy import random -import mmcv -from mmdet.datasets.builder import PIPELINES -from mmcv.parallel import DataContainer as DC - -@PIPELINES.register_module() -class PadMultiViewImage(object): - """Pad the multi-view image. - There are two padding modes: (1) pad to a fixed size and (2) pad to the - minimum size that is divisible by some number. - Added keys are "pad_shape", "pad_fixed_size", "pad_size_divisor", - Args: - size (tuple, optional): Fixed padding size. - size_divisor (int, optional): The divisor of padded size. - pad_val (float, optional): Padding value, 0 by default. - """ - - def __init__(self, size=None, size_divisor=None, pad_val=0): - self.size = size - self.size_divisor = size_divisor - self.pad_val = pad_val - # only one of size and size_divisor should be valid - assert size is not None or size_divisor is not None - assert size is None or size_divisor is None - - def _pad_img(self, results): - """Pad images according to ``self.size``.""" - if self.size is not None: - padded_img = [mmcv.impad( - img, shape=self.size, pad_val=self.pad_val) for img in results['img']] - elif self.size_divisor is not None: - padded_img = [mmcv.impad_to_multiple( - img, self.size_divisor, pad_val=self.pad_val) for img in results['img']] - - results['ori_shape'] = [img.shape for img in results['img']] - results['img'] = padded_img - results['img_shape'] = [img.shape for img in padded_img] - results['pad_shape'] = [img.shape for img in padded_img] - results['pad_fixed_size'] = self.size - results['pad_size_divisor'] = self.size_divisor - - def __call__(self, results): - """Call function to pad images, masks, semantic segmentation maps. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Updated result dict. - """ - self._pad_img(results) - return results - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += f'(size={self.size}, ' - repr_str += f'size_divisor={self.size_divisor}, ' - repr_str += f'pad_val={self.pad_val})' - return repr_str - - -@PIPELINES.register_module() -class NormalizeMultiviewImage(object): - """Normalize the image. - Added key is "img_norm_cfg". - Args: - mean (sequence): Mean values of 3 channels. - std (sequence): Std values of 3 channels. - to_rgb (bool): Whether to convert the image from BGR to RGB, - default is true. - """ - - def __init__(self, mean, std, to_rgb=True): - self.mean = np.array(mean, dtype=np.float32) - self.std = np.array(std, dtype=np.float32) - self.to_rgb = to_rgb - - - def __call__(self, results): - """Call function to normalize images. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Normalized results, 'img_norm_cfg' key is added into - result dict. - """ - - results['img'] = [mmcv.imnormalize(img, self.mean, self.std, self.to_rgb) for img in results['img']] - results['img_norm_cfg'] = dict( - mean=self.mean, std=self.std, to_rgb=self.to_rgb) - return results - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += f'(mean={self.mean}, std={self.std}, to_rgb={self.to_rgb})' - return repr_str - - -@PIPELINES.register_module() -class PhotoMetricDistortionMultiViewImage: - """Apply photometric distortion to image sequentially, every transformation - is applied with a probability of 0.5. The position of random contrast is in - second or second to last. - 1. random brightness - 2. random contrast (mode 0) - 3. convert color from BGR to HSV - 4. random saturation - 5. random hue - 6. convert color from HSV to BGR - 7. random contrast (mode 1) - 8. randomly swap channels - Args: - brightness_delta (int): delta of brightness. - contrast_range (tuple): range of contrast. - saturation_range (tuple): range of saturation. - hue_delta (int): delta of hue. - """ - - def __init__(self, - brightness_delta=32, - contrast_range=(0.5, 1.5), - saturation_range=(0.5, 1.5), - hue_delta=18): - self.brightness_delta = brightness_delta - self.contrast_lower, self.contrast_upper = contrast_range - self.saturation_lower, self.saturation_upper = saturation_range - self.hue_delta = hue_delta - - def __call__(self, results): - """Call function to perform photometric distortion on images. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Result dict with images distorted. - """ - imgs = results['img'] - new_imgs = [] - for img in imgs: - assert img.dtype == np.float32, \ - 'PhotoMetricDistortion needs the input image of dtype np.float32,'\ - ' please set "to_float32=True" in "LoadImageFromFile" pipeline' - # random brightness - if random.randint(2): - delta = random.uniform(-self.brightness_delta, - self.brightness_delta) - img += delta - - # mode == 0 --> do random contrast first - # mode == 1 --> do random contrast last - mode = random.randint(2) - if mode == 1: - if random.randint(2): - alpha = random.uniform(self.contrast_lower, - self.contrast_upper) - img *= alpha - - # convert color from BGR to HSV - img = mmcv.bgr2hsv(img) - - # random saturation - if random.randint(2): - img[..., 1] *= random.uniform(self.saturation_lower, - self.saturation_upper) - - # random hue - if random.randint(2): - img[..., 0] += random.uniform(-self.hue_delta, self.hue_delta) - img[..., 0][img[..., 0] > 360] -= 360 - img[..., 0][img[..., 0] < 0] += 360 - - # convert color from HSV to BGR - img = mmcv.hsv2bgr(img) - - # random contrast - if mode == 0: - if random.randint(2): - alpha = random.uniform(self.contrast_lower, - self.contrast_upper) - img *= alpha - - # randomly swap channels - if random.randint(2): - img = img[..., random.permutation(3)] - new_imgs.append(img) - results['img'] = new_imgs - return results - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += f'(\nbrightness_delta={self.brightness_delta},\n' - repr_str += 'contrast_range=' - repr_str += f'{(self.contrast_lower, self.contrast_upper)},\n' - repr_str += 'saturation_range=' - repr_str += f'{(self.saturation_lower, self.saturation_upper)},\n' - repr_str += f'hue_delta={self.hue_delta})' - return repr_str - - - -@PIPELINES.register_module() -class CustomCollect3D(object): - """Collect data from the loader relevant to the specific task. - This is usually the last stage of the data loader pipeline. Typically keys - is set to some subset of "img", "proposals", "gt_bboxes", - "gt_bboxes_ignore", "gt_labels", and/or "gt_masks". - The "img_meta" item is always populated. The contents of the "img_meta" - dictionary depends on "meta_keys". By default this includes: - - 'img_shape': shape of the image input to the network as a tuple \ - (h, w, c). Note that images may be zero padded on the \ - bottom/right if the batch tensor is larger than this shape. - - 'scale_factor': a float indicating the preprocessing scale - - 'flip': a boolean indicating if image flip transform was used - - 'filename': path to the image file - - 'ori_shape': original shape of the image as a tuple (h, w, c) - - 'pad_shape': image shape after padding - - 'lidar2img': transform from lidar to image - - 'depth2img': transform from depth to image - - 'cam2img': transform from camera to image - - 'pcd_horizontal_flip': a boolean indicating if point cloud is \ - flipped horizontally - - 'pcd_vertical_flip': a boolean indicating if point cloud is \ - flipped vertically - - 'box_mode_3d': 3D box mode - - 'box_type_3d': 3D box type - - 'img_norm_cfg': a dict of normalization information: - - mean: per channel mean subtraction - - std: per channel std divisor - - to_rgb: bool indicating if bgr was converted to rgb - - 'pcd_trans': point cloud transformations - - 'sample_idx': sample index - - 'pcd_scale_factor': point cloud scale factor - - 'pcd_rotation': rotation applied to point cloud - - 'pts_filename': path to point cloud file. - Args: - keys (Sequence[str]): Keys of results to be collected in ``data``. - meta_keys (Sequence[str], optional): Meta keys to be converted to - ``mmcv.DataContainer`` and collected in ``data[img_metas]``. - Default: ('filename', 'ori_shape', 'img_shape', 'lidar2img', - 'depth2img', 'cam2img', 'pad_shape', 'scale_factor', 'flip', - 'pcd_horizontal_flip', 'pcd_vertical_flip', 'box_mode_3d', - 'box_type_3d', 'img_norm_cfg', 'pcd_trans', - 'sample_idx', 'pcd_scale_factor', 'pcd_rotation', 'pts_filename') - """ - - def __init__(self, - keys, - meta_keys=('filename', 'ori_shape', 'img_shape', 'lidar2img','lidar2cam', - 'depth2img', 'cam2img', 'pad_shape', - 'scale_factor', 'flip', 'pcd_horizontal_flip', - 'pcd_vertical_flip', 'box_mode_3d', 'box_type_3d', - 'img_norm_cfg', 'pcd_trans', 'sample_idx', 'prev_idx', 'next_idx', - 'pcd_scale_factor', 'pcd_rotation', 'pts_filename', - 'transformation_3d_flow', 'scene_token', - 'can_bus', - )): - self.keys = keys - self.meta_keys = meta_keys - - def __call__(self, results): - """Call function to collect keys in results. The keys in ``meta_keys`` - will be converted to :obj:`mmcv.DataContainer`. - Args: - results (dict): Result dict contains the data to collect. - Returns: - dict: The result dict contains the following keys - - keys in ``self.keys`` - - ``img_metas`` - """ - - data = {} - img_metas = {} - - for key in self.meta_keys: - if key in results: - img_metas[key] = results[key] - - data['img_metas'] = DC(img_metas, cpu_only=True) - for key in self.keys: - if key not in results: - data[key] = None - else: - data[key] = results[key] - return data - - def __repr__(self): - """str: Return a string that describes the module.""" - return self.__class__.__name__ + \ - f'(keys={self.keys}, meta_keys={self.meta_keys})' - - - -@PIPELINES.register_module() -class RandomScaleImageMultiViewImage(object): - """Random scale the image - Args: - scales - """ - - def __init__(self, scales=[]): - self.scales = scales - assert len(self.scales)==1 - - def __call__(self, results): - """Call function to pad images, masks, semantic segmentation maps. - Args: - results (dict): Result dict from loading pipeline. - Returns: - dict: Updated result dict. - """ - rand_ind = np.random.permutation(range(len(self.scales)))[0] - rand_scale = self.scales[rand_ind] - - y_size = [int(img.shape[0] * rand_scale) for img in results['img']] - x_size = [int(img.shape[1] * rand_scale) for img in results['img']] - scale_factor = np.eye(4) - scale_factor[0, 0] *= rand_scale - scale_factor[1, 1] *= rand_scale - results['img'] = [mmcv.imresize(img, (x_size[idx], y_size[idx]), return_scale=False) for idx, img in - enumerate(results['img'])] - lidar2img = [scale_factor @ l2i for l2i in results['lidar2img']] - results['lidar2img'] = lidar2img - results['img_shape'] = [img.shape for img in results['img']] - results['ori_shape'] = [img.shape for img in results['img']] - - return results - - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += f'(size={self.scales}, ' - return repr_str \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/__init__.py deleted file mode 100644 index bb2a0b17769a958042583dcb4c8c4a4f51636f4c..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .group_sampler import DistributedGroupSampler -from .distributed_sampler import DistributedSampler -from .sampler import SAMPLER, build_sampler - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py deleted file mode 100644 index 16c59e5f3dd880ba185247acfba6eae354deb771..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py +++ /dev/null @@ -1,110 +0,0 @@ - -# Copyright (c) OpenMMLab. All rights reserved. -import math - -import numpy as np -import torch -from mmcv.runner import get_dist_info -from torch.utils.data import Sampler -from .sampler import SAMPLER -import random -from IPython import embed - - -@SAMPLER.register_module() -class DistributedGroupSampler(Sampler): - """Sampler that restricts data loading to a subset of the dataset. - It is especially useful in conjunction with - :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each - process can pass a DistributedSampler instance as a DataLoader sampler, - and load a subset of the original dataset that is exclusive to it. - .. note:: - Dataset is assumed to be of constant size. - Arguments: - dataset: Dataset used for sampling. - num_replicas (optional): Number of processes participating in - distributed training. - rank (optional): Rank of the current process within num_replicas. - seed (int, optional): random seed used to shuffle the sampler if - ``shuffle=True``. This number should be identical across all - processes in the distributed group. Default: 0. - """ - - def __init__(self, - dataset, - samples_per_gpu=1, - num_replicas=None, - rank=None, - seed=0): - _rank, _num_replicas = get_dist_info() - if num_replicas is None: - num_replicas = _num_replicas - if rank is None: - rank = _rank - self.dataset = dataset - self.samples_per_gpu = samples_per_gpu - self.num_replicas = num_replicas - self.rank = rank - self.epoch = 0 - self.seed = seed if seed is not None else 0 - - assert hasattr(self.dataset, 'flag') - self.flag = self.dataset.flag - self.group_sizes = np.bincount(self.flag) - - self.num_samples = 0 - for i, j in enumerate(self.group_sizes): - self.num_samples += int( - math.ceil(self.group_sizes[i] * 1.0 / self.samples_per_gpu / - self.num_replicas)) * self.samples_per_gpu - self.total_size = self.num_samples * self.num_replicas - - def __iter__(self): - # deterministically shuffle based on epoch - g = torch.Generator() - g.manual_seed(self.epoch + self.seed) - - indices = [] - for i, size in enumerate(self.group_sizes): - if size > 0: - indice = np.where(self.flag == i)[0] - assert len(indice) == size - # add .numpy() to avoid bug when selecting indice in parrots. - # TODO: check whether torch.randperm() can be replaced by - # numpy.random.permutation(). - indice = indice[list( - torch.randperm(int(size), generator=g).numpy())].tolist() - extra = int( - math.ceil( - size * 1.0 / self.samples_per_gpu / self.num_replicas) - ) * self.samples_per_gpu * self.num_replicas - len(indice) - # pad indice - tmp = indice.copy() - for _ in range(extra // size): - indice.extend(tmp) - indice.extend(tmp[:extra % size]) - indices.extend(indice) - - assert len(indices) == self.total_size - - indices = [ - indices[j] for i in list( - torch.randperm( - len(indices) // self.samples_per_gpu, generator=g)) - for j in range(i * self.samples_per_gpu, (i + 1) * - self.samples_per_gpu) - ] - - # subsample - offset = self.num_samples * self.rank - indices = indices[offset:offset + self.num_samples] - assert len(indices) == self.num_samples - - return iter(indices) - - def __len__(self): - return self.num_samples - - def set_epoch(self, epoch): - self.epoch = epoch - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/__init__.py deleted file mode 100644 index 64eaac44f5d69856ac12b411c62bd6022aeb272c..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .modeling import * \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/nuscenes.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/nuscenes.py deleted file mode 100644 index 952795fc9f15fe7e5da8cb33f3946e5aaa89bb8a..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/nuscenes.py +++ /dev/null @@ -1,360 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -#import functools -from collections import OrderedDict - -import numpy as np -import seaborn as sns -from torch.utils.data import Dataset -from tqdm import tqdm - -#from detectron2.data import MetadataCatalog -from detectron2.structures.boxes import BoxMode -from nuscenes.eval.detection.utils import category_to_detection_name -from nuscenes.nuscenes import NuScenes -from nuscenes.utils.splits import create_splits_scenes - -#from tridet.data import collect_dataset_dicts -from projects.mmdet3d_plugin.dd3d.structures.boxes3d import GenericBoxes3D -from projects.mmdet3d_plugin.dd3d.structures.pose import Pose -from projects.mmdet3d_plugin.dd3d.utils.geometry import project_points3d -from projects.mmdet3d_plugin.dd3d.utils.visualization import float_to_uint8_color - -# https://github.com/nutonomy/nuscenes-devkit/blob/9b209638ef3dee6d0cdc5ac700c493747f5b35fe/python-sdk/nuscenes/utils/splits.py#L189 -# - train/val/test: The standard splits of the nuScenes dataset (700/150/150 scenes). -# - mini_train/mini_val: Train and val splits of the mini subset used for visualization and debugging (8/2 scenes). -# - train_detect/train_track: Two halves of the train split used for separating the training sets of detector and -# tracker if required -DATASET_NAME_TO_VERSION = { - "nusc_train": "v1.0-trainval", - "nusc_val": "v1.0-trainval", - "nusc_val-subsample-8": "v1.0-trainval", - "nusc_trainval": "v1.0-trainval", - "nusc_test": "v1.0-test", - "nusc_mini_train": "v1.0-mini", - "nusc_mini_val": "v1.0-mini", -} - -CAMERA_NAMES = ('CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', 'CAM_BACK', 'CAM_BACK_RIGHT') - -ATTRIBUTE_IDS = { - 'vehicle.moving': 0, - 'vehicle.parked': 1, - 'vehicle.stopped': 2, - 'pedestrian.moving': 0, - 'pedestrian.standing': 1, - 'pedestrian.sitting_lying_down': 2, - 'cycle.with_rider': 0, - 'cycle.without_rider': 1, -} - -CATEGORY_IDS = OrderedDict({ - 'barrier': 0, - 'bicycle': 1, - 'bus': 2, - 'car': 3, - 'construction_vehicle': 4, - 'motorcycle': 5, - 'pedestrian': 6, - 'traffic_cone': 7, - 'trailer': 8, - 'truck': 9, -}) - -COLORS = [float_to_uint8_color(clr) for clr in sns.color_palette("bright", n_colors=10)] -COLORMAP = OrderedDict({ - 'barrier': COLORS[8], # yellow - 'bicycle': COLORS[0], # blue - 'bus': COLORS[6], # pink - 'car': COLORS[2], # green - 'construction_vehicle': COLORS[7], # gray - 'motorcycle': COLORS[4], # purple - 'pedestrian': COLORS[1], # orange - 'traffic_cone': COLORS[3], # red - 'trailer': COLORS[9], # skyblue - 'truck': COLORS[5], # brown -}) - -MAX_NUM_ATTRIBUTES = 3 - - -def _compute_iou(box1, box2): - """ - Parameters - ---------- - box1, box2: - (x1, y1, x2, y2) - """ - xx1 = max(box1[0], box2[0]) - yy1 = max(box1[1], box2[1]) - xx2 = min(box1[2], box2[2]) - yy2 = min(box1[3], box2[3]) - if xx1 >= xx2 or yy1 >= yy2: - return 0. - inter = (xx2 - xx1) * (yy2 - yy1) - a1 = (box1[2] - box1[0]) * (box1[3] - box1[1]) - a2 = (box2[2] - box2[0]) * (box2[3] - box2[1]) - return inter / (a1 + a2 - inter) - - -class NuscenesDataset(Dataset): - def __init__(self, name, data_root, datum_names=CAMERA_NAMES, min_num_lidar_points=3, min_box_visibility=0.2, **unused): - self.data_root = data_root - assert name in DATASET_NAME_TO_VERSION - version = DATASET_NAME_TO_VERSION[name] - self.nusc = NuScenes(version=version, dataroot=data_root, verbose=True) - - self.datum_names = datum_names - self.min_num_lidar_points = min_num_lidar_points - self.min_box_visibility = min_box_visibility - - self.dataset_item_info = self._build_dataset_item_info(name) - - # Index instance tokens to their IDs - self._instance_token_to_id = self._index_instance_tokens() - - # Construct the mapping from datum_token (image id) to index - print("Generating the mapping from image id to idx...") - self.datumtoken2idx = {} - for idx, (datum_token, _, _, _, _) in enumerate(self.dataset_item_info): - self.datumtoken2idx[datum_token] = idx - print("Done.") - - def _build_dataset_item_info(self, name): - scenes_in_split = self._get_split_scenes(name) - - dataset_items = [] - for _, scene_token in tqdm(scenes_in_split): - scene = self.nusc.get('scene', scene_token) - sample_token = scene['first_sample_token'] - for sample_idx in range(scene['nbr_samples']): - if name.endswith('subsample-8') and sample_idx % 8 > 0: - # Sample-level subsampling. - continue - - sample = self.nusc.get('sample', sample_token) - for datum_name, datum_token in sample['data'].items(): - if datum_name not in self.datum_names: - continue - dataset_items.append((datum_token, sample_token, scene['name'], sample_idx, datum_name)) - sample_token = sample['next'] - return dataset_items - - def _get_split_scenes(self, name): - scenes_in_splits = create_splits_scenes() - if name == "nusc_trainval": - scenes = scenes_in_splits["train"] + scenes_in_splits["val"] - elif name == "nusc_val-subsample-8": - scenes = scenes_in_splits["val"] - else: - assert name.startswith('nusc_'), f"Invalid dataset name: {name}" - split = name[5:] - assert split in scenes_in_splits, f"Invalid dataset: {split}" - scenes = scenes_in_splits[split] - - # Mapping from scene name to token. - name_to_token = {scene['name']: scene['token'] for scene in self.nusc.scene} - return [(name, name_to_token[name]) for name in scenes] - - def __len__(self): - return len(self.dataset_item_info) - - def _build_id(self, scene_name, sample_idx, datum_name): - sample_id = f"{scene_name}_{sample_idx:03d}" - image_id = f"{sample_id}_{datum_name}" - return image_id, sample_id - - def _index_instance_tokens(self): - """Index instance tokens for uniquely identifying instances across samples""" - instance_token_to_id = {} - for record in self.nusc.sample_annotation: - instance_token = record['instance_token'] - if instance_token not in instance_token_to_id: - next_instance_id = len(instance_token_to_id) - instance_token_to_id[instance_token] = next_instance_id - return instance_token_to_id - - def get_instance_annotations(self, annotation_list, K, image_shape, pose_WS): - annotations = [] - for _ann in annotation_list: - ann = self.nusc.get('sample_annotation', _ann.token) - if ann['num_lidar_pts'] + ann['num_radar_pts'] < self.min_num_lidar_points: - continue - annotation = OrderedDict() - - # -------- - # Category - # -------- - category = category_to_detection_name(ann['category_name']) - if category is None: - continue - annotation['category_id'] = CATEGORY_IDS[category] - - # ------ - # 3D box - # ------ - # NOTE: ann['rotation'], ann['translation'] is in global frame. - pose_SO = Pose(wxyz=_ann.orientation, tvec=_ann.center) # pose in sensor frame - # DEBUG: - # pose_WO_1 = Pose(np.array(ann['rotation']), np.array(ann['translation'])) - # pose_WO_2 = pose_WS * pose_SO - # assert np.allclose(pose_WO_1.matrix, pose_WO_2.matrix) - bbox3d = GenericBoxes3D(_ann.orientation, _ann.center, _ann.wlh) - annotation['bbox3d'] = bbox3d.vectorize().tolist()[0] - - # -------------------------------------- - # 2D box -- project 8 corners of 3D bbox - # -------------------------------------- - corners = project_points3d(bbox3d.corners.cpu().numpy().squeeze(0), K) - l, t = corners[:, 0].min(), corners[:, 1].min() - r, b = corners[:, 0].max(), corners[:, 1].max() - - x1 = max(0, l) - y1 = max(0, t) - x2 = min(image_shape[1], r) - y2 = min(image_shape[0], b) - - iou = _compute_iou([l, t, r, b], [x1, y1, x2, y2]) - if iou < self.min_box_visibility: - continue - - annotation['bbox'] = [x1, y1, x2, y2] - annotation['bbox_mode'] = BoxMode.XYXY_ABS - - # -------- - # Track ID - # -------- - annotation['track_id'] = self._instance_token_to_id[ann['instance_token']] - - # --------- - # Attribute - # --------- - attr_tokens = ann['attribute_tokens'] - assert len(attr_tokens) < 2 # NOTE: Allow only single attrubute. - attribute_id = MAX_NUM_ATTRIBUTES # By default, MAX_NUM_ATTRIBUTES -- this is to be ignored in loss compute. - if attr_tokens: - attribute = self.nusc.get('attribute', attr_tokens[0])['name'] - attribute_id = ATTRIBUTE_IDS[attribute] - annotation['attribute_id'] = attribute_id - - # ----- - # Speed - # ----- - vel_global = self.nusc.box_velocity(ann['token']) - speed = np.linalg.norm(vel_global) # NOTE: This can be NaN. - # DEBUG: - # speed * Quaternion(ann['rotation']).rotation_matrix.T[0] ~= vel_global - annotation['speed'] = speed - - annotations.append(annotation) - - return annotations - - def _get_ego_velocity(self, current, max_time_diff=1.5): - """Velocity of ego-vehicle in m/s. - """ - has_prev = current['prev'] != '' - has_next = current['next'] != '' - - # Cannot estimate velocity for a single annotation. - if not has_prev and not has_next: - return np.array([np.nan, np.nan, np.nan]) - - if has_prev: - first = self.nusc.get('sample_data', current['prev']) - else: - first = current - - if has_next: - last = self.nusc.get('sample_data', current['next']) - else: - last = current - - pos_first = self.nusc.get('ego_pose', first['ego_pose_token'])['translation'] - pos_last = self.nusc.get('ego_pose', last['ego_pose_token'])['translation'] - pos_diff = np.float32(pos_last) - np.float32(pos_first) - - time_last = 1e-6 * last['timestamp'] - time_first = 1e-6 * first['timestamp'] - time_diff = time_last - time_first - - if has_next and has_prev: - # If doing centered difference, allow for up to double the max_time_diff. - max_time_diff *= 2 - - if time_diff > max_time_diff: - # If time_diff is too big, don't return an estimate. - return np.array([np.nan, np.nan, np.nan]) - else: - return pos_diff / time_diff - - def __getitem__(self, idx): - datum_token, sample_token, scene_name, sample_idx, datum_name = self.dataset_item_info[idx] - datum = self.nusc.get('sample_data', datum_token) - assert datum['is_key_frame'] - - filename, _annotations, K = self.nusc.get_sample_data(datum_token) - image_id, sample_id = self._build_id(scene_name, sample_idx, datum_name) - height, width = datum['height'], datum['width'] - d2_dict = OrderedDict( - file_name=filename, - height=height, - width=width, - image_id=image_id, - sample_id=sample_id, - sample_token=sample_token - ) - - # Intrinsics - d2_dict['intrinsics'] = list(K.flatten()) - - # Get pose of the sensor (S) from vehicle (V) frame - _pose_VS = self.nusc.get('calibrated_sensor', datum['calibrated_sensor_token']) - pose_VS = Pose(wxyz=np.float64(_pose_VS['rotation']), tvec=np.float64(_pose_VS['translation'])) - - # Get ego-pose of the vehicle (V) from global/world (W) frame - _pose_WV = self.nusc.get('ego_pose', datum['ego_pose_token']) - pose_WV = Pose(wxyz=np.float64(_pose_WV['rotation']), tvec=np.float64(_pose_WV['translation'])) - pose_WS = pose_WV * pose_VS - - d2_dict['pose'] = {'wxyz': list(pose_WS.quat.elements), 'tvec': list(pose_WS.tvec)} - d2_dict['extrinsics'] = {'wxyz': list(pose_VS.quat.elements), 'tvec': list(pose_VS.tvec)} - - d2_dict['ego_speed'] = np.linalg.norm(self._get_ego_velocity(datum)) - - d2_dict['annotations'] = self.get_instance_annotations(_annotations, K, (height, width), pose_WS) - - return d2_dict - - def getitem_by_datumtoken(self, datum_token): - # idx = self.datumtoken2idx[datum_token] - # ret = self.__getitem__(idx) - - datum = self.nusc.get('sample_data', datum_token) - sample_token = datum['sample_token'] - filename, _annotations, K = self.nusc.get_sample_data(datum_token) - height, width = datum['height'], datum['width'] - d2_dict = OrderedDict( - file_name=filename, - height=height, - width=width, - image_id=0, - sample_id=0, - sample_token=sample_token - ) - # Intrinsics - d2_dict['intrinsics'] = list(K.flatten()) - # Get pose of the sensor (S) from vehicle (V) frame - _pose_VS = self.nusc.get('calibrated_sensor', datum['calibrated_sensor_token']) - pose_VS = Pose(wxyz=np.float64(_pose_VS['rotation']), tvec=np.float64(_pose_VS['translation'])) - # Get ego-pose of the vehicle (V) from global/world (W) frame - _pose_WV = self.nusc.get('ego_pose', datum['ego_pose_token']) - pose_WV = Pose(wxyz=np.float64(_pose_WV['rotation']), tvec=np.float64(_pose_WV['translation'])) - pose_WS = pose_WV * pose_VS - - d2_dict['pose'] = {'wxyz': list(pose_WS.quat.elements), 'tvec': list(pose_WS.tvec)} - d2_dict['extrinsics'] = {'wxyz': list(pose_VS.quat.elements), 'tvec': list(pose_VS.tvec)} - - d2_dict['ego_speed'] = np.linalg.norm(self._get_ego_velocity(datum)) - - d2_dict['annotations'] = self.get_instance_annotations(_annotations, K, (height, width), pose_WS) - return d2_dict \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/transform_utils.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/transform_utils.py deleted file mode 100644 index 623bd6e8f8cf1e6cf5d5af18b0048d7b29d37a64..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/datasets/transform_utils.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -# Copyright 2021 Toyota Research Institute. All rights reserved. -# Adapted from detectron2: -# https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/detection_utils.py -import numpy as np -import torch - -from detectron2.data import transforms as T -from detectron2.structures import Boxes, BoxMode, Instances - -from projects.mmdet3d_plugin.dd3d.structures.boxes3d import Boxes3D - -__all__ = ["transform_instance_annotations", "annotations_to_instances"] - - -def transform_instance_annotations( - annotation, - transforms, - image_size, -): - """Adapted from: - https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/detection_utils.py#L254 - - The changes from original: - - The presence of 2D bounding box (i.e. "bbox" field) is assumed by default in d2; here it's optional. - - Add optional 3D bounding box support. - - If the instance mask annotation is in RLE, then it's decoded into polygons, not bitmask, to save memory. - - =============================================================================================================== - - Apply transforms to box, segmentation and keypoints annotations of a single instance. - - It will use `transforms.apply_box` for the box, and - `transforms.apply_coords` for segmentation polygons & keypoints. - If you need anything more specially designed for each data structure, - you'll need to implement your own version of this function or the transforms. - - Args: - annotation (dict): dict of instance annotations for a single instance. - It will be modified in-place. - transforms (TransformList or list[Transform]): - image_size (tuple): the height, width of the transformed image - keypoint_hflip_indices (ndarray[int]): see `create_keypoint_hflip_indices`. - - Returns: - dict: - the same input dict with fields "bbox", "segmentation", "keypoints" - transformed according to `transforms`. - The "bbox_mode" field will be set to XYXY_ABS. - """ - if isinstance(transforms, (tuple, list)): - transforms = T.TransformList(transforms) - # (dennis.park) Here 2D bounding box is optional. - if "bbox" in annotation: - assert "bbox_mode" in annotation, "'bbox' is present, but 'bbox_mode' is not." - # bbox is 1d (per-instance bounding box) - bbox = BoxMode.convert(annotation["bbox"], annotation["bbox_mode"], BoxMode.XYXY_ABS) - bbox = transforms.apply_box(np.array([bbox]))[0] - # clip transformed bbox to image size - bbox = bbox.clip(min=0) - bbox = np.minimum(bbox, list(image_size + image_size)[::-1]) - annotation["bbox"] = bbox - annotation["bbox_mode"] = BoxMode.XYXY_ABS - - # Vertical flipping is not implemented (`flip_transform.py`). TODO: implement if needed. - if "bbox3d" in annotation: - bbox3d = np.array(annotation["bbox3d"]) - annotation['bbox3d'] = transforms.apply_box3d(bbox3d) - - return annotation - - -def _create_empty_instances(image_size): - target = Instances(image_size) - - target.gt_boxes = Boxes([]) - target.gt_classes = torch.tensor([], dtype=torch.int64) - target.gt_boxes3d = Boxes3D.from_vectors([], torch.eye(3, dtype=torch.float32)) - - return target - - -def annotations_to_instances( - annos, - image_size, - intrinsics=None, -): - """ - Create an :class:`Instances` object used by the models, - from instance annotations in the dataset dict. - - Args: - annos (list[dict]): a list of instance annotations in one image, each - element for one instance. - image_size (tuple): height, width - - Returns: - Instances: - It will contain fields "gt_boxes", "gt_classes", - "gt_masks", "gt_keypoints", if they can be obtained from `annos`. - This is the format that builtin models expect. - """ - if len(annos) == 0: - return _create_empty_instances(image_size) - - boxes = [BoxMode.convert(obj["bbox"], obj["bbox_mode"], BoxMode.XYXY_ABS) for obj in annos] - target = Instances(image_size) - target.gt_boxes = Boxes(boxes) - - classes = [obj["category_id"] for obj in annos] - classes = torch.tensor(classes, dtype=torch.int64) - target.gt_classes = classes - - if len(annos) and "bbox3d" in annos[0]: - assert intrinsics is not None - target.gt_boxes3d = Boxes3D.from_vectors([anno['bbox3d'] for anno in annos], intrinsics) - if len(target.gt_boxes3d) != target.gt_boxes.tensor.shape[0]: - raise ValueError( - f"The sizes of `gt_boxes3d` and `gt_boxes` do not match: a={len(target.gt_boxes3d)}, b={target.gt_boxes.tensor.shape[0]}." - ) - - # NOTE: add nuscenes attributes here - # NOTE: instances will be filtered later - # NuScenes attributes - if len(annos) and "attribute_id" in annos[0]: - attributes = [obj["attribute_id"] for obj in annos] - target.gt_attributes = torch.tensor(attributes, dtype=torch.int64) - - # Speed (magnitude of velocity) - if len(annos) and "speed" in annos[0]: - speeds = [obj["speed"] for obj in annos] - target.gt_speeds = torch.tensor(speeds, dtype=torch.float32) - - assert len(boxes) == len(classes) == len(attributes) == len(speeds), \ - 'the numbers of annotations should be the same' - return target diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/__init__.py deleted file mode 100644 index dd76a6155108b205b1c93720e1f6365db1d46b3f..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .nuscenes_dd3d import NuscenesDD3D \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/core.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/core.py deleted file mode 100644 index 34608becdde05c8f527d169a9da4cdfb913f8465..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/core.py +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -import torch -from torch import nn - -#from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY -from detectron2.modeling.postprocessing import detector_postprocess as resize_instances -from detectron2.structures import Instances -from detectron2.layers import ShapeSpec -from mmcv.runner import force_fp32 - -from .fcos2d import FCOS2DHead, FCOS2DInference, FCOS2DLoss -from .fcos3d import FCOS3DHead, FCOS3DInference, FCOS3DLoss -#from tridet.modeling.dd3d.postprocessing import nuscenes_sample_aggregate -from .prepare_targets import DD3DTargetPreparer -#from tridet.modeling.feature_extractor import build_feature_extractor -from projects.mmdet3d_plugin.dd3d.structures.image_list import ImageList -from projects.mmdet3d_plugin.dd3d.utils.tensor2d import compute_features_locations as compute_locations_per_level - - -#@META_ARCH_REGISTRY.register() -class DD3D(nn.Module): - def __init__(self, - num_classes, - in_channels, - strides, - fcos2d_cfg=dict(), - fcos2d_loss_cfg=dict(), - fcos3d_cfg=dict(), - fcos3d_loss_cfg=dict(), - target_assign_cfg=dict(), - box3d_on=True, - feature_locations_offset="none"): - super().__init__() - # NOTE: do not need backbone - # self.backbone = build_feature_extractor(cfg) - # backbone_output_shape = self.backbone.output_shape() - # self.in_features = cfg.DD3D.IN_FEATURES or list(backbone_output_shape.keys()) - - self.backbone_output_shape = [ShapeSpec(channels=in_channels, stride=s) for s in strides] - - self.feature_locations_offset = feature_locations_offset - - self.fcos2d_head = FCOS2DHead(num_classes=num_classes, input_shape=self.backbone_output_shape, - **fcos2d_cfg) - self.fcos2d_loss = FCOS2DLoss(num_classes=num_classes, **fcos2d_loss_cfg) - # NOTE: inference later - # self.fcos2d_inference = FCOS2DInference(cfg) - - if box3d_on: - self.fcos3d_head = FCOS3DHead(num_classes=num_classes, input_shape=self.backbone_output_shape, - **fcos3d_cfg) - self.fcos3d_loss = FCOS3DLoss(num_classes=num_classes, **fcos3d_loss_cfg) - # NOTE: inference later - # self.fcos3d_inference = FCOS3DInference(cfg) - self.only_box2d = False - else: - self.only_box2d = True - - self.prepare_targets = DD3DTargetPreparer(num_classes=num_classes, - input_shape=self.backbone_output_shape, - box3d_on=box3d_on, - **target_assign_cfg) - - # NOTE: inference later - # self.postprocess_in_inference = cfg.DD3D.INFERENCE.DO_POSTPROCESS - - # self.do_nms = cfg.DD3D.INFERENCE.DO_NMS - # self.do_bev_nms = cfg.DD3D.INFERENCE.DO_BEV_NMS - # self.bev_nms_iou_thresh = cfg.DD3D.INFERENCE.BEV_NMS_IOU_THRESH - - # nuScenes inference aggregates detections over all 6 cameras. - # self.nusc_sample_aggregate_in_inference = cfg.DD3D.INFERENCE.NUSC_SAMPLE_AGGREGATE - self.num_classes = num_classes - - # NOTE: do not need normalize - # self.register_buffer("pixel_mean", torch.Tensor(cfg.MODEL.PIXEL_MEAN).view(-1, 1, 1)) - # self.register_buffer("pixel_std", torch.Tensor(cfg.MODEL.PIXEL_STD).view(-1, 1, 1)) - - # NOTE: - # @property - # def device(self): - # return self.pixel_mean.device - - # def preprocess_image(self, x): - # return (x - self.pixel_mean) / self.pixel_std - - @force_fp32(apply_to=('features')) - def forward(self, features, batched_inputs): - # NOTE: - # images = [x["image"].to(self.device) for x in batched_inputs] - # images = [self.preprocess_image(x) for x in images] - - # NOTE: directly use inv_intrinsics - # if 'intrinsics' in batched_inputs[0]: - # intrinsics = [x['intrinsics'].to(self.device) for x in batched_inputs] - # else: - # intrinsics = None - # images = ImageList.from_tensors(images, self.backbone.size_divisibility, intrinsics=intrinsics) - if 'inv_intrinsics' in batched_inputs[0]: - inv_intrinsics = [x['inv_intrinsics'].to(features[0].device) for x in batched_inputs] - inv_intrinsics = torch.stack(inv_intrinsics, dim=0) - else: - inv_intrinsics = None - - # NOTE: - # gt_dense_depth = None - # if 'depth' in batched_inputs[0]: - # gt_dense_depth = [x["depth"].to(self.device) for x in batched_inputs] - # gt_dense_depth = ImageList.from_tensors( - # gt_dense_depth, self.backbone.size_divisibility, intrinsics=intrinsics - # ) - - # NOTE: directly input feature - # features = self.backbone(images.tensor) - # features = [features[f] for f in self.in_features] - - if "instances" in batched_inputs[0]: - gt_instances = [x["instances"].to(features[0].device) for x in batched_inputs] - else: - gt_instances = None - - locations = self.compute_locations(features) - logits, box2d_reg, centerness, _ = self.fcos2d_head(features) - if not self.only_box2d: - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth = self.fcos3d_head(features) - # NOTE: directly use inv_intrinsics - # inv_intrinsics = images.intrinsics.inverse() if images.intrinsics is not None else None - - if self.training: - assert gt_instances is not None - feature_shapes = [x.shape[-2:] for x in features] - training_targets = self.prepare_targets(locations, gt_instances, feature_shapes) - # NOTE: - # if gt_dense_depth is not None: - # training_targets.update({"dense_depth": gt_dense_depth}) - - losses = {} - fcos2d_loss, fcos2d_info = self.fcos2d_loss(logits, box2d_reg, centerness, training_targets) - losses.update(fcos2d_loss) - - if not self.only_box2d: - fcos3d_loss = self.fcos3d_loss( - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth, inv_intrinsics, - fcos2d_info, training_targets - ) - losses.update(fcos3d_loss) - return losses - else: - # TODO: do not support inference now - raise NotImplementedError - - pred_instances, fcos2d_info = self.fcos2d_inference( - logits, box2d_reg, centerness, locations, images.image_sizes - ) - if not self.only_box2d: - # This adds 'pred_boxes3d' and 'scores_3d' to Instances in 'pred_instances' in place. - self.fcos3d_inference( - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, inv_intrinsics, pred_instances, - fcos2d_info - ) - - # 3D score == 2D score x confidence. - score_key = "scores_3d" - else: - score_key = "scores" - - # Transpose to "image-first", i.e. (B, L) - pred_instances = list(zip(*pred_instances)) - pred_instances = [Instances.cat(instances) for instances in pred_instances] - - # 2D NMS and pick top-K. - if self.do_nms: - pred_instances = self.fcos2d_inference.nms_and_top_k(pred_instances, score_key) - - if not self.only_box2d and self.do_bev_nms: - # Bird-eye-view NMS. - dummy_group_idxs = {i: [i] for i, _ in enumerate(pred_instances)} - if 'pose' in batched_inputs[0]: - poses = [x['pose'] for x in batched_inputs] - else: - poses = [x['extrinsics'] for x in batched_inputs] - pred_instances = nuscenes_sample_aggregate( - pred_instances, - dummy_group_idxs, - self.num_classes, - poses, - iou_threshold=self.bev_nms_iou_thresh, - include_boxes3d_global=False - ) - - if self.postprocess_in_inference: - processed_results = [] - for results_per_image, input_per_image, image_size in \ - zip(pred_instances, batched_inputs, images.image_sizes): - height = input_per_image.get("height", image_size[0]) - width = input_per_image.get("width", image_size[1]) - r = resize_instances(results_per_image, height, width) - processed_results.append({"instances": r}) - else: - processed_results = [{"instances": x} for x in pred_instances] - - return processed_results - - def compute_locations(self, features): - locations = [] - in_strides = [x.stride for x in self.backbone_output_shape] - for level, feature in enumerate(features): - h, w = feature.size()[-2:] - locations_per_level = compute_locations_per_level( - h, w, in_strides[level], feature.dtype, feature.device, offset=self.feature_locations_offset - ) - locations.append(locations_per_level) - return locations - - def forward_train(self, features, batched_inputs): - self.train() - return self.forward(features, batched_inputs) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos2d.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos2d.py deleted file mode 100644 index 059b8804acb8c1af97684dcd32a37c118803fcdf..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos2d.py +++ /dev/null @@ -1,382 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -# Adapted from AdelaiDet: -# https://github.com/aim-uofa/AdelaiDet -import torch -from fvcore.nn import sigmoid_focal_loss -from torch import nn -from torch.nn import functional as F - -from detectron2.layers import Conv2d, batched_nms, cat, get_norm -from detectron2.structures import Boxes, Instances -from detectron2.utils.comm import get_world_size -from mmcv.runner import force_fp32 - -from projects.mmdet3d_plugin.dd3d.layers.iou_loss import IOULoss -from projects.mmdet3d_plugin.dd3d.layers.normalization import ModuleListDial, Scale -from projects.mmdet3d_plugin.dd3d.utils.comm import reduce_sum - -INF = 100000000 - - -def compute_ctrness_targets(reg_targets): - if len(reg_targets) == 0: - return reg_targets.new_zeros(len(reg_targets)) - left_right = reg_targets[:, [0, 2]] - top_bottom = reg_targets[:, [1, 3]] - ctrness = (left_right.min(dim=-1)[0] / left_right.max(dim=-1)[0]) * \ - (top_bottom.min(dim=-1)[0] / top_bottom.max(dim=-1)[0]) - return torch.sqrt(ctrness) - - -class FCOS2DHead(nn.Module): - def __init__(self, - num_classes, - input_shape, - num_cls_convs=4, - num_box_convs=4, - norm='BN', - use_deformable=False, - use_scale=True, - box2d_scale_init_factor=1.0, - version='v2'): - super().__init__() - - self.num_classes = num_classes - self.in_strides = [shape.stride for shape in input_shape] - self.num_levels = len(input_shape) - - self.use_scale = use_scale - self.box2d_scale_init_factor = box2d_scale_init_factor - - self._version = version - - in_channels = [s.channels for s in input_shape] - assert len(set(in_channels)) == 1, "Each level must have the same channel!" - in_channels = in_channels[0] - - if use_deformable: - raise ValueError("Not supported yet.") - - head_configs = {'cls': num_cls_convs, 'box2d': num_box_convs} - - for head_name, num_convs in head_configs.items(): - tower = [] - if self._version == "v1": - for _ in range(num_convs): - conv_func = nn.Conv2d - tower.append(conv_func(in_channels, in_channels, kernel_size=3, stride=1, padding=1, bias=True)) - if norm == "GN": - raise NotImplementedError() - elif norm == "NaiveGN": - raise NotImplementedError() - elif norm == "BN": - tower.append(ModuleListDial([nn.BatchNorm2d(in_channels) for _ in range(self.num_levels)])) - elif norm == "SyncBN": - raise NotImplementedError() - tower.append(nn.ReLU()) - elif self._version == "v2": - for _ in range(num_convs): - if norm in ("BN", "FrozenBN", "SyncBN", "GN"): - # NOTE: need to add norm here! - # Each FPN level has its own batchnorm layer. - # NOTE: do not use dd3d train.py! - # "BN" is converted to "SyncBN" in distributed training (see train.py) - norm_layer = ModuleListDial([get_norm(norm, in_channels) for _ in range(self.num_levels)]) - else: - norm_layer = get_norm(norm, in_channels) - tower.append( - Conv2d( - in_channels, - in_channels, - kernel_size=3, - stride=1, - padding=1, - bias=norm_layer is None, - norm=norm_layer, - activation=F.relu - ) - ) - else: - raise ValueError(f"Invalid FCOS2D version: {self._version}") - self.add_module(f'{head_name}_tower', nn.Sequential(*tower)) - - self.cls_logits = nn.Conv2d(in_channels, self.num_classes, kernel_size=3, stride=1, padding=1) - self.box2d_reg = nn.Conv2d(in_channels, 4, kernel_size=3, stride=1, padding=1) - self.centerness = nn.Conv2d(in_channels, 1, kernel_size=3, stride=1, padding=1) - - if self.use_scale: - if self._version == "v1": - self.scales_reg = nn.ModuleList([ - Scale(init_value=stride * self.box2d_scale_init_factor) for stride in self.in_strides - ]) - else: - self.scales_box2d_reg = nn.ModuleList([ - Scale(init_value=stride * self.box2d_scale_init_factor) for stride in self.in_strides - ]) - - self.init_weights() - - def init_weights(self): - - for tower in [self.cls_tower, self.box2d_tower]: - for l in tower.modules(): - if isinstance(l, nn.Conv2d): - torch.nn.init.kaiming_normal_(l.weight, mode='fan_out', nonlinearity='relu') - if l.bias is not None: - torch.nn.init.constant_(l.bias, 0) - - predictors = [self.cls_logits, self.box2d_reg, self.centerness] - - for modules in predictors: - for l in modules.modules(): - if isinstance(l, nn.Conv2d): - torch.nn.init.kaiming_uniform_(l.weight, a=1) - if l.bias is not None: # depth head may not have bias. - torch.nn.init.constant_(l.bias, 0) - - def forward(self, x): - logits = [] - box2d_reg = [] - centerness = [] - - extra_output = {"cls_tower_out": []} - - for l, feature in enumerate(x): - cls_tower_out = self.cls_tower(feature) - bbox_tower_out = self.box2d_tower(feature) - - # 2D box - logits.append(self.cls_logits(cls_tower_out)) - centerness.append(self.centerness(bbox_tower_out)) - box_reg = self.box2d_reg(bbox_tower_out) - if self.use_scale: - # TODO: to optimize the runtime, apply this scaling in inference (and loss compute) only on FG pixels? - if self._version == "v1": - box_reg = self.scales_reg[l](box_reg) - else: - box_reg = self.scales_box2d_reg[l](box_reg) - # Note that we use relu, as in the improved FCOS, instead of exp. - box2d_reg.append(F.relu(box_reg)) - - extra_output['cls_tower_out'].append(cls_tower_out) - - return logits, box2d_reg, centerness, extra_output - - -class FCOS2DLoss(nn.Module): - def __init__(self, - num_classes, - focal_loss_alpha=0.25, - focal_loss_gamma=2.0, - loc_loss_type='giou', - ): - super().__init__() - self.focal_loss_alpha = focal_loss_alpha - self.focal_loss_gamma = focal_loss_gamma - - self.box2d_reg_loss_fn = IOULoss(loc_loss_type) - - self.num_classes = num_classes - - @force_fp32(apply_to=('logits', 'box2d_reg', 'centerness')) - def forward(self, logits, box2d_reg, centerness, targets): - labels = targets['labels'] - box2d_reg_targets = targets['box2d_reg_targets'] - pos_inds = targets["pos_inds"] - - if len(labels) != box2d_reg_targets.shape[0]: - raise ValueError( - f"The size of 'labels' and 'box2d_reg_targets' does not match: a={len(labels)}, b={box2d_reg_targets.shape[0]}" - ) - - # Flatten predictions - logits = cat([x.permute(0, 2, 3, 1).reshape(-1, self.num_classes) for x in logits]) - box2d_reg_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, 4) for x in box2d_reg]) - centerness_pred = cat([x.permute(0, 2, 3, 1).reshape(-1) for x in centerness]) - - # ------------------- - # Classification loss - # ------------------- - num_pos_local = pos_inds.numel() - num_gpus = get_world_size() - total_num_pos = reduce_sum(pos_inds.new_tensor([num_pos_local])).item() - num_pos_avg = max(total_num_pos / num_gpus, 1.0) - - # prepare one_hot - cls_target = torch.zeros_like(logits) - cls_target[pos_inds, labels[pos_inds]] = 1 - - loss_cls = sigmoid_focal_loss( - logits, - cls_target, - alpha=self.focal_loss_alpha, - gamma=self.focal_loss_gamma, - reduction="sum", - ) / num_pos_avg - - # NOTE: The rest of losses only consider foreground pixels. - box2d_reg_pred = box2d_reg_pred[pos_inds] - box2d_reg_targets = box2d_reg_targets[pos_inds] - - centerness_pred = centerness_pred[pos_inds] - - # Compute centerness targets here using 2D regression targets of foreground pixels. - centerness_targets = compute_ctrness_targets(box2d_reg_targets) - - # Denominator for all foreground losses. - ctrness_targets_sum = centerness_targets.sum() - loss_denom = max(reduce_sum(ctrness_targets_sum).item() / num_gpus, 1e-6) - - # NOTE: change the return after reduce_sum - if pos_inds.numel() == 0: - losses = { - "loss_cls": loss_cls, - "loss_box2d_reg": box2d_reg_pred.sum() * 0., - "loss_centerness": centerness_pred.sum() * 0., - } - return losses, {} - - # ---------------------- - # 2D box regression loss - # ---------------------- - loss_box2d_reg = self.box2d_reg_loss_fn(box2d_reg_pred, box2d_reg_targets, centerness_targets) / loss_denom - - # --------------- - # Centerness loss - # --------------- - loss_centerness = F.binary_cross_entropy_with_logits( - centerness_pred, centerness_targets, reduction="sum" - ) / num_pos_avg - - loss_dict = {"loss_cls": loss_cls, "loss_box2d_reg": loss_box2d_reg, "loss_centerness": loss_centerness} - extra_info = {"loss_denom": loss_denom, "centerness_targets": centerness_targets} - - return loss_dict, extra_info - - -class FCOS2DInference(): - def __init__(self, cfg): - self.thresh_with_ctr = cfg.DD3D.FCOS2D.INFERENCE.THRESH_WITH_CTR - self.pre_nms_thresh = cfg.DD3D.FCOS2D.INFERENCE.PRE_NMS_THRESH - self.pre_nms_topk = cfg.DD3D.FCOS2D.INFERENCE.PRE_NMS_TOPK - self.post_nms_topk = cfg.DD3D.FCOS2D.INFERENCE.POST_NMS_TOPK - self.nms_thresh = cfg.DD3D.FCOS2D.INFERENCE.NMS_THRESH - self.num_classes = cfg.DD3D.NUM_CLASSES - - def __call__(self, logits, box2d_reg, centerness, locations, image_sizes): - - pred_instances = [] # List[List[Instances]], shape = (L, B) - extra_info = [] - for lvl, (logits_lvl, box2d_reg_lvl, centerness_lvl, locations_lvl) in \ - enumerate(zip(logits, box2d_reg, centerness, locations)): - - instances_per_lvl, extra_info_per_lvl = self.forward_for_single_feature_map( - logits_lvl, box2d_reg_lvl, centerness_lvl, locations_lvl, image_sizes - ) # List of Instances; one for each image. - - for instances_per_im in instances_per_lvl: - instances_per_im.fpn_levels = locations_lvl.new_ones(len(instances_per_im), dtype=torch.long) * lvl - - pred_instances.append(instances_per_lvl) - extra_info.append(extra_info_per_lvl) - - return pred_instances, extra_info - - def forward_for_single_feature_map(self, logits, box2d_reg, centerness, locations, image_sizes): - N, C, _, __ = logits.shape - - # put in the same format as locations - scores = logits.permute(0, 2, 3, 1).reshape(N, -1, C).sigmoid() - box2d_reg = box2d_reg.permute(0, 2, 3, 1).reshape(N, -1, 4) - centerness = centerness.permute(0, 2, 3, 1).reshape(N, -1).sigmoid() - - # if self.thresh_with_ctr is True, we multiply the classification - # scores with centerness scores before applying the threshold. - if self.thresh_with_ctr: - scores = scores * centerness[:, :, None] - - candidate_mask = scores > self.pre_nms_thresh - - pre_nms_topk = candidate_mask.reshape(N, -1).sum(1) - pre_nms_topk = pre_nms_topk.clamp(max=self.pre_nms_topk) - - if not self.thresh_with_ctr: - scores = scores * centerness[:, :, None] - - results = [] - all_fg_inds_per_im, all_topk_indices, all_class_inds_per_im = [], [], [] - for i in range(N): - scores_per_im = scores[i] - candidate_mask_per_im = candidate_mask[i] - scores_per_im = scores_per_im[candidate_mask_per_im] - - candidate_inds_per_im = candidate_mask_per_im.nonzero(as_tuple=False) - fg_inds_per_im = candidate_inds_per_im[:, 0] - class_inds_per_im = candidate_inds_per_im[:, 1] - - # Cache info here. - all_fg_inds_per_im.append(fg_inds_per_im) - all_class_inds_per_im.append(class_inds_per_im) - - box2d_reg_per_im = box2d_reg[i][fg_inds_per_im] - locations_per_im = locations[fg_inds_per_im] - - pre_nms_topk_per_im = pre_nms_topk[i] - - if candidate_mask_per_im.sum().item() > pre_nms_topk_per_im.item(): - scores_per_im, topk_indices = \ - scores_per_im.topk(pre_nms_topk_per_im, sorted=False) - - class_inds_per_im = class_inds_per_im[topk_indices] - box2d_reg_per_im = box2d_reg_per_im[topk_indices] - locations_per_im = locations_per_im[topk_indices] - else: - topk_indices = None - - all_topk_indices.append(topk_indices) - - detections = torch.stack([ - locations_per_im[:, 0] - box2d_reg_per_im[:, 0], - locations_per_im[:, 1] - box2d_reg_per_im[:, 1], - locations_per_im[:, 0] + box2d_reg_per_im[:, 2], - locations_per_im[:, 1] + box2d_reg_per_im[:, 3], - ], - dim=1) - - instances = Instances(image_sizes[i]) - instances.pred_boxes = Boxes(detections) - instances.scores = torch.sqrt(scores_per_im) - instances.pred_classes = class_inds_per_im - instances.locations = locations_per_im - - results.append(instances) - - extra_info = { - "fg_inds_per_im": all_fg_inds_per_im, - "class_inds_per_im": all_class_inds_per_im, - "topk_indices": all_topk_indices - } - return results, extra_info - - def nms_and_top_k(self, instances_per_im, score_key_for_nms="scores"): - results = [] - for instances in instances_per_im: - if self.nms_thresh > 0: - # Multiclass NMS. - keep = batched_nms( - instances.pred_boxes.tensor, instances.get(score_key_for_nms), instances.pred_classes, - self.nms_thresh - ) - instances = instances[keep] - num_detections = len(instances) - - # Limit to max_per_image detections **over all classes** - if num_detections > self.post_nms_topk > 0: - scores = instances.scores - # image_thresh, _ = torch.kthvalue(scores.cpu(), num_detections - self.post_nms_topk + 1) - image_thresh, _ = torch.kthvalue(scores, num_detections - self.post_nms_topk + 1) - keep = scores >= image_thresh.item() - keep = torch.nonzero(keep).squeeze(1) - instances = instances[keep] - results.append(instances) - return results diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos3d.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos3d.py deleted file mode 100644 index 08c187d02818d53553f9fbb60f7cf6600de8ce6f..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/fcos3d.py +++ /dev/null @@ -1,427 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -import torch -import torch.nn.functional as F -from torch import nn - -from detectron2.layers import Conv2d, cat, get_norm -from mmcv.runner import force_fp32 - -from projects.mmdet3d_plugin.dd3d.layers.normalization import ModuleListDial, Offset, Scale -from .disentangled_box3d_loss import DisentangledBox3DLoss -from projects.mmdet3d_plugin.dd3d.structures.boxes3d import Boxes3D -from projects.mmdet3d_plugin.dd3d.utils.geometry import allocentric_to_egocentric, unproject_points2d - -EPS = 1e-7 - - -def predictions_to_boxes3d( - quat, - proj_ctr, - depth, - size, - locations, - inv_intrinsics, - canon_box_sizes, - min_depth, - max_depth, - scale_depth_by_focal_lengths_factor, - scale_depth_by_focal_lengths=True, - quat_is_allocentric=True, - depth_is_distance=False -): - # Normalize to make quat unit norm. - quat = quat / quat.norm(dim=1, keepdim=True).clamp(min=EPS) - # Make sure again it's numerically unit-norm. - quat = quat / quat.norm(dim=1, keepdim=True) - - if scale_depth_by_focal_lengths: - pixel_size = torch.norm(torch.stack([inv_intrinsics[:, 0, 0], inv_intrinsics[:, 1, 1]], dim=-1), dim=-1) - depth = depth / (pixel_size * scale_depth_by_focal_lengths_factor) - - if depth_is_distance: - depth = depth / unproject_points2d(locations, inv_intrinsics).norm(dim=1).clamp(min=EPS) - - depth = depth.reshape(-1, 1).clamp(min_depth, max_depth) - - proj_ctr = proj_ctr + locations - - if quat_is_allocentric: - quat = allocentric_to_egocentric(quat, proj_ctr, inv_intrinsics) - - size = (size.tanh() + 1.) * canon_box_sizes # max size = 2 * canon_size - - return Boxes3D(quat, proj_ctr, depth, size, inv_intrinsics) - - -class FCOS3DHead(nn.Module): - def __init__(self, - num_classes, - input_shape, - num_convs=4, - norm='BN', - use_scale=True, - depth_scale_init_factor=0.3, - proj_ctr_scale_init_factor=1.0, - use_per_level_predictors=False, - class_agnostic=False, - use_deformable=False, - mean_depth_per_level=None, - std_depth_per_level=None, - ): - super().__init__() - self.num_classes = num_classes - self.in_strides = [shape.stride for shape in input_shape] - self.num_levels = len(input_shape) - - self.use_scale = use_scale - self.depth_scale_init_factor = depth_scale_init_factor - self.proj_ctr_scale_init_factor = proj_ctr_scale_init_factor - self.use_per_level_predictors = use_per_level_predictors - - self.register_buffer("mean_depth_per_level", torch.Tensor(mean_depth_per_level)) - self.register_buffer("std_depth_per_level", torch.Tensor(std_depth_per_level)) - - in_channels = [s.channels for s in input_shape] - assert len(set(in_channels)) == 1, "Each level must have the same channel!" - in_channels = in_channels[0] - - if use_deformable: - raise ValueError("Not supported yet.") - - box3d_tower = [] - for i in range(num_convs): - if norm in ("BN", "FrozenBN", "SyncBN", "GN"): - # NOTE: need to add norm here! - # Each FPN level has its own batchnorm layer. - # NOTE: do not use dd3d train.py! - # "BN" is converted to "SyncBN" in distributed training (see train.py) - norm_layer = ModuleListDial([get_norm(norm, in_channels) for _ in range(self.num_levels)]) - else: - norm_layer = get_norm(norm, in_channels) - box3d_tower.append( - Conv2d( - in_channels, - in_channels, - kernel_size=3, - stride=1, - padding=1, - bias=norm_layer is None, - norm=norm_layer, - activation=F.relu - ) - ) - self.add_module('box3d_tower', nn.Sequential(*box3d_tower)) - - num_classes = self.num_classes if not class_agnostic else 1 - num_levels = self.num_levels if use_per_level_predictors else 1 - - # 3D box branches. - self.box3d_quat = nn.ModuleList([ - Conv2d(in_channels, 4 * num_classes, kernel_size=3, stride=1, padding=1, bias=True) - for _ in range(num_levels) - ]) - self.box3d_ctr = nn.ModuleList([ - Conv2d(in_channels, 2 * num_classes, kernel_size=3, stride=1, padding=1, bias=True) - for _ in range(num_levels) - ]) - self.box3d_depth = nn.ModuleList([ - Conv2d(in_channels, 1 * num_classes, kernel_size=3, stride=1, padding=1, bias=(not self.use_scale)) - for _ in range(num_levels) - ]) - self.box3d_size = nn.ModuleList([ - Conv2d(in_channels, 3 * num_classes, kernel_size=3, stride=1, padding=1, bias=True) - for _ in range(num_levels) - ]) - self.box3d_conf = nn.ModuleList([ - Conv2d(in_channels, 1 * num_classes, kernel_size=3, stride=1, padding=1, bias=True) - for _ in range(num_levels) - ]) - - if self.use_scale: - self.scales_proj_ctr = nn.ModuleList([ - Scale(init_value=stride * self.proj_ctr_scale_init_factor) for stride in self.in_strides - ]) - # (pre-)compute (mean, std) of depth for each level, and determine the init value here. - self.scales_size = nn.ModuleList([Scale(init_value=1.0) for _ in range(self.num_levels)]) - self.scales_conf = nn.ModuleList([Scale(init_value=1.0) for _ in range(self.num_levels)]) - - self.scales_depth = nn.ModuleList([ - Scale(init_value=sigma * self.depth_scale_init_factor) for sigma in self.std_depth_per_level - ]) - self.offsets_depth = nn.ModuleList([Offset(init_value=b) for b in self.mean_depth_per_level]) - - self._init_weights() - - def _init_weights(self): - - for l in self.box3d_tower.modules(): - if isinstance(l, nn.Conv2d): - torch.nn.init.kaiming_normal_(l.weight, mode='fan_out', nonlinearity='relu') - if l.bias is not None: - torch.nn.init.constant_(l.bias, 0) - - predictors = [self.box3d_quat, self.box3d_ctr, self.box3d_depth, self.box3d_size, self.box3d_conf] - - for modules in predictors: - for l in modules.modules(): - if isinstance(l, nn.Conv2d): - torch.nn.init.kaiming_uniform_(l.weight, a=1) - if l.bias is not None: # depth head may not have bias. - torch.nn.init.constant_(l.bias, 0) - - def forward(self, x): - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf = [], [], [], [], [] - dense_depth = None - for l, features in enumerate(x): - box3d_tower_out = self.box3d_tower(features) - - _l = l if self.use_per_level_predictors else 0 - - # 3D box - quat = self.box3d_quat[_l](box3d_tower_out) - proj_ctr = self.box3d_ctr[_l](box3d_tower_out) - depth = self.box3d_depth[_l](box3d_tower_out) - size3d = self.box3d_size[_l](box3d_tower_out) - conf3d = self.box3d_conf[_l](box3d_tower_out) - - if self.use_scale: - # TODO: to optimize the runtime, apply this scaling in inference (and loss compute) only on FG pixels? - proj_ctr = self.scales_proj_ctr[l](proj_ctr) - size3d = self.scales_size[l](size3d) - conf3d = self.scales_conf[l](conf3d) - depth = self.offsets_depth[l](self.scales_depth[l](depth)) - - box3d_quat.append(quat) - box3d_ctr.append(proj_ctr) - box3d_depth.append(depth) - box3d_size.append(size3d) - box3d_conf.append(conf3d) - - return box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth - - -class FCOS3DLoss(nn.Module): - def __init__(self, - num_classes, - min_depth=0.1, - max_depth=80.0, - box3d_loss_weight=2.0, - conf3d_loss_weight=1.0, - conf_3d_temperature=1.0, - smooth_l1_loss_beta=0.05, - max_loss_per_group=20, - predict_allocentric_rot=True, - scale_depth_by_focal_lengths=True, - scale_depth_by_focal_lengths_factor=500.0, - class_agnostic=False, - predict_distance=False, - canon_box_sizes=None): - super().__init__() - self.canon_box_sizes = canon_box_sizes - self.min_depth = min_depth - self.max_depth = max_depth - self.predict_allocentric_rot = predict_allocentric_rot - self.scale_depth_by_focal_lengths = scale_depth_by_focal_lengths - self.scale_depth_by_focal_lengths_factor = scale_depth_by_focal_lengths_factor - self.predict_distance = predict_distance - - self.box3d_reg_loss_fn = DisentangledBox3DLoss(smooth_l1_loss_beta, max_loss_per_group) - self.box3d_loss_weight = box3d_loss_weight - self.conf3d_loss_weight = conf3d_loss_weight - self.conf_3d_temperature = conf_3d_temperature - - self.num_classes = num_classes - self.class_agnostic = class_agnostic - - @force_fp32(apply_to=('box3d_quat', 'box3d_ctr', 'box3d_depth', 'box3d_size','box3d_conf', 'inv_intrinsics')) - def forward( - self, box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth, inv_intrinsics, fcos2d_info, - targets - ): - labels = targets['labels'] - box3d_targets = targets['box3d_targets'] - pos_inds = targets["pos_inds"] - - if pos_inds.numel() == 0: - losses = { - "loss_box3d_quat": torch.stack([x.sum() * 0. for x in box3d_quat]).sum(), - "loss_box3d_proj_ctr": torch.stack([x.sum() * 0. for x in box3d_ctr]).sum(), - "loss_box3d_depth": torch.stack([x.sum() * 0. for x in box3d_depth]).sum(), - "loss_box3d_size": torch.stack([x.sum() * 0. for x in box3d_size]).sum(), - "loss_conf3d": torch.stack([x.sum() * 0. for x in box3d_conf]).sum() - } - return losses - - if len(labels) != len(box3d_targets): - raise ValueError( - f"The size of 'labels' and 'box3d_targets' does not match: a={len(labels)}, b={len(box3d_targets)}" - ) - - num_classes = self.num_classes if not self.class_agnostic else 1 - - box3d_quat_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, 4, num_classes) for x in box3d_quat]) - box3d_ctr_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, 2, num_classes) for x in box3d_ctr]) - box3d_depth_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, num_classes) for x in box3d_depth]) - box3d_size_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, 3, num_classes) for x in box3d_size]) - box3d_conf_pred = cat([x.permute(0, 2, 3, 1).reshape(-1, num_classes) for x in box3d_conf]) - - # ---------------------- - # 3D box disentangled loss - # ---------------------- - box3d_targets = box3d_targets[pos_inds] - - box3d_quat_pred = box3d_quat_pred[pos_inds] - box3d_ctr_pred = box3d_ctr_pred[pos_inds] - box3d_depth_pred = box3d_depth_pred[pos_inds] - box3d_size_pred = box3d_size_pred[pos_inds] - box3d_conf_pred = box3d_conf_pred[pos_inds] - - if self.class_agnostic: - box3d_quat_pred = box3d_quat_pred.squeeze(-1) - box3d_ctr_pred = box3d_ctr_pred.squeeze(-1) - box3d_depth_pred = box3d_depth_pred.squeeze(-1) - box3d_size_pred = box3d_size_pred.squeeze(-1) - box3d_conf_pred = box3d_conf_pred.squeeze(-1) - else: - I = labels[pos_inds][..., None, None] - box3d_quat_pred = torch.gather(box3d_quat_pred, dim=2, index=I.repeat(1, 4, 1)).squeeze(-1) - box3d_ctr_pred = torch.gather(box3d_ctr_pred, dim=2, index=I.repeat(1, 2, 1)).squeeze(-1) - box3d_depth_pred = torch.gather(box3d_depth_pred, dim=1, index=I.squeeze(-1)).squeeze(-1) - box3d_size_pred = torch.gather(box3d_size_pred, dim=2, index=I.repeat(1, 3, 1)).squeeze(-1) - box3d_conf_pred = torch.gather(box3d_conf_pred, dim=1, index=I.squeeze(-1)).squeeze(-1) - - canon_box_sizes = box3d_quat_pred.new_tensor(self.canon_box_sizes)[labels[pos_inds]] - - locations = targets["locations"][pos_inds] - im_inds = targets["im_inds"][pos_inds] - inv_intrinsics = inv_intrinsics[im_inds] - - box3d_pred = predictions_to_boxes3d( - box3d_quat_pred, - box3d_ctr_pred, - box3d_depth_pred, - box3d_size_pred, - locations, - inv_intrinsics, - canon_box_sizes, - self.min_depth, - self.max_depth, - scale_depth_by_focal_lengths_factor=self.scale_depth_by_focal_lengths_factor, - scale_depth_by_focal_lengths=self.scale_depth_by_focal_lengths, - quat_is_allocentric=self.predict_allocentric_rot, - depth_is_distance=self.predict_distance - ) - - centerness_targets = fcos2d_info["centerness_targets"] - loss_denom = fcos2d_info["loss_denom"] - losses_box3d, box3d_l1_error = self.box3d_reg_loss_fn(box3d_pred, box3d_targets, locations, centerness_targets) - - losses_box3d = {k: self.box3d_loss_weight * v / loss_denom for k, v in losses_box3d.items()} - - conf_3d_targets = torch.exp(-1. / self.conf_3d_temperature * box3d_l1_error) - loss_conf3d = F.binary_cross_entropy_with_logits(box3d_conf_pred, conf_3d_targets, reduction='none') - loss_conf3d = self.conf3d_loss_weight * (loss_conf3d * centerness_targets).sum() / loss_denom - - losses = {"loss_conf3d": loss_conf3d, **losses_box3d} - - return losses - - -class FCOS3DInference(): - def __init__(self, cfg): - self.canon_box_sizes = cfg.DD3D.FCOS3D.CANONICAL_BOX3D_SIZES - self.min_depth = cfg.DD3D.FCOS3D.MIN_DEPTH - self.max_depth = cfg.DD3D.FCOS3D.MAX_DEPTH - self.predict_allocentric_rot = cfg.DD3D.FCOS3D.PREDICT_ALLOCENTRIC_ROT - self.scale_depth_by_focal_lengths = cfg.DD3D.FCOS3D.SCALE_DEPTH_BY_FOCAL_LENGTHS - self.scale_depth_by_focal_lengths_factor = cfg.DD3D.FCOS3D.SCALE_DEPTH_BY_FOCAL_LENGTHS_FACTOR - self.predict_distance = cfg.DD3D.FCOS3D.PREDICT_DISTANCE - - self.num_classes = cfg.DD3D.NUM_CLASSES - self.class_agnostic = cfg.DD3D.FCOS3D.CLASS_AGNOSTIC_BOX3D - - def __call__( - self, box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, inv_intrinsics, pred_instances, fcos2d_info - ): - # pred_instances: # List[List[Instances]], shape = (L, B) - for lvl, (box3d_quat_lvl, box3d_ctr_lvl, box3d_depth_lvl, box3d_size_lvl, box3d_conf_lvl) in \ - enumerate(zip(box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf)): - - # In-place modification: update per-level pred_instances. - self.forward_for_single_feature_map( - box3d_quat_lvl, box3d_ctr_lvl, box3d_depth_lvl, box3d_size_lvl, box3d_conf_lvl, inv_intrinsics, - pred_instances[lvl], fcos2d_info[lvl] - ) # List of Instances; one for each image. - - def forward_for_single_feature_map( - self, box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, inv_intrinsics, pred_instances, fcos2d_info - ): - N = box3d_quat.shape[0] - - num_classes = self.num_classes if not self.class_agnostic else 1 - - box3d_quat = box3d_quat.permute(0, 2, 3, 1).reshape(N, -1, 4, num_classes) - box3d_ctr = box3d_ctr.permute(0, 2, 3, 1).reshape(N, -1, 2, num_classes) - box3d_depth = box3d_depth.permute(0, 2, 3, 1).reshape(N, -1, num_classes) - box3d_size = box3d_size.permute(0, 2, 3, 1).reshape(N, -1, 3, num_classes) - box3d_conf = box3d_conf.permute(0, 2, 3, 1).reshape(N, -1, num_classes).sigmoid() - - for i in range(N): - fg_inds_per_im = fcos2d_info['fg_inds_per_im'][i] - class_inds_per_im = fcos2d_info['class_inds_per_im'][i] - topk_indices = fcos2d_info['topk_indices'][i] - - box3d_quat_per_im = box3d_quat[i][fg_inds_per_im] - box3d_ctr_per_im = box3d_ctr[i][fg_inds_per_im] - box3d_depth_per_im = box3d_depth[i][fg_inds_per_im] - box3d_size_per_im = box3d_size[i][fg_inds_per_im] - box3d_conf_per_im = box3d_conf[i][fg_inds_per_im] - - if self.class_agnostic: - box3d_quat_per_im = box3d_quat_per_im.squeeze(-1) - box3d_ctr_per_im = box3d_ctr_per_im.squeeze(-1) - box3d_depth_per_im = box3d_depth_per_im.squeeze(-1) - box3d_size_per_im = box3d_size_per_im.squeeze(-1) - box3d_conf_per_im = box3d_conf_per_im.squeeze(-1) - else: - I = class_inds_per_im[..., None, None] - box3d_quat_per_im = torch.gather(box3d_quat_per_im, dim=2, index=I.repeat(1, 4, 1)).squeeze(-1) - box3d_ctr_per_im = torch.gather(box3d_ctr_per_im, dim=2, index=I.repeat(1, 2, 1)).squeeze(-1) - box3d_depth_per_im = torch.gather(box3d_depth_per_im, dim=1, index=I.squeeze(-1)).squeeze(-1) - box3d_size_per_im = torch.gather(box3d_size_per_im, dim=2, index=I.repeat(1, 3, 1)).squeeze(-1) - box3d_conf_per_im = torch.gather(box3d_conf_per_im, dim=1, index=I.squeeze(-1)).squeeze(-1) - - if topk_indices is not None: - box3d_quat_per_im = box3d_quat_per_im[topk_indices] - box3d_ctr_per_im = box3d_ctr_per_im[topk_indices] - box3d_depth_per_im = box3d_depth_per_im[topk_indices] - box3d_size_per_im = box3d_size_per_im[topk_indices] - box3d_conf_per_im = box3d_conf_per_im[topk_indices] - - # scores_per_im = pred_instances[i].scores.square() - # NOTE: Before refactoring, the squared score was used. Is raw 2D score better? - scores_per_im = pred_instances[i].scores - scores_3d_per_im = scores_per_im * box3d_conf_per_im - - canon_box_sizes = box3d_quat.new_tensor(self.canon_box_sizes)[pred_instances[i].pred_classes] - inv_K = inv_intrinsics[i][None, ...].expand(len(box3d_quat_per_im), 3, 3) - locations = pred_instances[i].locations - pred_boxes3d = predictions_to_boxes3d( - box3d_quat_per_im, - box3d_ctr_per_im, - box3d_depth_per_im, - box3d_size_per_im, - locations, - inv_K, - canon_box_sizes, - self.min_depth, - self.max_depth, - scale_depth_by_focal_lengths_factor=self.scale_depth_by_focal_lengths_factor, - scale_depth_by_focal_lengths=self.scale_depth_by_focal_lengths, - quat_is_allocentric=self.predict_allocentric_rot, - depth_is_distance=self.predict_distance - ) - - # In-place modification: add fields to instances. - pred_instances[i].pred_boxes3d = pred_boxes3d - pred_instances[i].scores_3d = scores_3d_per_im diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/nuscenes_dd3d.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/nuscenes_dd3d.py deleted file mode 100644 index a4007b0e0e7e7f9ed829ec568de425a16334e28c..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/nuscenes_dd3d.py +++ /dev/null @@ -1,522 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -import torch -import torch.nn.functional as F -from fvcore.nn.smooth_l1_loss import smooth_l1_loss -from torch import nn - -from detectron2.layers import Conv2d, cat -#from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY -from detectron2.modeling.postprocessing import detector_postprocess as resize_instances -from detectron2.structures import Instances -from detectron2.utils import comm as d2_comm -from mmdet.models.builder import HEADS -from mmcv.runner import force_fp32 - -from projects.mmdet3d_plugin.dd3d.datasets.nuscenes import MAX_NUM_ATTRIBUTES -from .core import DD3D -#from tridet.modeling.dd3d.postprocessing import get_group_idxs, nuscenes_sample_aggregate -from .prepare_targets import DD3DTargetPreparer -from projects.mmdet3d_plugin.dd3d.structures.boxes3d import Boxes3D -from projects.mmdet3d_plugin.dd3d.structures.image_list import ImageList -from projects.mmdet3d_plugin.dd3d.utils.comm import reduce_sum - -INF = 100000000. - - -class NuscenesDD3DTargetPreparer(DD3DTargetPreparer): - def __init__(self, **kwargs): - super().__init__(**kwargs) - assert self.dd3d_enabled, f"{type(self).__name__} requires dd3d_enabled = True" - - def __call__(self, locations, gt_instances, feature_shapes): - num_loc_list = [len(loc) for loc in locations] - - # compute locations to size ranges - loc_to_size_range = [] - for l, loc_per_level in enumerate(locations): - loc_to_size_range_per_level = loc_per_level.new_tensor(self.sizes_of_interest[l]) - loc_to_size_range.append(loc_to_size_range_per_level[None].expand(num_loc_list[l], -1)) - - loc_to_size_range = torch.cat(loc_to_size_range, dim=0) - locations = torch.cat(locations, dim=0) - - training_targets = self.compute_targets_for_locations(locations, gt_instances, loc_to_size_range, num_loc_list) - - training_targets["locations"] = [locations.clone() for _ in range(len(gt_instances))] - training_targets["im_inds"] = [ - locations.new_ones(locations.size(0), dtype=torch.long) * i for i in range(len(gt_instances)) - ] - - box2d = training_targets.pop("box2d", None) - - # transpose im first training_targets to level first ones - training_targets = {k: self._transpose(v, num_loc_list) for k, v in training_targets.items() if k != "box2d"} - - training_targets["fpn_levels"] = [ - loc.new_ones(len(loc), dtype=torch.long) * level for level, loc in enumerate(training_targets["locations"]) - ] - - # Flatten targets: (L x B x H x W, TARGET_SIZE) - labels = cat([x.reshape(-1) for x in training_targets["labels"]]) - box2d_reg_targets = cat([x.reshape(-1, 4) for x in training_targets["box2d_reg"]]) - - target_inds = cat([x.reshape(-1) for x in training_targets["target_inds"]]) - locations = cat([x.reshape(-1, 2) for x in training_targets["locations"]]) - im_inds = cat([x.reshape(-1) for x in training_targets["im_inds"]]) - fpn_levels = cat([x.reshape(-1) for x in training_targets["fpn_levels"]]) - - pos_inds = torch.nonzero(labels != self.num_classes).squeeze(1) - - targets = { - "labels": labels, - "box2d_reg_targets": box2d_reg_targets, - "locations": locations, - "target_inds": target_inds, - "im_inds": im_inds, - "fpn_levels": fpn_levels, - "pos_inds": pos_inds - } - - if self.dd3d_enabled: - box3d_targets = Boxes3D.cat(training_targets["box3d"]) - targets.update({"box3d_targets": box3d_targets}) - - if box2d is not None: - # Original format is B x L x (H x W, 4) - # Need to be in L x (B, 4, H, W). - batched_box2d = [] - for lvl, per_lvl_box2d in enumerate(zip(*box2d)): - # B x (H x W, 4) - h, w = feature_shapes[lvl] - batched_box2d_lvl = torch.stack([x.T.reshape(4, h, w) for x in per_lvl_box2d], dim=0) - batched_box2d.append(batched_box2d_lvl) - targets.update({"batched_box2d": batched_box2d}) - - # Nuscenes targets -- attribute / speed - attributes = cat([x.reshape(-1) for x in training_targets["attributes"]]) - speeds = cat([x.reshape(-1) for x in training_targets["speeds"]]) - - targets.update({'attributes': attributes, 'speeds': speeds}) - - return targets - - def compute_targets_for_locations(self, locations, targets, size_ranges, num_loc_list): - labels = [] - box2d_reg = [] - - if self.dd3d_enabled: - box3d = [] - - target_inds = [] - xs, ys = locations[:, 0], locations[:, 1] - - # NuScenes targets -- attribute / speed - attributes, speeds = [], [] - - num_targets = 0 - for im_i in range(len(targets)): - targets_per_im = targets[im_i] - bboxes = targets_per_im.gt_boxes.tensor - labels_per_im = targets_per_im.gt_classes - - # no gt - if bboxes.numel() == 0: - labels.append(labels_per_im.new_zeros(locations.size(0)) + self.num_classes) - # reg_targets.append(locations.new_zeros((locations.size(0), 4))) - box2d_reg.append(locations.new_zeros((locations.size(0), 4))) - target_inds.append(labels_per_im.new_zeros(locations.size(0)) - 1) - - if self.dd3d_enabled: - box3d.append( - Boxes3D( - locations.new_zeros(locations.size(0), 4), - locations.new_zeros(locations.size(0), 2), - locations.new_zeros(locations.size(0), 1), - locations.new_zeros(locations.size(0), 3), - locations.new_zeros(locations.size(0), 3, 3), - ).to(torch.float32) - ) - # NOTE: attributes and speeds. - attributes.append(labels_per_im.new_zeros(locations.size(0))) - speeds.append(labels_per_im.new_zeros(locations.size(0))) - continue - - area = targets_per_im.gt_boxes.area() - - l = xs[:, None] - bboxes[:, 0][None] - t = ys[:, None] - bboxes[:, 1][None] - r = bboxes[:, 2][None] - xs[:, None] - b = bboxes[:, 3][None] - ys[:, None] - # reg_targets_per_im = torch.stack([l, t, r, b], dim=2) - box2d_reg_per_im = torch.stack([l, t, r, b], dim=2) - - if self.center_sample: - is_in_boxes = self.get_sample_region(bboxes, num_loc_list, xs, ys) - else: - is_in_boxes = box2d_reg_per_im.min(dim=2)[0] > 0 - - max_reg_targets_per_im = box2d_reg_per_im.max(dim=2)[0] - # limit the regression range for each location - is_cared_in_the_level = \ - (max_reg_targets_per_im >= size_ranges[:, [0]]) & \ - (max_reg_targets_per_im <= size_ranges[:, [1]]) - - locations_to_gt_area = area[None].repeat(len(locations), 1) - locations_to_gt_area[is_in_boxes == 0] = INF - locations_to_gt_area[is_cared_in_the_level == 0] = INF - - # if there are still more than one objects for a location, - # we choose the one with minimal area - locations_to_min_area, locations_to_gt_inds = locations_to_gt_area.min(dim=1) - - box2d_reg_per_im = box2d_reg_per_im[range(len(locations)), locations_to_gt_inds] - target_inds_per_im = locations_to_gt_inds + num_targets - num_targets += len(targets_per_im) - - labels_per_im = labels_per_im[locations_to_gt_inds] - labels_per_im[locations_to_min_area == INF] = self.num_classes - - labels.append(labels_per_im) - box2d_reg.append(box2d_reg_per_im) - target_inds.append(target_inds_per_im) - - if self.dd3d_enabled: - # 3D box targets - box3d_per_im = targets_per_im.gt_boxes3d[locations_to_gt_inds] - box3d.append(box3d_per_im) - - # NuScenes targets -- attribute / speed - attributes_per_im = targets_per_im.gt_attributes[locations_to_gt_inds] - speeds_per_im = targets_per_im.gt_speeds[locations_to_gt_inds] - attributes.append(attributes_per_im) - speeds.append(speeds_per_im) - - ret = {"labels": labels, "box2d_reg": box2d_reg, "target_inds": target_inds} - if self.dd3d_enabled: - ret.update({"box3d": box3d}) - - # NuScenes targets -- attribute / speed - ret.update({"attributes": attributes, "speeds": speeds}) - - return ret - - -class NuscenesLoss(nn.Module): - def __init__(self, attr_loss_weight=0.2, speed_loss_weight=0.2): - super().__init__() - self.attr_loss_weight = attr_loss_weight - self.speed_loss_weight = speed_loss_weight - - @force_fp32(apply_to=('attr_logits', 'speeds')) - def forward(self, attr_logits, speeds, fcos2d_info, targets): - # Flatten predictions - attr_logits = cat([x.permute(0, 2, 3, 1).reshape(-1, MAX_NUM_ATTRIBUTES) for x in attr_logits]) - speeds = cat([x.permute(0, 2, 3, 1).reshape(-1) for x in speeds]) - - pos_inds = targets['pos_inds'] - - losses = {} - - # 1. Attributes - attr_logits = attr_logits[pos_inds] - target_attr = targets['attributes'][pos_inds] - valid_attr_mask = target_attr != MAX_NUM_ATTRIBUTES # No attrs associated with class, or just attr missing. - - if pos_inds.numel() == 0: - attr_weights = attr_logits.new_tensor(0.0) #torch.tensor(0.0).cuda() - else: - attr_weights = fcos2d_info['centerness_targets'][valid_attr_mask] - # Denominator for all foreground losses -- re-computed for features with valid attributes. - # attr_loss_denom = max(reduce_sum(attr_weights.sum()).item() / d2_comm.get_world_size(), 1e-6) - # NOTE: compute attr_weights_sum, and then feed it to reduce_sum() works, but not above. - attr_weights_sum = attr_weights.sum() - attr_loss_denom = max(reduce_sum(attr_weights_sum).item() / d2_comm.get_world_size(), 1e-6) - - if valid_attr_mask.sum() == 0: - losses.update({"loss_attr": attr_logits.sum() * 0.}) - else: - attr_logits = attr_logits[valid_attr_mask] - target_attr = target_attr[valid_attr_mask] - - xent = F.cross_entropy(attr_logits, target_attr) - loss_attr = (xent * attr_weights).sum() / attr_loss_denom - - losses.update({"loss_attr": self.attr_loss_weight * loss_attr}) - - # 2. Speed - speeds = speeds[pos_inds] - target_speeds = targets['speeds'][pos_inds] - # NOTE: some GT speeds are NaN. - valid_gt_mask = torch.logical_not(torch.isnan(target_speeds)) - - if pos_inds.numel() == 0: - speed_weights = speeds.new_tensor(0.0) #torch.tensor(0.0).cuda() - else: - speed_weights = fcos2d_info['centerness_targets'][valid_gt_mask] - # Denominator for all foreground losses -- re-computed for features with valid speeds. - # speed_loss_denom = max(reduce_sum(speed_weights.sum()).item() / d2_comm.get_world_size(), 1e-6) - speed_weights_sum = speed_weights.sum() - speed_loss_denom = max(reduce_sum(speed_weights_sum).item() / d2_comm.get_world_size(), 1e-6) - - # NOTE: move after reduce sum - if pos_inds.numel() == 0: - losses = {"loss_attr": attr_logits.sum() * 0., "loss_speed": speeds.sum() * 0.} - # NOTE: This is probably un-reachable, because the training filter images with empty annotations. - # NOTE: If not, attr_weights can be unavailable in the reduce_sum below(). - return losses - - if valid_gt_mask.sum() == 0: - losses.update({"loss_speed": speeds.sum() * 0.}) - # return losses - else: - speeds = speeds[valid_gt_mask] - target_speeds = target_speeds[valid_gt_mask] - - l1_error = smooth_l1_loss(speeds, target_speeds, beta=0.05) - loss_speed = (l1_error * speed_weights).sum() / speed_loss_denom - losses.update({"loss_speed": self.speed_loss_weight * loss_speed}) - - return losses - - -class NuscenesInference(): - def __init__(self, cfg): - pass - - def __call__(self, attr_logits, speeds, pred_instances, fcos2d_info): - """Add 'pred_attribute', 'pred_speed' to Instances in 'pred_instances'.""" - N = attr_logits[0].shape[0] - for lvl, (attr_logits_lvl, speed_lvl, info_lvl, instances_lvl) in \ - enumerate(zip(attr_logits, speeds, fcos2d_info, pred_instances)): - - attr_logits_lvl = attr_logits_lvl.permute(0, 2, 3, 1).reshape(N, -1, MAX_NUM_ATTRIBUTES) - speed_lvl = speed_lvl.permute(0, 2, 3, 1).reshape(N, -1) - for i in range(N): - fg_inds_per_im = info_lvl['fg_inds_per_im'][i] - topk_indices = info_lvl['topk_indices'][i] - - attr_logits_per_im = attr_logits_lvl[i][fg_inds_per_im] - speed_per_im = speed_lvl[i][fg_inds_per_im] - - if topk_indices is not None: - attr_logits_per_im = attr_logits_per_im[topk_indices] - speed_per_im = speed_per_im[topk_indices] - - if len(attr_logits_per_im) == 0: - instances_lvl[i].pred_attributes = instances_lvl[i].pred_classes.new_tensor([]) - instances_lvl[i].pred_speeds = instances_lvl[i].scores.new_tensor([]) - else: - instances_lvl[i].pred_attributes = attr_logits_per_im.argmax(dim=1) - instances_lvl[i].pred_speeds = speed_per_im - - -@HEADS.register_module() -class NuscenesDD3D(DD3D): - def __init__(self, - num_classes, - in_channels, - strides, - fcos2d_cfg=dict(), - fcos2d_loss_cfg=dict(), - fcos3d_cfg=dict(), - fcos3d_loss_cfg=dict(), - target_assign_cfg=dict(), - nusc_loss_weight=dict(), - box3d_on=True, - feature_locations_offset="none"): - super().__init__(num_classes, - in_channels, - strides, - fcos2d_cfg=fcos2d_cfg, - fcos2d_loss_cfg=fcos2d_loss_cfg, - fcos3d_cfg=fcos3d_cfg, - fcos3d_loss_cfg=fcos3d_loss_cfg, - target_assign_cfg=target_assign_cfg, - box3d_on=box3d_on, - feature_locations_offset=feature_locations_offset) - - # backbone_output_shape = self.backbone_output_shape - # in_channels = backbone_output_shape[0].channels - - # -------------------------------------------------------------------------- - # NuScenes predictions -- attribute / speed, computed from cls_tower output. - # -------------------------------------------------------------------------- - self.attr_logits = Conv2d(in_channels, MAX_NUM_ATTRIBUTES, kernel_size=3, stride=1, padding=1, bias=True) - self.speed = Conv2d(in_channels, 1, kernel_size=3, stride=1, padding=1, bias=True, activation=F.relu) - - # init weights - for modules in [self.attr_logits, self.speed]: - for l in modules.modules(): - if isinstance(l, nn.Conv2d): - torch.nn.init.kaiming_uniform_(l.weight, a=1) - if l.bias is not None: # depth head may not have bias. - torch.nn.init.constant_(l.bias, 0) - - # Re-define target preparer - del self.prepare_targets - self.prepare_targets = NuscenesDD3DTargetPreparer(num_classes=num_classes, - input_shape=self.backbone_output_shape, - box3d_on=box3d_on, - **target_assign_cfg) - - self.nuscenes_loss = NuscenesLoss(**nusc_loss_weight) - # NOTE: inference later - # self.nuscenes_inference = NuscenesInference(cfg) - - # self.num_images_per_sample = cfg.MODEL.FCOS3D.NUSC_NUM_IMAGES_PER_SAMPLE - # NOTE: inference later - # self.num_images_per_sample = cfg.DD3D.NUSC.INFERENCE.NUM_IMAGES_PER_SAMPLE - - # assert self.num_images_per_sample == 6 - # assert cfg.DATALOADER.TEST.NUM_IMAGES_PER_GROUP == 6 - - # NOTE: NuScenes evaluator allows max. 500 detections per sample. - # self.max_num_dets_per_sample = cfg.DD3D.NUSC.INFERENCE.MAX_NUM_DETS_PER_SAMPLE - - @force_fp32(apply_to=('features')) - def forward(self, features, batched_inputs): - # NOTE: - # images = [x["image"].to(self.device) for x in batched_inputs] - # images = [self.preprocess_image(x) for x in images] - - # NOTE: directly use inv_intrinsics - # if 'intrinsics' in batched_inputs[0]: - # intrinsics = [x['intrinsics'].to(self.device) for x in batched_inputs] - # else: - # intrinsics = None - # images = ImageList.from_tensors(images, self.backbone.size_divisibility, intrinsics=intrinsics) - if 'inv_intrinsics' in batched_inputs[0]: - inv_intrinsics = [x['inv_intrinsics'].to(features[0].device) for x in batched_inputs] - inv_intrinsics = torch.stack(inv_intrinsics, dim=0) - else: - inv_intrinsics = None - - # NOTE: - # gt_dense_depth = None - # if 'depth' in batched_inputs[0]: - # gt_dense_depth = [x["depth"].to(self.device) for x in batched_inputs] - # gt_dense_depth = ImageList.from_tensors( - # gt_dense_depth, self.backbone.size_divisibility, intrinsics=intrinsics - # ) - - # NOTE: directly input feature - # features = self.backbone(images.tensor) - # features = [features[f] for f in self.in_features] - - if "instances" in batched_inputs[0]: - gt_instances = [x["instances"].to(features[0].device) for x in batched_inputs] - else: - gt_instances = None - - locations = self.compute_locations(features) - logits, box2d_reg, centerness, fcos2d_extra_output = self.fcos2d_head(features) - if not self.only_box2d: - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth = self.fcos3d_head(features) - # NOTE: directly use inv_intrinsics - # inv_intrinsics = images.intrinsics.inverse() if images.intrinsics is not None else None - - # -------------------------------------------------------------------------- - # NuScenes predictions -- attribute / speed, computed from cls_tower output. - # -------------------------------------------------------------------------- - attr_logits, speeds = [], [] - for x in fcos2d_extra_output['cls_tower_out']: - attr_logits.append(self.attr_logits(x)) - speeds.append(self.speed(x)) - - if self.training: - assert gt_instances is not None - feature_shapes = [x.shape[-2:] for x in features] - training_targets = self.prepare_targets(locations, gt_instances, feature_shapes) - # NOTE: - # if gt_dense_depth is not None: - # training_targets.update({"dense_depth": gt_dense_depth}) - - losses = {} - fcos2d_loss, fcos2d_info = self.fcos2d_loss(logits, box2d_reg, centerness, training_targets) - losses.update(fcos2d_loss) - - if not self.only_box2d: - fcos3d_loss = self.fcos3d_loss( - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, dense_depth, inv_intrinsics, - fcos2d_info, training_targets - ) - losses.update(fcos3d_loss) - - # Nuscenes loss -- attribute / speed - nuscenes_loss = self.nuscenes_loss(attr_logits, speeds, fcos2d_info, training_targets) - losses.update(nuscenes_loss) - return losses - else: - # TODO: do not support inference now - raise NotImplementedError - pred_instances, fcos2d_info = self.fcos2d_inference( - logits, box2d_reg, centerness, locations, images.image_sizes - ) - if not self.only_box2d: - # This adds 'pred_boxes3d' and 'scores_3d' to Instances in 'pred_instances'. - self.fcos3d_inference( - box3d_quat, box3d_ctr, box3d_depth, box3d_size, box3d_conf, inv_intrinsics, pred_instances, - fcos2d_info - ) - score_key = "scores_3d" - else: - score_key = "scores" - - # This adds 'pred_attributes', 'pred_speed' to Instances in 'pred_instances'. - self.nuscenes_inference(attr_logits, speeds, pred_instances, fcos2d_info) - - # Transpose to "image-first", i.e. (B, L) - pred_instances = list(zip(*pred_instances)) - pred_instances = [Instances.cat(instances) for instances in pred_instances] - - # 2D NMS and pick top-K. - if self.do_nms: - pred_instances = self.fcos2d_inference.nms_and_top_k(pred_instances, score_key) - - if not self.only_box2d and self.do_bev_nms: - # Bird-eye-view NMS. - dummy_group_idxs = {i: [i] for i, _ in enumerate(pred_instances)} - if 'pose' in batched_inputs[0]: - poses = [x['pose'] for x in batched_inputs] - else: - poses = [x['extrinsics'] for x in batched_inputs] - pred_instances = nuscenes_sample_aggregate( - pred_instances, - dummy_group_idxs, - self.num_classes, - poses, - iou_threshold=self.bev_nms_iou_thresh, - include_boxes3d_global=False - ) - - if self.postprocess_in_inference: - processed_results = [] - for results_per_image, input_per_image, image_size in \ - zip(pred_instances, batched_inputs, images.image_sizes): - height = input_per_image.get("height", image_size[0]) - width = input_per_image.get("width", image_size[1]) - r = resize_instances(results_per_image, height, width) - processed_results.append({"instances": r}) - - # ---------------------------------------------------------- - # NuScenes specific: cross-image (i.e. sample-level) BEV NMS. - # ---------------------------------------------------------- - sample_tokens = [x['sample_token'] for x in batched_inputs] - group_idxs = get_group_idxs(sample_tokens, self.num_images_per_sample) - - instances = [x['instances'] for x in processed_results] - global_poses = [x['pose'] for x in batched_inputs] - - filtered_instances = nuscenes_sample_aggregate( - instances, - group_idxs, - self.num_classes, - global_poses, - self.bev_nms_iou_thresh, - max_num_dets_per_sample=self.max_num_dets_per_sample - ) - processed_results = [{"instances": x} for x in filtered_instances] - else: - processed_results = [{"instances": x} for x in pred_instances] - - return processed_results diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/prepare_targets.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/prepare_targets.py deleted file mode 100644 index d074954fcf50019bcae59247d0114a8d3f2ede6a..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/dd3d/modeling/prepare_targets.py +++ /dev/null @@ -1,242 +0,0 @@ -# Copyright 2021 Toyota Research Institute. All rights reserved. -import torch - -from detectron2.layers import cat - -from projects.mmdet3d_plugin.dd3d.structures.boxes3d import Boxes3D - -INF = 100000000. - - -class DD3DTargetPreparer(): - def __init__(self, - num_classes, - input_shape, - box3d_on=True, - center_sample=True, - pos_radius=1.5, - sizes_of_interest=None): - self.num_classes = num_classes - self.center_sample = center_sample - self.strides = [shape.stride for shape in input_shape] - self.radius = pos_radius - self.dd3d_enabled = box3d_on - - # generate sizes of interest - # NOTE: - # soi = [] - # prev_size = -1 - # for s in sizes_of_interest: - # soi.append([prev_size, s]) - # prev_size = s - # soi.append([prev_size, INF]) - self.sizes_of_interest = sizes_of_interest - - def __call__(self, locations, gt_instances, feature_shapes): - num_loc_list = [len(loc) for loc in locations] - - # compute locations to size ranges - loc_to_size_range = [] - for l, loc_per_level in enumerate(locations): - loc_to_size_range_per_level = loc_per_level.new_tensor(self.sizes_of_interest[l]) - loc_to_size_range.append(loc_to_size_range_per_level[None].expand(num_loc_list[l], -1)) - - loc_to_size_range = torch.cat(loc_to_size_range, dim=0) - locations = torch.cat(locations, dim=0) - - training_targets = self.compute_targets_for_locations(locations, gt_instances, loc_to_size_range, num_loc_list) - - training_targets["locations"] = [locations.clone() for _ in range(len(gt_instances))] - training_targets["im_inds"] = [ - locations.new_ones(locations.size(0), dtype=torch.long) * i for i in range(len(gt_instances)) - ] - - box2d = training_targets.pop("box2d", None) - - # transpose im first training_targets to level first ones - training_targets = {k: self._transpose(v, num_loc_list) for k, v in training_targets.items() if k != "box2d"} - - training_targets["fpn_levels"] = [ - loc.new_ones(len(loc), dtype=torch.long) * level for level, loc in enumerate(training_targets["locations"]) - ] - - # Flatten targets: (L x B x H x W, TARGET_SIZE) - labels = cat([x.reshape(-1) for x in training_targets["labels"]]) - box2d_reg_targets = cat([x.reshape(-1, 4) for x in training_targets["box2d_reg"]]) - - target_inds = cat([x.reshape(-1) for x in training_targets["target_inds"]]) - locations = cat([x.reshape(-1, 2) for x in training_targets["locations"]]) - im_inds = cat([x.reshape(-1) for x in training_targets["im_inds"]]) - fpn_levels = cat([x.reshape(-1) for x in training_targets["fpn_levels"]]) - - pos_inds = torch.nonzero(labels != self.num_classes).squeeze(1) - - targets = { - "labels": labels, - "box2d_reg_targets": box2d_reg_targets, - "locations": locations, - "target_inds": target_inds, - "im_inds": im_inds, - "fpn_levels": fpn_levels, - "pos_inds": pos_inds - } - - if self.dd3d_enabled: - box3d_targets = Boxes3D.cat(training_targets["box3d"]) - targets.update({"box3d_targets": box3d_targets}) - - if box2d is not None: - # Original format is B x L x (H x W, 4) - # Need to be in L x (B, 4, H, W). - batched_box2d = [] - for lvl, per_lvl_box2d in enumerate(zip(*box2d)): - # B x (H x W, 4) - h, w = feature_shapes[lvl] - batched_box2d_lvl = torch.stack([x.T.reshape(4, h, w) for x in per_lvl_box2d], dim=0) - batched_box2d.append(batched_box2d_lvl) - targets.update({"batched_box2d": batched_box2d}) - - return targets - - def compute_targets_for_locations(self, locations, targets, size_ranges, num_loc_list): - labels = [] - box2d_reg = [] - - if self.dd3d_enabled: - box3d = [] - - target_inds = [] - xs, ys = locations[:, 0], locations[:, 1] - - num_targets = 0 - for im_i in range(len(targets)): - targets_per_im = targets[im_i] - bboxes = targets_per_im.gt_boxes.tensor - labels_per_im = targets_per_im.gt_classes - - # no gt - if bboxes.numel() == 0: - labels.append(labels_per_im.new_zeros(locations.size(0)) + self.num_classes) - # reg_targets.append(locations.new_zeros((locations.size(0), 4))) - box2d_reg.append(locations.new_zeros((locations.size(0), 4))) - target_inds.append(labels_per_im.new_zeros(locations.size(0)) - 1) - - if self.dd3d_enabled: - box3d.append( - Boxes3D( - locations.new_zeros(locations.size(0), 4), - locations.new_zeros(locations.size(0), 2), - locations.new_zeros(locations.size(0), 1), - locations.new_zeros(locations.size(0), 3), - locations.new_zeros(locations.size(0), 3, 3), - ).to(torch.float32) - ) - continue - - area = targets_per_im.gt_boxes.area() - - l = xs[:, None] - bboxes[:, 0][None] - t = ys[:, None] - bboxes[:, 1][None] - r = bboxes[:, 2][None] - xs[:, None] - b = bboxes[:, 3][None] - ys[:, None] - # reg_targets_per_im = torch.stack([l, t, r, b], dim=2) - box2d_reg_per_im = torch.stack([l, t, r, b], dim=2) - - if self.center_sample: - is_in_boxes = self.get_sample_region(bboxes, num_loc_list, xs, ys) - else: - is_in_boxes = box2d_reg_per_im.min(dim=2)[0] > 0 - - max_reg_targets_per_im = box2d_reg_per_im.max(dim=2)[0] - # limit the regression range for each location - is_cared_in_the_level = \ - (max_reg_targets_per_im >= size_ranges[:, [0]]) & \ - (max_reg_targets_per_im <= size_ranges[:, [1]]) - - locations_to_gt_area = area[None].repeat(len(locations), 1) - locations_to_gt_area[is_in_boxes == 0] = INF - locations_to_gt_area[is_cared_in_the_level == 0] = INF - - # if there are still more than one objects for a location, - # we choose the one with minimal area - locations_to_min_area, locations_to_gt_inds = locations_to_gt_area.min(dim=1) - - box2d_reg_per_im = box2d_reg_per_im[range(len(locations)), locations_to_gt_inds] - target_inds_per_im = locations_to_gt_inds + num_targets - num_targets += len(targets_per_im) - - labels_per_im = labels_per_im[locations_to_gt_inds] - labels_per_im[locations_to_min_area == INF] = self.num_classes - - labels.append(labels_per_im) - box2d_reg.append(box2d_reg_per_im) - target_inds.append(target_inds_per_im) - - if self.dd3d_enabled: - # 3D box targets - box3d_per_im = targets_per_im.gt_boxes3d[locations_to_gt_inds] - box3d.append(box3d_per_im) - - ret = {"labels": labels, "box2d_reg": box2d_reg, "target_inds": target_inds} - if self.dd3d_enabled: - ret.update({"box3d": box3d}) - - return ret - - def get_sample_region(self, boxes, num_loc_list, loc_xs, loc_ys): - center_x = boxes[..., [0, 2]].sum(dim=-1) * 0.5 - center_y = boxes[..., [1, 3]].sum(dim=-1) * 0.5 - - num_gts = boxes.shape[0] - K = len(loc_xs) - boxes = boxes[None].expand(K, num_gts, 4) - center_x = center_x[None].expand(K, num_gts) - center_y = center_y[None].expand(K, num_gts) - center_gt = boxes.new_zeros(boxes.shape) - # no gt - if center_x.numel() == 0 or center_x[..., 0].sum() == 0: - return loc_xs.new_zeros(loc_xs.shape, dtype=torch.uint8) - beg = 0 - for level, num_loc in enumerate(num_loc_list): - end = beg + num_loc - stride = self.strides[level] * self.radius - xmin = center_x[beg:end] - stride - ymin = center_y[beg:end] - stride - xmax = center_x[beg:end] + stride - ymax = center_y[beg:end] + stride - # limit sample region in gt - center_gt[beg:end, :, 0] = torch.where(xmin > boxes[beg:end, :, 0], xmin, boxes[beg:end, :, 0]) - center_gt[beg:end, :, 1] = torch.where(ymin > boxes[beg:end, :, 1], ymin, boxes[beg:end, :, 1]) - center_gt[beg:end, :, 2] = torch.where(xmax > boxes[beg:end, :, 2], boxes[beg:end, :, 2], xmax) - center_gt[beg:end, :, 3] = torch.where(ymax > boxes[beg:end, :, 3], boxes[beg:end, :, 3], ymax) - beg = end - left = loc_xs[:, None] - center_gt[..., 0] - right = center_gt[..., 2] - loc_xs[:, None] - top = loc_ys[:, None] - center_gt[..., 1] - bottom = center_gt[..., 3] - loc_ys[:, None] - center_bbox = torch.stack((left, top, right, bottom), -1) - inside_gt_bbox_mask = center_bbox.min(-1)[0] > 0 - return inside_gt_bbox_mask - - def _transpose(self, training_targets, num_loc_list): - ''' - This function is used to transpose image first training targets to level first ones - :return: level first training targets - ''' - if isinstance(training_targets[0], Boxes3D): - for im_i in range(len(training_targets)): - # training_targets[im_i] = torch.split(training_targets[im_i], num_loc_list, dim=0) - training_targets[im_i] = training_targets[im_i].split(num_loc_list, dim=0) - - targets_level_first = [] - for targets_per_level in zip(*training_targets): - targets_level_first.append(Boxes3D.cat(targets_per_level, dim=0)) - return targets_level_first - - for im_i in range(len(training_targets)): - training_targets[im_i] = torch.split(training_targets[im_i], num_loc_list, dim=0) - - targets_level_first = [] - for targets_per_level in zip(*training_targets): - targets_level_first.append(torch.cat(targets_per_level, dim=0)) - return targets_level_first diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/__init__.py deleted file mode 100755 index cea72f55c89cbc3d57bc9ae58e74144b27cc0530..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .vovnet import VoVNet - -__all__ = ['VoVNet'] \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/vovnet.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/vovnet.py deleted file mode 100755 index 879d186a37b49addaf27362cc6ae1e5465b2168e..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/backbones/vovnet.py +++ /dev/null @@ -1,375 +0,0 @@ - -from collections import OrderedDict -from mmcv.runner import BaseModule -from mmdet.models.builder import BACKBONES -import torch -import torch.nn as nn -import torch.nn.functional as F -from torch.nn.modules.batchnorm import _BatchNorm - - -VoVNet19_slim_dw_eSE = { - 'stem': [64, 64, 64], - 'stage_conv_ch': [64, 80, 96, 112], - 'stage_out_ch': [112, 256, 384, 512], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": True -} - -VoVNet19_dw_eSE = { - 'stem': [64, 64, 64], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": True -} - -VoVNet19_slim_eSE = { - 'stem': [64, 64, 128], - 'stage_conv_ch': [64, 80, 96, 112], - 'stage_out_ch': [112, 256, 384, 512], - 'layer_per_block': 3, - 'block_per_stage': [1, 1, 1, 1], - 'eSE': True, - "dw": False -} - -VoVNet19_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": False -} - -VoVNet39_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 1, 2, 2], - "eSE": True, - "dw": False -} - -VoVNet57_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 1, 4, 3], - "eSE": True, - "dw": False -} - -VoVNet99_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 3, 9, 3], - "eSE": True, - "dw": False -} - -_STAGE_SPECS = { - "V-19-slim-dw-eSE": VoVNet19_slim_dw_eSE, - "V-19-dw-eSE": VoVNet19_dw_eSE, - "V-19-slim-eSE": VoVNet19_slim_eSE, - "V-19-eSE": VoVNet19_eSE, - "V-39-eSE": VoVNet39_eSE, - "V-57-eSE": VoVNet57_eSE, - "V-99-eSE": VoVNet99_eSE, -} - - -def dw_conv3x3(in_channels, out_channels, module_name, postfix, stride=1, kernel_size=3, padding=1): - """3x3 convolution with padding""" - return [ - ( - '{}_{}/dw_conv3x3'.format(module_name, postfix), - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=out_channels, - bias=False - ) - ), - ( - '{}_{}/pw_conv1x1'.format(module_name, postfix), - nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0, groups=1, bias=False) - ), - ('{}_{}/pw_norm'.format(module_name, postfix), nn.BatchNorm2d(out_channels)), - ('{}_{}/pw_relu'.format(module_name, postfix), nn.ReLU(inplace=True)), - ] - - -def conv3x3(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=3, padding=1): - """3x3 convolution with padding""" - return [ - ( - f"{module_name}_{postfix}/conv", - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=groups, - bias=False, - ), - ), - (f"{module_name}_{postfix}/norm", nn.BatchNorm2d(out_channels)), - (f"{module_name}_{postfix}/relu", nn.ReLU(inplace=True)), - ] - - -def conv1x1(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=1, padding=0): - """1x1 convolution with padding""" - return [ - ( - f"{module_name}_{postfix}/conv", - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=groups, - bias=False, - ), - ), - (f"{module_name}_{postfix}/norm", nn.BatchNorm2d(out_channels)), - (f"{module_name}_{postfix}/relu", nn.ReLU(inplace=True)), - ] - - -class Hsigmoid(nn.Module): - def __init__(self, inplace=True): - super(Hsigmoid, self).__init__() - self.inplace = inplace - - def forward(self, x): - return F.relu6(x + 3.0, inplace=self.inplace) / 6.0 - - -class eSEModule(nn.Module): - def __init__(self, channel, reduction=4): - super(eSEModule, self).__init__() - self.avg_pool = nn.AdaptiveAvgPool2d(1) - self.fc = nn.Conv2d(channel, channel, kernel_size=1, padding=0) - self.hsigmoid = Hsigmoid() - - def forward(self, x): - input = x - x = self.avg_pool(x) - x = self.fc(x) - x = self.hsigmoid(x) - return input * x - - -class _OSA_module(nn.Module): - def __init__( - self, in_ch, stage_ch, concat_ch, layer_per_block, module_name, SE=False, identity=False, depthwise=False - ): - - super(_OSA_module, self).__init__() - - self.identity = identity - self.depthwise = depthwise - self.isReduced = False - self.layers = nn.ModuleList() - in_channel = in_ch - if self.depthwise and in_channel != stage_ch: - self.isReduced = True - self.conv_reduction = nn.Sequential( - OrderedDict(conv1x1(in_channel, stage_ch, "{}_reduction".format(module_name), "0")) - ) - for i in range(layer_per_block): - if self.depthwise: - self.layers.append(nn.Sequential(OrderedDict(dw_conv3x3(stage_ch, stage_ch, module_name, i)))) - else: - self.layers.append(nn.Sequential(OrderedDict(conv3x3(in_channel, stage_ch, module_name, i)))) - in_channel = stage_ch - - # feature aggregation - in_channel = in_ch + layer_per_block * stage_ch - self.concat = nn.Sequential(OrderedDict(conv1x1(in_channel, concat_ch, module_name, "concat"))) - - self.ese = eSEModule(concat_ch) - - def forward(self, x): - - identity_feat = x - - output = [] - output.append(x) - if self.depthwise and self.isReduced: - x = self.conv_reduction(x) - for layer in self.layers: - x = layer(x) - output.append(x) - - x = torch.cat(output, dim=1) - xt = self.concat(x) - - xt = self.ese(xt) - - if self.identity: - xt = xt + identity_feat - - return xt - - -class _OSA_stage(nn.Sequential): - def __init__( - self, in_ch, stage_ch, concat_ch, block_per_stage, layer_per_block, stage_num, SE=False, depthwise=False - ): - - super(_OSA_stage, self).__init__() - - if not stage_num == 2: - self.add_module("Pooling", nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True)) - - if block_per_stage != 1: - SE = False - module_name = f"OSA{stage_num}_1" - self.add_module( - module_name, _OSA_module(in_ch, stage_ch, concat_ch, layer_per_block, module_name, SE, depthwise=depthwise) - ) - for i in range(block_per_stage - 1): - if i != block_per_stage - 2: # last block - SE = False - module_name = f"OSA{stage_num}_{i + 2}" - self.add_module( - module_name, - _OSA_module( - concat_ch, - stage_ch, - concat_ch, - layer_per_block, - module_name, - SE, - identity=True, - depthwise=depthwise - ), - ) - - -@BACKBONES.register_module() -class VoVNet(BaseModule): - def __init__(self, spec_name, input_ch=3, out_features=None, - frozen_stages=-1, norm_eval=True, pretrained=None, init_cfg=None): - """ - Args: - input_ch(int) : the number of input channel - out_features (list[str]): name of the layers whose outputs should - be returned in forward. Can be anything in "stem", "stage2" ... - """ - super(VoVNet, self).__init__(init_cfg) - self.frozen_stages = frozen_stages - self.norm_eval = norm_eval - - if isinstance(pretrained, str): - warnings.warn('DeprecationWarning: pretrained is deprecated, ' - 'please use "init_cfg" instead') - self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) - stage_specs = _STAGE_SPECS[spec_name] - - stem_ch = stage_specs["stem"] - config_stage_ch = stage_specs["stage_conv_ch"] - config_concat_ch = stage_specs["stage_out_ch"] - block_per_stage = stage_specs["block_per_stage"] - layer_per_block = stage_specs["layer_per_block"] - SE = stage_specs["eSE"] - depthwise = stage_specs["dw"] - - self._out_features = out_features - - # Stem module - conv_type = dw_conv3x3 if depthwise else conv3x3 - stem = conv3x3(input_ch, stem_ch[0], "stem", "1", 2) - stem += conv_type(stem_ch[0], stem_ch[1], "stem", "2", 1) - stem += conv_type(stem_ch[1], stem_ch[2], "stem", "3", 2) - self.add_module("stem", nn.Sequential((OrderedDict(stem)))) - current_stirde = 4 - self._out_feature_strides = {"stem": current_stirde, "stage2": current_stirde} - self._out_feature_channels = {"stem": stem_ch[2]} - - stem_out_ch = [stem_ch[2]] - in_ch_list = stem_out_ch + config_concat_ch[:-1] - # OSA stages - self.stage_names = [] - for i in range(4): # num_stages - name = "stage%d" % (i + 2) # stage 2 ... stage 5 - self.stage_names.append(name) - self.add_module( - name, - _OSA_stage( - in_ch_list[i], - config_stage_ch[i], - config_concat_ch[i], - block_per_stage[i], - layer_per_block, - i + 2, - SE, - depthwise, - ), - ) - - self._out_feature_channels[name] = config_concat_ch[i] - if not i == 0: - self._out_feature_strides[name] = current_stirde = int(current_stirde * 2) - - # initialize weights - # self._initialize_weights() - - def _initialize_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - nn.init.kaiming_normal_(m.weight) - - def forward(self, x): - outputs = {} - x = self.stem(x) - if "stem" in self._out_features: - outputs["stem"] = x - for name in self.stage_names: - x = getattr(self, name)(x) - if name in self._out_features: - outputs[name] = x - - return outputs - - def _freeze_stages(self): - if self.frozen_stages >= 0: - m = getattr(self, 'stem') - m.eval() - for param in m.parameters(): - param.requires_grad = False - - for i in range(1, self.frozen_stages + 1): - m = getattr(self, f'stage{i+1}') - m.eval() - for param in m.parameters(): - param.requires_grad = False - - def train(self, mode=True): - """Convert the model into training mode while keep normalization layer - freezed.""" - super(VoVNet, self).train(mode) - self._freeze_stages() - if mode and self.norm_eval: - for m in self.modules(): - # trick: eval have effect on BatchNorm only - if isinstance(m, _BatchNorm): - m.eval() \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/__init__.py deleted file mode 100644 index 93b13c9c853d6f7eece8ae2dc7aa67d4e87db68b..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .hooks import GradChecker \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/hooks.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/hooks.py deleted file mode 100644 index 56ff7fd575c890e60ce49eb618df157b2cc2ca37..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/hooks/hooks.py +++ /dev/null @@ -1,13 +0,0 @@ -from mmcv.runner.hooks.hook import HOOKS, Hook -from projects.mmdet3d_plugin.models.utils import run_time - - -@HOOKS.register_module() -class GradChecker(Hook): - - def after_train_iter(self, runner): - for key, val in runner.model.named_parameters(): - if val.grad == None and val.requires_grad: - print('WARNNING: {key}\'s parameters are not be used!!!!'.format(key=key)) - - diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/__init__.py deleted file mode 100644 index c7dd426868a61772bbe0926e435ce89f15009805..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .adamw import AdamW2 \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/adamw.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/adamw.py deleted file mode 100644 index c890aeaf04721580c11ca329f2be09a6a280f773..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/opt/adamw.py +++ /dev/null @@ -1,131 +0,0 @@ -try: - from torch.optim import _functional as F -except: - print('WARNING!!!, I recommend using torch>=1.8') - -import torch -from torch.optim.optimizer import Optimizer -from mmcv.runner.optimizer.builder import OPTIMIZERS - -@OPTIMIZERS.register_module() -class AdamW2(Optimizer): - r"""Implements AdamW algorithm. Solve the bug of torch 1.8 - - The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. - The AdamW variant was proposed in `Decoupled Weight Decay Regularization`_. - - Args: - params (iterable): iterable of parameters to optimize or dicts defining - parameter groups - lr (float, optional): learning rate (default: 1e-3) - betas (Tuple[float, float], optional): coefficients used for computing - running averages of gradient and its square (default: (0.9, 0.999)) - eps (float, optional): term added to the denominator to improve - numerical stability (default: 1e-8) - weight_decay (float, optional): weight decay coefficient (default: 1e-2) - amsgrad (boolean, optional): whether to use the AMSGrad variant of this - algorithm from the paper `On the Convergence of Adam and Beyond`_ - (default: False) - - .. _Adam\: A Method for Stochastic Optimization: - https://arxiv.org/abs/1412.6980 - .. _Decoupled Weight Decay Regularization: - https://arxiv.org/abs/1711.05101 - .. _On the Convergence of Adam and Beyond: - https://openreview.net/forum?id=ryQu7f-RZ - """ - - def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, - weight_decay=1e-2, amsgrad=False): - if not 0.0 <= lr: - raise ValueError("Invalid learning rate: {}".format(lr)) - if not 0.0 <= eps: - raise ValueError("Invalid epsilon value: {}".format(eps)) - if not 0.0 <= betas[0] < 1.0: - raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) - if not 0.0 <= betas[1] < 1.0: - raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) - if not 0.0 <= weight_decay: - raise ValueError("Invalid weight_decay value: {}".format(weight_decay)) - defaults = dict(lr=lr, betas=betas, eps=eps, - weight_decay=weight_decay, amsgrad=amsgrad) - super(AdamW2, self).__init__(params, defaults) - - def __setstate__(self, state): - super(AdamW2, self).__setstate__(state) - for group in self.param_groups: - group.setdefault('amsgrad', False) - - @torch.no_grad() - def step(self, closure=None): - """Performs a single optimization step. - - Args: - closure (callable, optional): A closure that reevaluates the model - and returns the loss. - """ - loss = None - if closure is not None: - with torch.enable_grad(): - loss = closure() - - for group in self.param_groups: - params_with_grad = [] - grads = [] - exp_avgs = [] - exp_avg_sqs = [] - state_sums = [] - max_exp_avg_sqs = [] - state_steps = [] - amsgrad = group['amsgrad'] - - # put this line here for solving bug - beta1, beta2 = group['betas'] - - for p in group['params']: - if p.grad is None: - continue - params_with_grad.append(p) - if p.grad.is_sparse: - raise RuntimeError('AdamW does not support sparse gradients') - grads.append(p.grad) - - state = self.state[p] - - # State initialization - if len(state) == 0: - state['step'] = 0 - # Exponential moving average of gradient values - state['exp_avg'] = torch.zeros_like(p, memory_format=torch.preserve_format) - # Exponential moving average of squared gradient values - state['exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - if amsgrad: - # Maintains max of all exp. moving avg. of sq. grad. values - state['max_exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - - exp_avgs.append(state['exp_avg']) - exp_avg_sqs.append(state['exp_avg_sq']) - - if amsgrad: - max_exp_avg_sqs.append(state['max_exp_avg_sq']) - - - # update the steps for each param group update - state['step'] += 1 - # record the step after step update - state_steps.append(state['step']) - - F.adamw(params_with_grad, - grads, - exp_avgs, - exp_avg_sqs, - max_exp_avg_sqs, - state_steps, - amsgrad, - beta1, - beta2, - group['lr'], - group['weight_decay'], - group['eps']) - - return loss \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/__init__.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/__init__.py deleted file mode 100755 index 1df10c81ebce83ce7bc1aad6de30f26d4848a3e2..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ - -from .bricks import run_time -from .grid_mask import GridMask -from .position_embedding import RelPositionEmbedding -from .visual import save_tensor \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/bricks.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/bricks.py deleted file mode 100644 index fd458813d9ffced23b79799daa84150ba887774e..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/bricks.py +++ /dev/null @@ -1,20 +0,0 @@ -import functools -import time -from collections import defaultdict -import torch -time_maps = defaultdict(lambda :0.) -count_maps = defaultdict(lambda :0.) -def run_time(name): - def middle(fn): - def wrapper(*args, **kwargs): - torch.cuda.synchronize() - start = time.time() - res = fn(*args, **kwargs) - torch.cuda.synchronize() - time_maps['%s : %s'%(name, fn.__name__) ] += time.time()-start - count_maps['%s : %s'%(name, fn.__name__) ] +=1 - print("%s : %s takes up %f "% (name, fn.__name__,time_maps['%s : %s'%(name, fn.__name__) ] /count_maps['%s : %s'%(name, fn.__name__) ] )) - return res - return wrapper - return middle - \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/grid_mask.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/grid_mask.py deleted file mode 100755 index 3d04b2c470a24b55fd5a60ca6c679fa9710bc1a7..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/grid_mask.py +++ /dev/null @@ -1,124 +0,0 @@ -import torch -import torch.nn as nn -import numpy as np -from PIL import Image -from mmcv.runner import force_fp32, auto_fp16 - -class Grid(object): - def __init__(self, use_h, use_w, rotate = 1, offset=False, ratio = 0.5, mode=0, prob = 1.): - self.use_h = use_h - self.use_w = use_w - self.rotate = rotate - self.offset = offset - self.ratio = ratio - self.mode=mode - self.st_prob = prob - self.prob = prob - - def set_prob(self, epoch, max_epoch): - self.prob = self.st_prob * epoch / max_epoch - - def __call__(self, img, label): - if np.random.rand() > self.prob: - return img, label - h = img.size(1) - w = img.size(2) - self.d1 = 2 - self.d2 = min(h, w) - hh = int(1.5*h) - ww = int(1.5*w) - d = np.random.randint(self.d1, self.d2) - if self.ratio == 1: - self.l = np.random.randint(1, d) - else: - self.l = min(max(int(d*self.ratio+0.5),1),d-1) - mask = np.ones((hh, ww), np.float32) - st_h = np.random.randint(d) - st_w = np.random.randint(d) - if self.use_h: - for i in range(hh//d): - s = d*i + st_h - t = min(s+self.l, hh) - mask[s:t,:] *= 0 - if self.use_w: - for i in range(ww//d): - s = d*i + st_w - t = min(s+self.l, ww) - mask[:,s:t] *= 0 - - r = np.random.randint(self.rotate) - mask = Image.fromarray(np.uint8(mask)) - mask = mask.rotate(r) - mask = np.asarray(mask) - mask = mask[(hh-h)//2:(hh-h)//2+h, (ww-w)//2:(ww-w)//2+w] - - mask = torch.from_numpy(mask).float() - if self.mode == 1: - mask = 1-mask - - mask = mask.expand_as(img) - if self.offset: - offset = torch.from_numpy(2 * (np.random.rand(h,w) - 0.5)).float() - offset = (1 - mask) * offset - img = img * mask + offset - else: - img = img * mask - - return img, label - - -class GridMask(nn.Module): - def __init__(self, use_h, use_w, rotate = 1, offset=False, ratio = 0.5, mode=0, prob = 1.): - super(GridMask, self).__init__() - self.use_h = use_h - self.use_w = use_w - self.rotate = rotate - self.offset = offset - self.ratio = ratio - self.mode = mode - self.st_prob = prob - self.prob = prob - self.fp16_enable = False - def set_prob(self, epoch, max_epoch): - self.prob = self.st_prob * epoch / max_epoch #+ 1.#0.5 - @auto_fp16() - def forward(self, x): - if np.random.rand() > self.prob or not self.training: - return x - n,c,h,w = x.size() - x = x.view(-1,h,w) - hh = int(1.5*h) - ww = int(1.5*w) - d = np.random.randint(2, h) - self.l = min(max(int(d*self.ratio+0.5),1),d-1) - mask = np.ones((hh, ww), np.float32) - st_h = np.random.randint(d) - st_w = np.random.randint(d) - if self.use_h: - for i in range(hh//d): - s = d*i + st_h - t = min(s+self.l, hh) - mask[s:t,:] *= 0 - if self.use_w: - for i in range(ww//d): - s = d*i + st_w - t = min(s+self.l, ww) - mask[:,s:t] *= 0 - - r = np.random.randint(self.rotate) - mask = Image.fromarray(np.uint8(mask)) - mask = mask.rotate(r) - mask = np.asarray(mask) - mask = mask[(hh-h)//2:(hh-h)//2+h, (ww-w)//2:(ww-w)//2+w] - - mask = torch.from_numpy(mask).to(x.dtype).cuda() - if self.mode == 1: - mask = 1-mask - mask = mask.expand_as(x) - if self.offset: - offset = torch.from_numpy(2 * (np.random.rand(h,w) - 0.5)).to(x.dtype).cuda() - x = x * mask + offset * (1 - mask) - else: - x = x * mask - - return x.view(n,c,h,w) \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/position_embedding.py b/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/position_embedding.py deleted file mode 100644 index 290110fef7cb86c5edafb0b33da3bed794e6f7a9..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/projects/mmdet3d_plugin/models/utils/position_embedding.py +++ /dev/null @@ -1,34 +0,0 @@ -import torch -import torch.nn as nn -import math - -class RelPositionEmbedding(nn.Module): - def __init__(self, num_pos_feats=64, pos_norm=True): - super().__init__() - self.num_pos_feats = num_pos_feats - self.fc = nn.Linear(4, self.num_pos_feats,bias=False) - #nn.init.orthogonal_(self.fc.weight) - #self.fc.weight.requires_grad = False - self.pos_norm = pos_norm - if self.pos_norm: - self.norm = nn.LayerNorm(self.num_pos_feats) - def forward(self, tensor): - #mask = nesttensor.mask - B,C,H,W = tensor.shape - #print('tensor.shape', tensor.shape) - y_range = (torch.arange(H) / float(H - 1)).to(tensor.device) - #y_axis = torch.stack((y_range, 1-y_range),dim=1) - y_axis = torch.stack((torch.cos(y_range * math.pi), torch.sin(y_range * math.pi)), dim=1) - y_axis = y_axis.reshape(H, 1, 2).repeat(1, W, 1).reshape(H * W, 2) - - x_range = (torch.arange(W) / float(W - 1)).to(tensor.device) - #x_axis =torch.stack((x_range,1-x_range),dim=1) - x_axis = torch.stack((torch.cos(x_range * math.pi), torch.sin(x_range * math.pi)), dim=1) - x_axis = x_axis.reshape(1, W, 2).repeat(H, 1, 1).reshape(H * W, 2) - x_pos = torch.cat((y_axis, x_axis), dim=1) - x_pos = self.fc(x_pos) - - if self.pos_norm: - x_pos = self.norm(x_pos) - #print('xpos,', x_pos.max(),x_pos.min()) - return x_pos \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/start_bevformer.sh b/docker-hub/BEVFormer/BEVFormer/start_bevformer.sh deleted file mode 100644 index c8de619f1c038fc7a831f5b9aa44baf4664d2708..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/start_bevformer.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -export NCCL_TOPO_FILE=null -export NCCL_ALGO=Ring -export NCCL_RINGS="N0 0 7 6 5 4 3 2 1 N0|N1 1 2 3 4 5 6 7 0 N1|N2 2 1 0 7 6 5 4 3 N2|N3 3 4 5 6 7 0 1 2 N3|N4 4 3 2 1 0 7 6 5 N4|N5 5 6 7 0 1 2 3 4 N5|N6 6 5 4 3 2 1 0 7 N6|N7 7 0 1 2 3 4 5 6 N7" - -export PYTORCH_MIOPEN_SUGGEST_NHWC=1 -export MIOPEN_FIND_MODE=1 -export ENABLE_MIOPEN_DEFORMER_CONV_FP16=TRUE - - -#export MIOPEN_ENABLE_LOGGING=1 # 打开MIOPEN LOGGING日志 default =0 -#export MIOPEN_ENABLE_LOGGING_CMD=1 # 输出日志CMD信息 default =0 -#export MIOPEN_LOG_LEVEL=6 # 设置日志打印level default=0 -#export ROCBLAS_LAYER=3 # 打开 rocblas输出日志 default=0 - -TIME=$(date "+%Y-%m-%d_%H_%M") - -MASTER_ADDR=${1:-localhost} -NNODES=${2:-1} -NODE_RANK=${3:-0} -CONFIG=${4:-./projects/configs/bevformer/bevformer_base.py} - -bash tools/dist_train_numa.sh $MASTER_ADDR $NNODES $NODE_RANK $CONFIG \ - 2>&1 | tee cvm_bw1000_bevformer_base_${NNODES}nodes_$TIME.log -~ \ No newline at end of file diff --git a/docker-hub/BEVFormer/BEVFormer/tools/dist_train_numa.sh b/docker-hub/BEVFormer/BEVFormer/tools/dist_train_numa.sh deleted file mode 100755 index 822bfee29bf8dd05fa6411cfd0202d6f27768649..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/tools/dist_train_numa.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -MASTER_ADDR=${1:-localhost} -MASTER_PORT=6000 -NNODES=${2:-1} -NODE_RANK=${3:-0} -GPUS_PER_NODE=8 -DISTRIBUTED_ARGS="--nproc_per_node $GPUS_PER_NODE --nnodes $NNODES --node_rank $NODE_RANK --master_addr $MASTER_ADDR --master_port $MASTER_PORT" - -CONFIG=$4 - -# add numa affinity config -PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ -torchrun $DISTRIBUTED_ARGS --no-python \ - bash -c ' - numa_map=( $(hy-smi --showtopo | grep "Numa Node" | awk "{print \$6}") ); - LOCAL_RANK=${LOCAL_RANK:-0} - NUMA_ID=${numa_map[$LOCAL_RANK]} - numactl --cpunodebind=${NUMA_ID} --membind=${NUMA_ID} python $(dirname "$0")/tools/train.py "$@" - ' _ $CONFIG --launcher pytorch ${@:5} --deterministic diff --git a/docker-hub/BEVFormer/BEVFormer/tools/fp16/train.py b/docker-hub/BEVFormer/BEVFormer/tools/fp16/train.py deleted file mode 100644 index eddc34952266773a6035c5acf76f8fe61945a632..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/BEVFormer/tools/fp16/train.py +++ /dev/null @@ -1,271 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from __future__ import division - -import argparse -import copy -import mmcv -import os -import time -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.runner import get_dist_info, init_dist, wrap_fp16_model -from os import path as osp - -from mmdet import __version__ as mmdet_version -from mmdet3d import __version__ as mmdet3d_version -#from mmdet3d.apis import train_model - -from mmdet3d.datasets import build_dataset -from mmdet3d.models import build_model -from mmdet3d.utils import collect_env, get_root_logger -from mmdet.apis import set_random_seed -from mmseg import __version__ as mmseg_version - -from mmcv.utils import TORCH_VERSION, digit_version - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a detector') - parser.add_argument('config', help='train config file path') - parser.add_argument('--work-dir', help='the dir to save logs and models') - parser.add_argument( - '--resume-from', help='the checkpoint file to resume from') - parser.add_argument( - '--no-validate', - action='store_true', - help='whether not to evaluate the checkpoint during training') - group_gpus = parser.add_mutually_exclusive_group() - group_gpus.add_argument( - '--gpus', - type=int, - help='number of gpus to use ' - '(only applicable to non-distributed training)') - group_gpus.add_argument( - '--gpu-ids', - type=int, - nargs='+', - help='ids of gpus to use ' - '(only applicable to non-distributed training)') - parser.add_argument('--seed', type=int, default=0, help='random seed') - parser.add_argument( - '--deterministic', - action='store_true', - help='whether to set deterministic options for CUDNN backend.') - parser.add_argument( - '--options', - nargs='+', - action=DictAction, - help='override some settings in the used config, the key-value pair ' - 'in xxx=yyy format will be merged into config file (deprecate), ' - 'change to --cfg-options instead.') - parser.add_argument( - '--cfg-options', - nargs='+', - action=DictAction, - help='override some settings in the used config, the key-value pair ' - 'in xxx=yyy format will be merged into config file. If the value to ' - 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' - 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' - 'Note that the quotation marks are necessary and that no white space ' - 'is allowed.') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - parser.add_argument( - '--autoscale-lr', - action='store_true', - help='automatically scale lr with the number of gpus') - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - - if args.options and args.cfg_options: - raise ValueError( - '--options and --cfg-options cannot be both specified, ' - '--options is deprecated in favor of --cfg-options') - if args.options: - warnings.warn('--options is deprecated in favor of --cfg-options') - args.cfg_options = args.options - - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - if args.cfg_options is not None: - cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - from projects.mmdet3d_plugin.bevformer.apis import custom_train_model - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - - # work_dir is determined in this priority: CLI > segment in file > filename - if args.work_dir is not None: - # update configs according to CLI args if args.work_dir is not None - cfg.work_dir = args.work_dir - elif cfg.get('work_dir', None) is None: - # use config filename as default work_dir if cfg.work_dir is None - cfg.work_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0]) - #if args.resume_from is not None: - - if args.resume_from is not None and osp.isfile(args.resume_from): - cfg.resume_from = args.resume_from - - if args.gpu_ids is not None: - cfg.gpu_ids = args.gpu_ids - else: - cfg.gpu_ids = range(1) if args.gpus is None else range(args.gpus) - if digit_version(TORCH_VERSION) != digit_version('1.8.1'): - cfg.optimizer['type'] = 'AdamW' - if args.autoscale_lr: - # apply the linear scaling rule (https://arxiv.org/abs/1706.02677) - cfg.optimizer['lr'] = cfg.optimizer['lr'] * len(cfg.gpu_ids) / 8 - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - assert False, 'DOT NOT SUPPORT!!!' - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - # re-set gpu_ids with distributed training mode - _, world_size = get_dist_info() - cfg.gpu_ids = range(world_size) - - # create work_dir - mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) - # dump config - cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config))) - # init the logger before other steps - timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime()) - log_file = osp.join(cfg.work_dir, f'{timestamp}.log') - # specify logger name, if we still use 'mmdet', the output info will be - # filtered and won't be saved in the log_file - # TODO: ugly workaround to judge whether we are training det or seg model - if cfg.model.type in ['EncoderDecoder3D']: - logger_name = 'mmseg' - else: - logger_name = 'mmdet' - logger = get_root_logger( - log_file=log_file, log_level=cfg.log_level, name=logger_name) - - # init the meta dict to record some important information such as - # environment info and seed, which will be logged - meta = dict() - # log env info - env_info_dict = collect_env() - env_info = '\n'.join([(f'{k}: {v}') for k, v in env_info_dict.items()]) - dash_line = '-' * 60 + '\n' - logger.info('Environment info:\n' + dash_line + env_info + '\n' + - dash_line) - meta['env_info'] = env_info - meta['config'] = cfg.pretty_text - - # log some basic info - logger.info(f'Distributed training: {distributed}') - logger.info(f'Config:\n{cfg.pretty_text}') - - # set random seeds - if args.seed is not None: - logger.info(f'Set random seed to {args.seed}, ' - f'deterministic: {args.deterministic}') - set_random_seed(args.seed, deterministic=args.deterministic) - cfg.seed = args.seed - meta['seed'] = args.seed - meta['exp_name'] = osp.basename(args.config) - - model = build_model( - cfg.model, - train_cfg=cfg.get('train_cfg'), - test_cfg=cfg.get('test_cfg')) - model.init_weights() - - eval_model_config = copy.deepcopy(cfg.model) - eval_model = build_model( - eval_model_config, - train_cfg=cfg.get('train_cfg'), - test_cfg=cfg.get('test_cfg')) - - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(eval_model) - - #eval_model.init_weights() - eval_model.load_state_dict(model.state_dict()) - - logger.info(f'Model:\n{model}') - from projects.mmdet3d_plugin.datasets import custom_build_dataset - datasets = [custom_build_dataset(cfg.data.train)] - if len(cfg.workflow) == 2: - val_dataset = copy.deepcopy(cfg.data.val) - # in case we use a dataset wrapper - if 'dataset' in cfg.data.train: - val_dataset.pipeline = cfg.data.train.dataset.pipeline - else: - val_dataset.pipeline = cfg.data.train.pipeline - # set test_mode=False here in deep copied config - # which do not affect AP/AR calculation later - # refer to https://mmdetection3d.readthedocs.io/en/latest/tutorials/customize_runtime.html#customize-workflow # noqa - val_dataset.test_mode = False - datasets.append(custom_build_dataset(val_dataset)) - if cfg.checkpoint_config is not None: - # save mmdet version, config file content and class names in - # checkpoints as meta data - cfg.checkpoint_config.meta = dict( - mmdet_version=mmdet_version, - mmseg_version=mmseg_version, - mmdet3d_version=mmdet3d_version, - config=cfg.pretty_text, - CLASSES=datasets[0].CLASSES, - PALETTE=datasets[0].PALETTE # for segmentors - if hasattr(datasets[0], 'PALETTE') else None) - # add an attribute for visualization convenience - model.CLASSES = datasets[0].CLASSES - custom_train_model( - model, - datasets, - cfg, - eval_model=eval_model, - distributed=distributed, - validate=(not args.no_validate), - timestamp=timestamp, - meta=meta) - - -if __name__ == '__main__': - main() diff --git a/docker-hub/BEVFormer/readme.md b/docker-hub/BEVFormer/readme.md deleted file mode 100644 index 9ab562d2429dfa67c7fb9e1dbcf26b6b3d83c944..0000000000000000000000000000000000000000 --- a/docker-hub/BEVFormer/readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# BEVformer - -## 快速执行 - -### 环境构建 - -``` -docker run -dit --network=host --name=bevformer --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal:/opt/hyhal:ro -v /public/opendas/DL_DATA/zijia:/data:ro harbor.sourcefind.cn:5443/dcu/admin/base/custom:pytorch2.5.1-driver-bevformer -``` - -数据集已完成处理在乌镇集群/public/opendas/DL_DATA/zijia路径内 - -### 代码执行 - -``` -## 代码已经在容器/workspace下了 -cd /workspace/BEVFormer -bash start_bevformer.sh -``` diff --git a/docker-hub/FlashOCC/Flashocc/README.md b/docker-hub/FlashOCC/Flashocc/README.md deleted file mode 100644 index ea12066aec932b2749e6475bda795711663abc69..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# FlashOcc: Fast and Memory-Efficient Occupancy Prediction via Channel-to-Height Plugin - - -
- -

-* Please note that the FPS here is measured with RTX3090 TensorRT FP16. - -# Panoptic-FlashOcc: An Efficient Baseline to Marry Semantic Occupancy with Panoptic via Instance Center - -
- -

-* Please note that the FPS here is measured with A100 GPU (PyTorch fp32 backend). - -## News -- **2024.09.16** Technical Report: FlashOcc can be insert to Bevdet with 1.1ms consumption while facilitating each other.[![arXiv](https://img.shields.io/badge/arXiv-Paper-.svg)](https://arxiv.org/abs/2409.11160) -- **2024.09.16** [Selected as reference algorithm for occupancy on horizon J6E/M](https://zhuanlan.zhihu.com/p/720461546) -- **2024.06.10** Release the code for Panoptic-FlashOCC -- **2024.04.17** Support for ray-iou metric -- **2024.03.22** Release the code for FlashOCCV2 -- **2024.02.03** [Release the training code for FlashOcc on UniOcc](https://github.com/drilistbox/FlashOCC_on_UniOcc_and_RenderOCC) -- **2024.01.20** [TensorRT Implement Writen In C++ With Cuda Acceleration](https://github.com/drilistbox/TRT_FlashOcc) -- **2023.12.23** Release the quick testing code via TensorRT in MMDeploy. -- **2023.11.28** Release the training code for FlashOCC. - - - - - -[![arXiv](https://img.shields.io/badge/arXiv-Paper-.svg)](https://arxiv.org/abs/2311.12058) -[![arXiv](https://img.shields.io/badge/arXiv-Paper-.svg)](https://arxiv.org/pdf/2406.10527) -[![arXiv](https://img.shields.io/badge/arXiv-Paper-.svg)](https://arxiv.org/abs/2409.11160) - - -This repository is an official implementation of [FlashOCC](https://arxiv.org/abs/2311.12058) - -
- -

- -and [Panoptic-FlashOCC](https://arxiv.org/pdf/2406.10527) - -
- -

- - -## Main Results -### 1. FlashOCC -| Config | Backbone | Input
Size | mIoU | FPS
(Hz) | Flops
(G) | Params
(M) | Model | Log | -|:---------------------------------------------------------------------------------------------------|:--------:|:----------:|:-------:|:-----------------------------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------:| -| [**BEVDetOCC (1f)**](projects/configs/bevdet_occ/bevdet-occ-r50.py) | R50 | 256x704 | 31.60 | 92.1 | [241.76](doc/mmdeploy_test.md) | [29.02](doc/mmdeploy_test.md) | [gdrive]() | [log]() | -| [**M0: FlashOCC (1f)**](projects/configs/flashocc/flashocc-r50.py) | R50 | 256x704 | 31.95 | [197.6](doc/mmdeploy_test.md) | [154.1](doc/mmdeploy_test.md) | [39.94](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/file/d/14my3jdqiIv6VIrkozQ6-ruEcBOPVlWGJ/view?usp=sharing) | [log](https://drive.google.com/file/d/1E-kaHxbTr6s3Qn70vhKpwJM8kejoNFxQ/view?usp=sharing) | -| [**M1: FlashOCC (1f)**](projects/configs/flashocc/flashocc-r50.py) | R50 | 256x704 | 32.08 | [152.7](doc/mmdeploy_test.md) | [248.57](doc/mmdeploy_test.md) | [44.74](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/file/d/1k9BzXB2nRyvXhqf7GQx3XNSej6Oq6I-B/view?usp=drive_link) | [log](https://drive.google.com/file/d/1NRm27wVZMSUylmZxsMedFSLr7729YEAV/view?usp=drive_link) | -| [**BEVDetOCC-4D-Stereo (2f)**](projects/configs/bevdet_occ/bevdet-occ-r50-4d-stereo.py) | R50 | 256x704 | 36.1 | - | - | - | [baidu](https://pan.baidu.com/s/1237QyV18zvRJ1pU3YzRItw?pwd=npe1) | [log](https://pan.baidu.com/s/1237QyV18zvRJ1pU3YzRItw?pwd=npe1) | -| [**M2:FlashOCC-4D-Stereo (2f)**](projects/configs/flashocc/flashocc-r50-4d-stereo.py) | R50 | 256x704 | 37.84 | - | - | - | [gdrive](https://drive.google.com/file/d/12WYaCdoZA8-A6_oh6vdLgOmqyEc3PNCe/view?usp=drive_link) | [log](https://drive.google.com/file/d/1eYvu9gUSQ7qk7w7lWPLrZMB0O2uKQUk3/view?usp=drive_link) | -| [**BEVDetOCC-4D-Stereo (2f)**](projects/configs/bevdet_occ/bevdet-occ-stbase-4d-stereo-512x1408.py) | Swin-B | 512x1408 | 42.0 | - | - | - | [baidu](https://pan.baidu.com/s/1237QyV18zvRJ1pU3YzRItw?pwd=npe1) | [log](https://pan.baidu.com/s/1237QyV18zvRJ1pU3YzRItw?pwd=npe1) | -| [**M3:FlashOCC-4D-Stereo (2f)**](projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_2e-4.py) | Swin-B | 512x1408 | 43.52 | - | [1490.77](doc/mmdeploy_test.md) | [144.99](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/file/d/1f6E6Bm6enIJETSEbfXs57M0iOUU997kU/view?usp=drive_link) | [log](https://drive.google.com/file/d/1tch-YK4ROGDGNmDcN5FZnOAvsbHe-iSU/view?usp=drive_link) | - -FPS are tested via TensorRT on 3090 with FP16 precision. Please refer to Tab.2 in paper for the detail model settings for M-number. - -### 2. Panoptic-FlashOCC -**In Panoptic-FlashOCC, we have made the following 3 adjustments to FlashOCC**: -- Without using camera mask for training. This is because its use significantly improves the prediction performance in the visible region, but at the expense of prediction in the invisible region. -- Using category balancing. -- Using stronger loss settings. -- Introducing instance center for panoptic occupancy - -**More results for different configurations will be released soon.** - -| Config | Backbone | Input
Size | RayIou | RayPQ | mIoU | FPS
(Hz) | Flops
(G) | Params
(M) | Model | Log | -|:--------------------------------------------------------------------------------|:--------:|:-----------:|:-------:|:------:|:------:|:------------:|:------------------------------:|:-----------------------------:|:-----------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------:| -| [**M1: FlashOCC (1f)**](projects/configs/flashocc/flashocc-r50.py) | R50 | 256x704 | - | - | 15.41 | - | [248.57](doc/mmdeploy_test.md) | [44.74](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/file/d/14XsvjSwp-vLpy_eBZzvKo3MAh-YWRHcu/view?usp=drive_link) | [log](https://drive.google.com/file/d/1cTDoauEmjhK9fReLDcA2zPZx4a6X3U1-/view?usp=drive_link) | -| [**Panoptic-FlashOCC-Depth-tiny (1f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny.py) | R50 | 256x704 | 34.57 | - | 28.83 | 43.9 | [175.00](doc/mmdeploy_test.md) | [45.32](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-Depth-tiny-Pano (1f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano.py) | R50 | 256x704 | 34.81 | 12.9 | 29.14 | 39.8 | [175.00](doc/mmdeploy_test.md) | [45.32](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-Depth (1f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth.py) | R50 | 256x704 | 34.93 | - | 28.91 | 38.7 | [269.47](doc/mmdeploy_test.md) | [50.12](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-Depth-Pano (1f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-pano.py) | R50 | 256x704 | 35.22 | 13.2 | 29.39 | 35.2 | [269.47](doc/mmdeploy_test.md) | [50.12](doc/mmdeploy_test.md) | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-4D-Depth (2f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d.py) | R50 | 256x704 | 35.99 | - | 29.57 | 35.9 | - | - | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-4D-Depth-Pano (2f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-pano.py) | R50 | 256x704 | 36.76 | 14.5 | 30.31 | 30.4 | - | - | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-4DLongterm-Depth (8f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py) | R50 | 256x704 | 38.51 | - | 31.49 | 35.6 | - | - | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | -| [**Panoptic-FlashOCC-4DLongterm-Depth-Pano (8f)**](projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py) | R50 | 256x704 | 38.50 | 16.0 | 31.57 | 30.2 | - | - | [gdrive](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | [log](https://drive.google.com/drive/folders/1cgCsbXgikoP10lj6DBC7Le9C-UOCIxlN?usp=sharing) | - -* Please note that the FPS here is measured with A100 GPU (PyTorch fp32 backend). - -## Get Started -1. [Environment Setup](doc/install.md) -2. [Model Training](doc/model_training.md) -3. [Quick Test Via TensorRT In MMDeploy](doc/mmdeploy_test.md) - -| Backend | mIOU | FPS(Hz) | -|----------|-------|---------| -| PyTorch-FP32 | 31.95 | - | -| TRT-FP32 | 30.78 | 96.2 | -| TRT-FP16 | 30.78 | 197.6 | -| TRT-FP16+INT8(PTQ) | 29.60 | 383.7 | -| TRT-INT8(PTQ) | 29.59 | 397.0 | - -4. [Visualization](doc/visualization.md) - * [flashocc] : A detail video can be found at [baidu](https://pan.baidu.com/s/1xfnFsj5IclpjJxIaOlI6dA?pwd=gype) -
- -

- - * [panoptic-flashocc] : first row is our prediction and second row is gt. -
- -

- -
- -

- - -5. [TensorRT Implement Writen In C++ With Cuda Acceleration](https://github.com/drilistbox/TRT_FlashOcc) - - -## Acknowledgement -Many thanks to the authors of [BEVDet](https://github.com/HuangJunJie2017/BEVDet), [FB-BEV](https://github.com/NVlabs/FB-BEV.git), -[RenderOcc](https://github.com/pmj110119/RenderOcc.git) and [SparseBEV](https://github.com/MCG-NJU/SparseBEV.git) - -## Bibtex -If this work is helpful for your research, please consider citing the following BibTeX entry. - -``` -@article{yu2024ultimatedo, - title={UltimateDO: An Efficient Framework to Marry Occupancy Prediction with 3D Object Detection via Channel2height}, - author={Yu, Zichen and Shu, Changyong}, - journal={arXiv preprint arXiv:2409.11160}, - year={2024} -} - -@article{yu2024panoptic, - title={Panoptic-FlashOcc: An Efficient Baseline to Marry Semantic Occupancy with Panoptic via Instance Center}, - author={Yu, Zichen and Shu, Changyong and Sun, Qianpu and Linghu, Junjie and Wei, Xiaobao and Yu, Jiangyong and Liu, Zongdai and Yang, Dawei and Li, Hui and Chen, Yan}, - journal={arXiv preprint arXiv:2406.10527}, - year={2024} -} - -@article{yu2023flashocc, - title={FlashOcc: Fast and Memory-Efficient Occupancy Prediction via Channel-to-Height Plugin}, - author={Zichen Yu and Changyong Shu and Jiajun Deng and Kangjie Lu and Zongdai Liu and Jiangyong Yu and Dawei Yang and Hui Li and Yan Chen}, - year={2023}, - eprint={2311.12058}, - archivePrefix={arXiv}, - primaryClass={cs.CV} -} -``` diff --git a/docker-hub/FlashOCC/Flashocc/data/nuscenes b/docker-hub/FlashOCC/Flashocc/data/nuscenes deleted file mode 120000 index 9c09f1a2ed6d85d1bcd1b7dbdd59cf4426de90be..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/data/nuscenes +++ /dev/null @@ -1 +0,0 @@ -/data/nuScenes \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/doc/install.md b/docker-hub/FlashOCC/Flashocc/doc/install.md deleted file mode 100644 index b86fd71bf16a43f2444f6e46e5a05f98323c992f..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/doc/install.md +++ /dev/null @@ -1,165 +0,0 @@ -## Environment Setup -step 1. Install environment for pytorch training -``` -conda create --name FlashOcc python=3.8.5 -conda activate FlashOcc -pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html -pip install mmcv-full==1.5.3 -pip install mmdet==2.25.1 -pip install mmsegmentation==0.25.0 - -sudo apt-get install python3-dev -sudo apt-get install libevent-dev -sudo apt-get groupinstall 'development tools' -export PATH=/usr/local/cuda/bin:$PATH -export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH -export CUDA_ROOT=/usr/local/cuda -pip install pycuda - -pip install lyft_dataset_sdk -pip install networkx==2.2 -pip install numba==0.53.0 -pip install numpy==1.23.5 -pip install nuscenes-devkit -pip install plyfile -pip install scikit-image -pip install tensorboard -pip install trimesh==2.35.39 -pip install setuptools==59.5.0 -pip install yapf==0.40.1 - -cd Path_to_FlashOcc -git clone git@github.com:Yzichen/FlashOCC.git - -cd Path_to_FlashOcc/FlashOcc -git clone https://github.com/open-mmlab/mmdetection3d.git - -cd Path_to_FlashOcc/FlashOcc/mmdetection3d -git checkout v1.0.0rc4 -pip install -v -e . - -cd Path_to_FlashOcc/FlashOcc/projects -pip install -v -e . -``` - -step 3. Prepare nuScenes dataset as introduced in [nuscenes_det.md](nuscenes_det.md) and create the pkl for FlashOCC by running: -```shell -python tools/create_data_bevdet.py -``` -thus, the folder will be ranged as following: -```shell script -└── Path_to_FlashOcc/ - └── data - └── nuscenes - ├── v1.0-trainval (existing) - ├── sweeps (existing) - ├── samples (existing) - ├── bevdetv2-nuscenes_infos_train.pkl (new) - └── bevdetv2-nuscenes_infos_val.pkl (new) -``` - -step 4. For Occupancy Prediction task, download (only) the 'gts' from [CVPR2023-3D-Occupancy-Prediction](https://github.com/CVPR2023-3D-Occupancy-Prediction/CVPR2023-3D-Occupancy-Prediction) and arrange the folder as: -```shell script -└── Path_to_FlashOcc/ - └── data - └── nuscenes - ├── v1.0-trainval (existing) - ├── sweeps (existing) - ├── samples (existing) - ├── gts (new) - ├── bevdetv2-nuscenes_infos_train.pkl (new) - └── bevdetv2-nuscenes_infos_val.pkl (new) -``` -(for panoptic occupancy), we follow the data setting in SparseOcc: - -(1) Download Occ3D-nuScenes occupancy GT from [gdrive](https://drive.google.com/file/d/1kiXVNSEi3UrNERPMz_CfiJXKkgts_5dY/view?usp=drive_link), unzip it, and save it to `data/nuscenes/occ3d`. - -(2) Generate the panoptic occupancy ground truth with `gen_instance_info.py`. The panoptic version of Occ3D will be saved to `data/nuscenes/occ3d_panoptic`. - - -step 5. CKPTS Preparation -(1) Download flashocc-r50-256x704.pth[https://drive.google.com/file/d/1k9BzXB2nRyvXhqf7GQx3XNSej6Oq6I-B/view] to Path_to_FlashOcc/FlashOcc/ckpts/, then run: -```shell script -bash tools/dist_test.sh projects/configs/flashocc/flashocc-r50.py ckpts/flashocc-r50-256x704.pth 4 --eval map -``` - -step 6. (Optional) Install mmdeploy for tensorrt testing -```shell script -conda activate FlashOcc -pip install Cython==0.29.24 - -### get tensorrt -wget https://developer.download.nvidia.com/compute/machine-learning/tensorrt/secure/8.4.0/tars/TensorRT-8.4.0.6.Linux.x86_64-gnu.cuda-11.6.cudnn8.3.tar.gz -export TENSORRT_DIR=Path_to_TensorRT-8.4.0.6 - -### get onnxruntime -ONNXRUNTIME_VERSION=1.8.1 -pip install onnxruntime-gpu==${ONNXRUNTIME_VERSION} -cd Path_to_your_onnxruntime -wget https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz \ - && tar -zxvf onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz -# export ONNXRUNTIME_DIR=/data01/shuchangyong/pkgs/onnxruntime-linux-x64-1.8.1 -export ONNXRUNTIME_DIR=Path_to_your_onnxruntime/onnxruntime-linux-x64-1.8.1 -cd Path_to_FlashOcc/FlashOcc/ -git clone git@github.com:drilistbox/mmdeploy.git -cd Path_to_FlashOcc/FlashOcc/mmdeploy -git submodule update --init --recursive -mkdir -p build -cd Path_to_FlashOcc/FlashOcc/mmdeploy/build -cmake -DMMDEPLOY_TARGET_BACKENDS="ort;trt" .. -make -j 16 -cd Path_to_FlashOcc/FlashOcc/mmdeploy -pip install -e . - -### build sdk -cd Path_to_pplcv/ -git clone https://github.com/openppl-public/ppl.cv.git -cd Path_to_pplcv/ppl.cv -export PPLCV_VERSION=0.7.0 -git checkout tags/v${PPLCV_VERSION} -b v${PPLCV_VERSION} -./build.sh cuda - -#pip install nvidia-tensorrt==8.4.0.6 -pip install nvidia-tensorrt==8.4.1.5 -pip install tensorrt -#pip install h5py -pip install spconv==2.3.6 - -export PATH=Path_to_TensorRT-8.4.0.6/bin:$PATH -export LD_LIBRARY_PATH=Path_to_TensorRT-8.4.0.6/lib:$LD_LIBRARY_PATH -export LIBRARY_PATH=Path_to_TensorRT-8.4.0.6/lib:$LIBRARY_PATH -``` - -## The finally overall rangement -1. Tensort -```shell script -└── Path_to_TensorRT-8.4.0.6 - └── TensorRT-8.4.0.6 -``` -2. FlashOcc -```shell script -└── Path_to_FlashOcc/ - └── data - └── nuscenes - ├── v1.0-trainval (existing) - ├── sweeps (existing) - ├── samples (existing) - ├── gts (new) - ├── bevdetv2-nuscenes_infos_train.pkl (new) - └── bevdetv2-nuscenes_infos_val.pkl (new) - └── doc - ├── install.md - └── trt_test.md - ├── figs - ├── mmdeploy (new) - ├── mmdetection3d (new) - ├── projects - ├── requirements - ├── tools - └── README.md -``` -3. ppl.cv -```shell script -└── Path_to_pplcv - └── ppl.cv -``` diff --git a/docker-hub/FlashOCC/Flashocc/doc/mmdeploy_test.md b/docker-hub/FlashOCC/Flashocc/doc/mmdeploy_test.md deleted file mode 100644 index 266da6e62b68e9b0d2fc530491173975eae42687..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/doc/mmdeploy_test.md +++ /dev/null @@ -1,143 +0,0 @@ -# trt inference speed -```shell -conda activate FlashOcc -1. cmd for M0 -exp_name=flashocc-r50-M0 -fold_name=flashocc -config=projects/configs/${fold_name}/${exp_name}-trt.py -checkpoint=ckpts/flashocc-r50-M0-256x704.pth -work_dir=work_dirs/${exp_name}/onnx_trt/ - -2. cmd for M1 -exp_name=flashocc-r50 -fold_name=flashocc -config=projects/configs/${fold_name}/${exp_name}-trt.py -checkpoint=ckpts/flashocc-r50-256x704.pth -work_dir=work_dirs/${exp_name}/onnx_trt/ - - -# int8 test. -engine=work_dirs/${exp_name}/onnx_trt/bevdet_int8_fuse.engine -python tools/convert_bevdet_to_TRT.py $config $checkpoint $work_dir --fuse-conv-bn --int8 --calib_num 256 -python tools/analysis_tools/benchmark_trt.py $config $engine --eval -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 4.58 -# ===> barrier - IoU = 34.13 -# ===> bicycle - IoU = 8.68 -# ===> bus - IoU = 34.9 -# ===> car - IoU = 40.48 -# ===> construction_vehicle - IoU = 15.99 -# ===> motorcycle - IoU = 15.49 -# ===> pedestrian - IoU = 13.58 -# ===> traffic_cone - IoU = 12.83 -# ===> trailer - IoU = 25.31 -# ===> truck - IoU = 28.08 -# ===> driveable_surface - IoU = 76.7 -# ===> other_flat - IoU = 31.5 -# ===> sidewalk - IoU = 45.01 -# ===> terrain - IoU = 49.63 -# ===> manmade - IoU = 35.72 -# ===> vegetation - IoU = 30.39 -# ===> mIoU of 6019 samples: 29.59 - -# int8+fp16 test. -engine=work_dirs/${exp_name}/onnx_trt/bevdet_int8_fp16_fuse.engine -python tools/convert_bevdet_to_TRT.py $config $checkpoint $work_dir --fuse-conv-bn --fp16 --int8 --calib_num 256 -python tools/analysis_tools/benchmark_trt.py $config $engine --eval -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 4.59 -# ===> barrier - IoU = 34.13 -# ===> bicycle - IoU = 8.71 -# ===> bus - IoU = 34.9 -# ===> car - IoU = 40.49 -# ===> construction_vehicle - IoU = 16.01 -# ===> motorcycle - IoU = 15.55 -# ===> pedestrian - IoU = 13.63 -# ===> traffic_cone - IoU = 12.86 -# ===> trailer - IoU = 25.33 -# ===> truck - IoU = 28.1 -# ===> driveable_surface - IoU = 76.7 -# ===> other_flat - IoU = 31.51 -# ===> sidewalk - IoU = 45.01 -# ===> terrain - IoU = 49.63 -# ===> manmade - IoU = 35.72 -# ===> vegetation - IoU = 30.39 -# ===> mIoU of 6019 samples: 29.6 - -# fp16 test -engine=work_dirs/${exp_name}/onnx_trt/bevdet_fp16_fuse.engine -python tools/convert_bevdet_to_TRT.py $config $checkpoint $work_dir --fuse-conv-bn --fp16 -python tools/analysis_tools/benchmark_trt.py $config $engine -python tools/analysis_tools/benchmark_trt.py $config $engine --eval -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 5.97 -# ===> barrier - IoU = 36.37 -# ===> bicycle - IoU = 10.14 -# ===> bus - IoU = 35.47 -# ===> car - IoU = 41.57 -# ===> construction_vehicle - IoU = 15.73 -# ===> motorcycle - IoU = 14.8 -# ===> pedestrian - IoU = 15.65 -# ===> traffic_cone - IoU = 14.46 -# ===> trailer - IoU = 27.47 -# ===> truck - IoU = 29.39 -# ===> driveable_surface - IoU = 77.14 -# ===> other_flat - IoU = 34.66 -# ===> sidewalk - IoU = 46.44 -# ===> terrain - IoU = 51.05 -# ===> manmade - IoU = 35.79 -# ===> vegetation - IoU = 31.19 -# ===> mIoU of 6019 samples: 30.78 - -# fp32 test -engine=work_dirs/${exp_name}/onnx_trt/bevdet_fuse.engine -python tools/convert_bevdet_to_TRT.py $config $checkpoint $work_dir --fuse-conv-bn -python tools/analysis_tools/benchmark_trt.py $config $engine -python tools/analysis_tools/benchmark_trt.py $config $engine --eval -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 5.97 -# ===> barrier - IoU = 36.37 -# ===> bicycle - IoU = 10.15 -# ===> bus - IoU = 35.46 -# ===> car - IoU = 41.56 -# ===> construction_vehicle - IoU = 15.73 -# ===> motorcycle - IoU = 14.78 -# ===> pedestrian - IoU = 15.64 -# ===> traffic_cone - IoU = 14.44 -# ===> trailer - IoU = 27.46 -# ===> truck - IoU = 29.39 -# ===> driveable_surface - IoU = 77.14 -# ===> other_flat - IoU = 34.68 -# ===> sidewalk - IoU = 46.44 -# ===> terrain - IoU = 51.05 -# ===> manmade - IoU = 35.79 -# ===> vegetation - IoU = 31.18 -# ===> mIoU of 6019 samples: 30.78 - -``` - - -3. cmd for flashoccv2 -``` -exp_name=flashoccv2-r50-depth -fold_name=flashoccv2 -config=projects/configs/${fold_name}/${exp_name}-trt.py -checkpoint=work_dirs/${exp_name}/epoch_24_ema.pth -work_dir=work_dirs/${exp_name}/onnx_trt/ - -# fp16 test -engine=work_dirs/${exp_name}/onnx_trt/bevdet_fp16_fuse.engine -python tools/convert_bevdet_to_TRT.py $config $checkpoint $work_dir --fuse-conv-bn --fp16 -python tools/analysis_tools/benchmark_trt.py $config $engine -python tools/analysis_tools/benchmark_trt.py $config $engine --eval -``` - -# Flops and params -```shell -python tools/analysis_tools/get_flops.py projects/configs/bevdet_occ/bevdet-occ-r50.py --modality image --shape 256 704 -python tools/analysis_tools/get_flops.py projects/configs/flashocc/flashocc-r50-M0.py --modality image --shape 256 704 -python tools/analysis_tools/get_flops.py projects/configs/flashocc/flashocc-r50.py --modality image --shape 256 704 -python tools/analysis_tools/get_flops.py projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408.py --modality image --shape 512 1408 -python tools/analysis_tools/get_flops.py projects/configs/flashoccv2/flashoccv2-r50-depth.py --modality image --shape 256 704 -python tools/analysis_tools/get_flops.py projects/configs/flashoccv2/flashoccv2-r50-depth-tiny.py --modality image --shape 256 704 -``` \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/doc/model_training.md b/docker-hub/FlashOCC/Flashocc/doc/model_training.md deleted file mode 100644 index fee2c6cab0f8f9466691876e97c125ffda84c339..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/doc/model_training.md +++ /dev/null @@ -1,29 +0,0 @@ - -#### Train model -```shell -# single gpu -python tools/train.py $config -# multiple gpu -./tools/dist_train.sh $config num_gpu -``` - -#### Test model -```shell -# single gpu -python tools/test.py $config $checkpoint --eval mAP -# multiple gpu -./tools/dist_test.sh $config $checkpoint num_gpu --eval mAP -# ray-iou metric -./tools/dist_test.sh $config $checkpoint num_gpu --eval ray-iou -``` - -#### FPS for Panoptic-FlashOcc -```shell -# for single-frame -python tools/analysis_tools/benchmark.py config ckpt -python tools/analysis_tools/benchmark.py config ckpt --w_pano - -# for multi-frame -python tools/analysis_tools/benchmark_sequential.py config ckpt -python tools/analysis_tools/benchmark_sequential.py config ckpt --w_pano -``` diff --git a/docker-hub/FlashOCC/Flashocc/doc/visualization.md b/docker-hub/FlashOCC/Flashocc/doc/visualization.md deleted file mode 100644 index 4b4c41e9835fd66bed5fe690763c3fab9e4ea8ab..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/doc/visualization.md +++ /dev/null @@ -1,17 +0,0 @@ - -# FlashOcc -```shell -# step 1. generate result -bash tools/dist_test.sh projects/configs/flashocc/flashocc-r50.py ckpts/flashocc-r50-256x704.pth 4 --eval map --eval-options show_dir=work_dirs/flashocc_r50/results -# step 2. visualization -python tools/analysis_tools/vis_occ.py work_dirs/flashocc_r50/results/ --root_path ./data/nuscenes --save_path ./vis -``` - -# Panoptic-FlashOcc -```shell - -exp_name=panoptic-flashocc-r50-depth4d-longterm8f-pano -python tools/vis_occ.py --config projects/configs/panoptic-flashocc/${exp_name}.py --weights work_dirs/${exp_name}/epoch_24_ema.pth --viz-dir vis/${exp_name} --draw-pano-gt - -``` - diff --git a/docker-hub/FlashOCC/Flashocc/figs/overview.png b/docker-hub/FlashOCC/Flashocc/figs/overview.png deleted file mode 100644 index 43393b70c6918d9c20a49a146393244863a06989..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/overview.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/pano.png b/docker-hub/FlashOCC/Flashocc/figs/pano.png deleted file mode 100644 index a07226d18247fda799e984b317bd09689bc7447d..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/pano.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.jpg b/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.jpg deleted file mode 100644 index 78c8318cf5c842cc036bda093ffea103b2857ea1..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.jpg and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.png b/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.png deleted file mode 100644 index f4a0b4cf573e4c47947989cd42f4610b087e643a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/panoptic_flashOcc.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/performance.png b/docker-hub/FlashOCC/Flashocc/figs/performance.png deleted file mode 100644 index d6e6381bdb92c5583ebc8acfb482c73cda8932c8..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/performance.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/performance_flashocc.jpg b/docker-hub/FlashOCC/Flashocc/figs/performance_flashocc.jpg deleted file mode 100644 index 80e89e9965ac1278dad5cb186cdc1cc83a7d7330..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/performance_flashocc.jpg and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/sem.png b/docker-hub/FlashOCC/Flashocc/figs/sem.png deleted file mode 100644 index 78202c16dedfbfb8b4b6b3eb4fbb17db10dcfa0a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/sem.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/figs/visualization.png b/docker-hub/FlashOCC/Flashocc/figs/visualization.png deleted file mode 100644 index e6aac9691146456673a0d3cb20a9dcc209ddd876..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/figs/visualization.png and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.cu b/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.cu deleted file mode 100644 index 8010eb8854a632321fc5db1643d805927bd312b7..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.cu +++ /dev/null @@ -1,747 +0,0 @@ -// Acknowledgments: https://github.com/tarashakhurana/4d-occ-forecasting -// Modified by Haisong Liu - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_D 1446 // 700 + 700 + 45 + 1 -#define MAX_STEP 1000 - -enum LossType {L1, L2, ABSREL}; -enum PhaseName {TEST, TRAIN}; - -template -__global__ void init_cuda_kernel( - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - torch::PackedTensorAccessor32 occupancy) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = occupancy.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - assert(T == 1 || t < T); - - // if t < 0, it is a padded point - if (t < 0) return; - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // grid shape - const int vzsize = occupancy.size(2); - const int vysize = occupancy.size(3); - const int vxsize = occupancy.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // end point - const int vx = int(points[n][c][0]); - const int vy = int(points[n][c][1]); - const int vz = int(points[n][c][2]); - - // - if (0 <= vx && vx < vxsize && - 0 <= vy && vy < vysize && - 0 <= vz && vz < vzsize) { - occupancy[n][ts][vz][vy][vx] = 1; - } - } -} - -template -__global__ void render_forward_cuda_kernel( - const torch::PackedTensorAccessor32 sigma, - const torch::PackedTensorAccessor32 origin, - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - // torch::PackedTensorAccessor32 pog, - torch::PackedTensorAccessor32 pred_dist, - torch::PackedTensorAccessor32 gt_dist, - torch::PackedTensorAccessor32 coord_index, - PhaseName train_phase) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = sigma.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - // assert(t < T); - assert(T == 1 || t < T); - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // if t < 0, it is a padded point - if (t < 0) return; - - // grid shape - const int vzsize = sigma.size(2); - const int vysize = sigma.size(3); - const int vxsize = sigma.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // origin - const double xo = origin[n][t][0]; - const double yo = origin[n][t][1]; - const double zo = origin[n][t][2]; - - // end point - const double xe = points[n][c][0]; - const double ye = points[n][c][1]; - const double ze = points[n][c][2]; - - // locate the voxel where the origin resides - const int vxo = int(xo); - const int vyo = int(yo); - const int vzo = int(zo); - - const int vxe = int(xe); - const int vye = int(ye); - const int vze = int(ze); - - // NOTE: new - int vx = vxo; - int vy = vyo; - int vz = vzo; - - // origin to end - const double rx = xe - xo; - const double ry = ye - yo; - const double rz = ze - zo; - double gt_d = sqrt(rx * rx + ry * ry + rz * rz); - - // directional vector - const double dx = rx / gt_d; - const double dy = ry / gt_d; - const double dz = rz / gt_d; - - // In which direction the voxel ids are incremented. - const int stepX = (dx >= 0) ? 1 : -1; - const int stepY = (dy >= 0) ? 1 : -1; - const int stepZ = (dz >= 0) ? 1 : -1; - - // Distance along the ray to the next voxel border from the current position (tMaxX, tMaxY, tMaxZ). - const double next_voxel_boundary_x = vx + (stepX < 0 ? 0 : 1); - const double next_voxel_boundary_y = vy + (stepY < 0 ? 0 : 1); - const double next_voxel_boundary_z = vz + (stepZ < 0 ? 0 : 1); - - // tMaxX, tMaxY, tMaxZ -- distance until next intersection with voxel-border - // the value of t at which the ray crosses the first vertical voxel boundary - double tMaxX = (dx!=0) ? (next_voxel_boundary_x - xo)/dx : DBL_MAX; // - double tMaxY = (dy!=0) ? (next_voxel_boundary_y - yo)/dy : DBL_MAX; // - double tMaxZ = (dz!=0) ? (next_voxel_boundary_z - zo)/dz : DBL_MAX; // - - // tDeltaX, tDeltaY, tDeltaZ -- - // how far along the ray we must move for the horizontal component to equal the width of a voxel - // the direction in which we traverse the grid - // can only be FLT_MAX if we never go in that direction - const double tDeltaX = (dx!=0) ? stepX/dx : DBL_MAX; - const double tDeltaY = (dy!=0) ? stepY/dy : DBL_MAX; - const double tDeltaZ = (dz!=0) ? stepZ/dz : DBL_MAX; - - int3 path[MAX_D]; - double csd[MAX_D]; // cumulative sum of sigma times delta - double p[MAX_D]; // alpha - double d[MAX_D]; - - // forward raymarching with voxel traversal - int step = 0; // total number of voxels traversed - int count = 0; // number of voxels traversed inside the voxel grid - double last_d = 0.0; // correct initialization - - // voxel traversal raycasting - bool was_inside = false; - while (true) { - bool inside = (0 <= vx && vx < vxsize) && - (0 <= vy && vy < vysize) && - (0 <= vz && vz < vzsize); - if (inside) { - was_inside = true; - path[count] = make_int3(vx, vy, vz); - } else if (was_inside) { // was but no longer inside - // we know we are not coming back so terminate - break; - } /*else if (last_d > gt_d) { - break; - } */ - /*else { // has not gone inside yet - // assert(count == 0); - // (1) when we have hit the destination but haven't gone inside the voxel grid - // (2) when we have traveled MAX_D voxels but haven't found one valid voxel - // handle intersection corner cases in case of infinite loop - bool hit = (vx == vxe && vy == vye && vz == vze); // this test seems brittle with corner cases - if (hit || step >= MAX_D) - break; - //if (last_d >= gt_d || step >= MAX_D) break; - } */ - // _d represents the ray distance has traveled before escaping the current voxel cell - double _d = 0.0; - // voxel traversal - if (tMaxX < tMaxY) { - if (tMaxX < tMaxZ) { - _d = tMaxX; - vx += stepX; - tMaxX += tDeltaX; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } else { - if (tMaxY < tMaxZ) { - _d = tMaxY; - vy += stepY; - tMaxY += tDeltaY; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } - if (inside) { - // get sigma at the current voxel - const int3 &v = path[count]; // use the recorded index - const double _sigma = sigma[n][ts][v.z][v.y][v.x]; - const double _delta = max(0.0, _d - last_d); // THIS TURNS OUT IMPORTANT - const double sd = _sigma * _delta; - if (count == 0) { // the first voxel inside - csd[count] = sd; - p[count] = 1 - exp(-sd); - } else { - csd[count] = csd[count-1] + sd; - p[count] = exp(-csd[count-1]) - exp(-csd[count]); - } - // record the traveled distance - d[count] = _d; - // count the number of voxels we have escaped - count ++; - } - last_d = _d; - step ++; - - if (step > MAX_STEP) { - break; - } - } - - // the total number of voxels visited should not exceed this number - assert(count <= MAX_D); - - if (count > 0) { - // compute the expected ray distance - //double exp_d = 0.0; - double exp_d = d[count-1]; - - const int3 &v_init = path[count-1]; - int x = v_init.x; - int y = v_init.y; - int z = v_init.z; - - for (int i = 0; i < count; i++) { - //printf("%f\t%f\n",p[i], d[i]); - //exp_d += p[i] * d[i]; - const int3 &v = path[i]; - const double occ = sigma[n][ts][v.z][v.y][v.x]; - if (occ > 0.5) { - exp_d = d[i]; - - x = v.x; - y = v.y; - z = v.z; - - break; - } - - } - //printf("%f\n",exp_d); - - // add an imaginary sample at the end point should gt_d exceeds max_d - double p_out = exp(-csd[count-1]); - double max_d = d[count-1]; - - // if (gt_d > max_d) - // exp_d += (p_out * gt_d); - - // p_out is the probability the ray escapes the voxel grid - //exp_d += (p_out * max_d); - if (train_phase == 1) { - gt_d = min(gt_d, max_d); - } - - // write the rendered ray distance (max_d) - pred_dist[n][c] = exp_d; - gt_dist[n][c] = gt_d; - - coord_index[n][c][0] = double(x); - coord_index[n][c][1] = double(y); - coord_index[n][c][2] = double(z); - - // // write occupancy - // for (int i = 0; i < count; i ++) { - // const int3 &v = path[i]; - // auto & occ = pog[n][t][v.z][v.y][v.x]; - // if (p[i] >= occ) { - // occ = p[i]; - // } - // } - } - } -} - -/* - * input shape - * sigma : N x T x H x L x W - * origin : N x T x 3 - * points : N x M x 4 - * output shape - * dist : N x M - */ -std::vector render_forward_cuda( - torch::Tensor sigma, - torch::Tensor origin, - torch::Tensor points, - torch::Tensor tindex, - const std::vector grid, - std::string phase_name) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto T = grid[0]; - const auto H = grid[1]; - const auto L = grid[2]; - const auto W = grid[3]; - - const auto device = sigma.device(); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // - // const auto dtype = points.dtype(); - // const auto options = torch::TensorOptions().dtype(dtype).device(device).requires_grad(false); - // auto pog = torch::zeros({N, T, H, L, W}, options); - - // perform rendering - auto gt_dist = -torch::ones({N, M}, device); - auto pred_dist = -torch::ones({N, M}, device); - - auto coord_index = torch::zeros({N, M, 3}, device); - - PhaseName train_phase; - if (phase_name.compare("test") == 0) { - train_phase = TEST; - } else if (phase_name.compare("train") == 0){ - train_phase = TRAIN; - } else { - std::cout << "UNKNOWN PHASE NAME: " << phase_name << std::endl; - exit(1); - } - - AT_DISPATCH_FLOATING_TYPES(sigma.type(), "render_forward_cuda", ([&] { - render_forward_cuda_kernel<<>>( - sigma.packed_accessor32(), - origin.packed_accessor32(), - points.packed_accessor32(), - tindex.packed_accessor32(), - // pog.packed_accessor32(), - pred_dist.packed_accessor32(), - gt_dist.packed_accessor32(), - coord_index.packed_accessor32(), - train_phase); - })); - - cudaDeviceSynchronize(); - - // return {pog, pred_dist, gt_dist}; - return {pred_dist, gt_dist, coord_index}; -} - -template -__global__ void render_cuda_kernel( - const torch::PackedTensorAccessor32 sigma, - const torch::PackedTensorAccessor32 origin, - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - // const torch::PackedTensorAccessor32 occupancy, - torch::PackedTensorAccessor32 pred_dist, - torch::PackedTensorAccessor32 gt_dist, - torch::PackedTensorAccessor32 grad_sigma, - // torch::PackedTensorAccessor32 grad_sigma_count, - LossType loss_type) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = sigma.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - // assert(t < T); - assert(T == 1 || t < T); - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // if t < 0, it is a padded point - if (t < 0) return; - - // grid shape - const int vzsize = sigma.size(2); - const int vysize = sigma.size(3); - const int vxsize = sigma.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // origin - const double xo = origin[n][t][0]; - const double yo = origin[n][t][1]; - const double zo = origin[n][t][2]; - - // end point - const double xe = points[n][c][0]; - const double ye = points[n][c][1]; - const double ze = points[n][c][2]; - - // locate the voxel where the origin resides - const int vxo = int(xo); - const int vyo = int(yo); - const int vzo = int(zo); - - // - const int vxe = int(xe); - const int vye = int(ye); - const int vze = int(ze); - - // NOTE: new - int vx = vxo; - int vy = vyo; - int vz = vzo; - - // origin to end - const double rx = xe - xo; - const double ry = ye - yo; - const double rz = ze - zo; - double gt_d = sqrt(rx * rx + ry * ry + rz * rz); - - // directional vector - const double dx = rx / gt_d; - const double dy = ry / gt_d; - const double dz = rz / gt_d; - - // In which direction the voxel ids are incremented. - const int stepX = (dx >= 0) ? 1 : -1; - const int stepY = (dy >= 0) ? 1 : -1; - const int stepZ = (dz >= 0) ? 1 : -1; - - // Distance along the ray to the next voxel border from the current position (tMaxX, tMaxY, tMaxZ). - const double next_voxel_boundary_x = vx + (stepX < 0 ? 0 : 1); - const double next_voxel_boundary_y = vy + (stepY < 0 ? 0 : 1); - const double next_voxel_boundary_z = vz + (stepZ < 0 ? 0 : 1); - - // tMaxX, tMaxY, tMaxZ -- distance until next intersection with voxel-border - // the value of t at which the ray crosses the first vertical voxel boundary - double tMaxX = (dx!=0) ? (next_voxel_boundary_x - xo)/dx : DBL_MAX; // - double tMaxY = (dy!=0) ? (next_voxel_boundary_y - yo)/dy : DBL_MAX; // - double tMaxZ = (dz!=0) ? (next_voxel_boundary_z - zo)/dz : DBL_MAX; // - - // tDeltaX, tDeltaY, tDeltaZ -- - // how far along the ray we must move for the horizontal component to equal the width of a voxel - // the direction in which we traverse the grid - // can only be FLT_MAX if we never go in that direction - const double tDeltaX = (dx!=0) ? stepX/dx : DBL_MAX; - const double tDeltaY = (dy!=0) ? stepY/dy : DBL_MAX; - const double tDeltaZ = (dz!=0) ? stepZ/dz : DBL_MAX; - - int3 path[MAX_D]; - double csd[MAX_D]; // cumulative sum of sigma times delta - double p[MAX_D]; // alpha - double d[MAX_D]; - double dt[MAX_D]; - - // forward raymarching with voxel traversal - int step = 0; // total number of voxels traversed - int count = 0; // number of voxels traversed inside the voxel grid - double last_d = 0.0; // correct initialization - - // voxel traversal raycasting - bool was_inside = false; - while (true) { - bool inside = (0 <= vx && vx < vxsize) && - (0 <= vy && vy < vysize) && - (0 <= vz && vz < vzsize); - if (inside) { // now inside - was_inside = true; - path[count] = make_int3(vx, vy, vz); - } else if (was_inside) { // was inside but no longer - // we know we are not coming back so terminate - break; - } else if (last_d > gt_d) { - break; - } /* else { // has not gone inside yet - // assert(count == 0); - // (1) when we have hit the destination but haven't gone inside the voxel grid - // (2) when we have traveled MAX_D voxels but haven't found one valid voxel - // handle intersection corner cases in case of infinite loop - // bool hit = (vx == vxe && vy == vye && vz == vze); - // if (hit || step >= MAX_D) - // break; - if (last_d >= gt_d || step >= MAX_D) break; - } */ - // _d represents the ray distance has traveled before escaping the current voxel cell - double _d = 0.0; - // voxel traversal - if (tMaxX < tMaxY) { - if (tMaxX < tMaxZ) { - _d = tMaxX; - vx += stepX; - tMaxX += tDeltaX; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } else { - if (tMaxY < tMaxZ) { - _d = tMaxY; - vy += stepY; - tMaxY += tDeltaY; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } - if (inside) { - // get sigma at the current voxel - const int3 &v = path[count]; // use the recorded index - const double _sigma = sigma[n][ts][v.z][v.y][v.x]; - const double _delta = max(0.0, _d - last_d); // THIS TURNS OUT IMPORTANT - const double sd = _sigma * _delta; - if (count == 0) { // the first voxel inside - csd[count] = sd; - p[count] = 1 - exp(-sd); - } else { - csd[count] = csd[count-1] + sd; - p[count] = exp(-csd[count-1]) - exp(-csd[count]); - } - // record the traveled distance - d[count] = _d; - dt[count] = _delta; - // count the number of voxels we have escaped - count ++; - } - last_d = _d; - step ++; - - if (step > MAX_STEP) { - break; - } - } - - // the total number of voxels visited should not exceed this number - assert(count <= MAX_D); - - // WHEN THERE IS AN INTERSECTION BETWEEN THE RAY AND THE VOXEL GRID - if (count > 0) { - // compute the expected ray distance - double exp_d = 0.0; - for (int i = 0; i < count; i ++) - exp_d += p[i] * d[i]; - - // add an imaginary sample at the end point should gt_d exceeds max_d - double p_out = exp(-csd[count-1]); - double max_d = d[count-1]; - - exp_d += (p_out * max_d); - gt_d = min(gt_d, max_d); - - // write the rendered ray distance (max_d) - pred_dist[n][c] = exp_d; - gt_dist[n][c] = gt_d; - - /* backward raymarching */ - double dd_dsigma[MAX_D]; - for (int i = count - 1; i >= 0; i --) { - // NOTE: probably need to double check again - if (i == count - 1) - dd_dsigma[i] = p_out * max_d; - else - dd_dsigma[i] = dd_dsigma[i+1] - exp(-csd[i]) * (d[i+1] - d[i]); - } - - for (int i = count - 1; i >= 0; i --) - dd_dsigma[i] *= dt[i]; - - // option 2: cap at the boundary - for (int i = count - 1; i >= 0; i --) - dd_dsigma[i] -= dt[i] * p_out * max_d; - - double dl_dd = 1.0; - if (loss_type == L1) - dl_dd = (exp_d >= gt_d) ? 1 : -1; - else if (loss_type == L2) - dl_dd = (exp_d - gt_d); - else if (loss_type == ABSREL) - dl_dd = (exp_d >= gt_d) ? (1.0/gt_d) : -(1.0/gt_d); - - // apply chain rule - for (int i = 0; i < count; i ++) { - const int3 &v = path[i]; - // NOTE: potential race conditions when writing gradients - grad_sigma[n][ts][v.z][v.y][v.x] += dl_dd * dd_dsigma[i]; - // grad_sigma_count[n][ts][v.z][v.y][v.x] += 1; - } - } - } -} - -/* - * input shape - * sigma : N x T x H x L x W - * origin : N x T x 3 - * points : N x M x 4 - * output shape - * dist : N x M - * loss : N x M - * grad_sigma : N x T x H x L x W - */ -std::vector render_cuda( - torch::Tensor sigma, - torch::Tensor origin, - torch::Tensor points, - torch::Tensor tindex, - std::string loss_name) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto device = sigma.device(); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // perform rendering - auto gt_dist = -torch::ones({N, M}, device); - auto pred_dist = -torch::ones({N, M}, device); - auto grad_sigma = torch::zeros_like(sigma); - // auto grad_sigma_count = torch::zeros_like(sigma); - - LossType loss_type; - if (loss_name.compare("l1") == 0) { - loss_type = L1; - } else if (loss_name.compare("l2") == 0) { - loss_type = L2; - } else if (loss_name.compare("absrel") == 0) { - loss_type = ABSREL; - } else if (loss_name.compare("bce") == 0){ - loss_type = L1; - } else { - std::cout << "UNKNOWN LOSS TYPE: " << loss_name << std::endl; - exit(1); - } - - AT_DISPATCH_FLOATING_TYPES(sigma.type(), "render_cuda", ([&] { - render_cuda_kernel<<>>( - sigma.packed_accessor32(), - origin.packed_accessor32(), - points.packed_accessor32(), - tindex.packed_accessor32(), - // occupancy.packed_accessor32(), - pred_dist.packed_accessor32(), - gt_dist.packed_accessor32(), - grad_sigma.packed_accessor32(), - // grad_sigma_count.packed_accessor32(), - loss_type); - })); - - cudaDeviceSynchronize(); - - // grad_sigma_count += (grad_sigma_count == 0); - // grad_sigma /= grad_sigma_count; - - return {pred_dist, gt_dist, grad_sigma}; -} - - -/* - * input shape - * origin : N x T x 3 - * points : N x M x 3 - * tindex : N x M - * output shape - * occupancy: N x T x H x L x W - */ -torch::Tensor init_cuda( - torch::Tensor points, - torch::Tensor tindex, - const std::vector grid) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto T = grid[0]; - const auto H = grid[1]; - const auto L = grid[2]; - const auto W = grid[3]; - - const auto dtype = points.dtype(); - const auto device = points.device(); - const auto options = torch::TensorOptions().dtype(dtype).device(device).requires_grad(false); - auto occupancy = torch::zeros({N, T, H, L, W}, options); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // initialize occupancy such that every voxel with one or more points is occupied - AT_DISPATCH_FLOATING_TYPES(points.type(), "init_cuda", ([&] { - init_cuda_kernel<<>>( - points.packed_accessor32(), - tindex.packed_accessor32(), - occupancy.packed_accessor32()); - })); - - // synchronize - cudaDeviceSynchronize(); - - return occupancy; -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.hip b/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.hip deleted file mode 100644 index 19f331da7836b5b37e167e8ef35505d5d50aa032..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/lib/dvr/dvr.hip +++ /dev/null @@ -1,749 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -// Acknowledgments: https://github.com/tarashakhurana/4d-occ-forecasting -// Modified by Haisong Liu - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_D 1446 // 700 + 700 + 45 + 1 -#define MAX_STEP 1000 - -enum LossType {L1, L2, ABSREL}; -enum PhaseName {TEST, TRAIN}; - -template -__global__ void init_cuda_kernel( - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - torch::PackedTensorAccessor32 occupancy) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = occupancy.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - assert(T == 1 || t < T); - - // if t < 0, it is a padded point - if (t < 0) return; - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // grid shape - const int vzsize = occupancy.size(2); - const int vysize = occupancy.size(3); - const int vxsize = occupancy.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // end point - const int vx = int(points[n][c][0]); - const int vy = int(points[n][c][1]); - const int vz = int(points[n][c][2]); - - // - if (0 <= vx && vx < vxsize && - 0 <= vy && vy < vysize && - 0 <= vz && vz < vzsize) { - occupancy[n][ts][vz][vy][vx] = 1; - } - } -} - -template -__global__ void render_forward_cuda_kernel( - const torch::PackedTensorAccessor32 sigma, - const torch::PackedTensorAccessor32 origin, - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - // torch::PackedTensorAccessor32 pog, - torch::PackedTensorAccessor32 pred_dist, - torch::PackedTensorAccessor32 gt_dist, - torch::PackedTensorAccessor32 coord_index, - PhaseName train_phase) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = sigma.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - // assert(t < T); - assert(T == 1 || t < T); - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // if t < 0, it is a padded point - if (t < 0) return; - - // grid shape - const int vzsize = sigma.size(2); - const int vysize = sigma.size(3); - const int vxsize = sigma.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // origin - const double xo = origin[n][t][0]; - const double yo = origin[n][t][1]; - const double zo = origin[n][t][2]; - - // end point - const double xe = points[n][c][0]; - const double ye = points[n][c][1]; - const double ze = points[n][c][2]; - - // locate the voxel where the origin resides - const int vxo = int(xo); - const int vyo = int(yo); - const int vzo = int(zo); - - const int vxe = int(xe); - const int vye = int(ye); - const int vze = int(ze); - - // NOTE: new - int vx = vxo; - int vy = vyo; - int vz = vzo; - - // origin to end - const double rx = xe - xo; - const double ry = ye - yo; - const double rz = ze - zo; - double gt_d = sqrt(rx * rx + ry * ry + rz * rz); - - // directional vector - const double dx = rx / gt_d; - const double dy = ry / gt_d; - const double dz = rz / gt_d; - - // In which direction the voxel ids are incremented. - const int stepX = (dx >= 0) ? 1 : -1; - const int stepY = (dy >= 0) ? 1 : -1; - const int stepZ = (dz >= 0) ? 1 : -1; - - // Distance along the ray to the next voxel border from the current position (tMaxX, tMaxY, tMaxZ). - const double next_voxel_boundary_x = vx + (stepX < 0 ? 0 : 1); - const double next_voxel_boundary_y = vy + (stepY < 0 ? 0 : 1); - const double next_voxel_boundary_z = vz + (stepZ < 0 ? 0 : 1); - - // tMaxX, tMaxY, tMaxZ -- distance until next intersection with voxel-border - // the value of t at which the ray crosses the first vertical voxel boundary - double tMaxX = (dx!=0) ? (next_voxel_boundary_x - xo)/dx : DBL_MAX; // - double tMaxY = (dy!=0) ? (next_voxel_boundary_y - yo)/dy : DBL_MAX; // - double tMaxZ = (dz!=0) ? (next_voxel_boundary_z - zo)/dz : DBL_MAX; // - - // tDeltaX, tDeltaY, tDeltaZ -- - // how far along the ray we must move for the horizontal component to equal the width of a voxel - // the direction in which we traverse the grid - // can only be FLT_MAX if we never go in that direction - const double tDeltaX = (dx!=0) ? stepX/dx : DBL_MAX; - const double tDeltaY = (dy!=0) ? stepY/dy : DBL_MAX; - const double tDeltaZ = (dz!=0) ? stepZ/dz : DBL_MAX; - - int3 path[MAX_D]; - double csd[MAX_D]; // cumulative sum of sigma times delta - double p[MAX_D]; // alpha - double d[MAX_D]; - - // forward raymarching with voxel traversal - int step = 0; // total number of voxels traversed - int count = 0; // number of voxels traversed inside the voxel grid - double last_d = 0.0; // correct initialization - - // voxel traversal raycasting - bool was_inside = false; - while (true) { - bool inside = (0 <= vx && vx < vxsize) && - (0 <= vy && vy < vysize) && - (0 <= vz && vz < vzsize); - if (inside) { - was_inside = true; - path[count] = make_int3(vx, vy, vz); - } else if (was_inside) { // was but no longer inside - // we know we are not coming back so terminate - break; - } /*else if (last_d > gt_d) { - break; - } */ - /*else { // has not gone inside yet - // assert(count == 0); - // (1) when we have hit the destination but haven't gone inside the voxel grid - // (2) when we have traveled MAX_D voxels but haven't found one valid voxel - // handle intersection corner cases in case of infinite loop - bool hit = (vx == vxe && vy == vye && vz == vze); // this test seems brittle with corner cases - if (hit || step >= MAX_D) - break; - //if (last_d >= gt_d || step >= MAX_D) break; - } */ - // _d represents the ray distance has traveled before escaping the current voxel cell - double _d = 0.0; - // voxel traversal - if (tMaxX < tMaxY) { - if (tMaxX < tMaxZ) { - _d = tMaxX; - vx += stepX; - tMaxX += tDeltaX; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } else { - if (tMaxY < tMaxZ) { - _d = tMaxY; - vy += stepY; - tMaxY += tDeltaY; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } - if (inside) { - // get sigma at the current voxel - const int3 &v = path[count]; // use the recorded index - const double _sigma = sigma[n][ts][v.z][v.y][v.x]; - const double _delta = max(0.0, _d - last_d); // THIS TURNS OUT IMPORTANT - const double sd = _sigma * _delta; - if (count == 0) { // the first voxel inside - csd[count] = sd; - p[count] = 1 - exp(-sd); - } else { - csd[count] = csd[count-1] + sd; - p[count] = exp(-csd[count-1]) - exp(-csd[count]); - } - // record the traveled distance - d[count] = _d; - // count the number of voxels we have escaped - count ++; - } - last_d = _d; - step ++; - - if (step > MAX_STEP) { - break; - } - } - - // the total number of voxels visited should not exceed this number - assert(count <= MAX_D); - - if (count > 0) { - // compute the expected ray distance - //double exp_d = 0.0; - double exp_d = d[count-1]; - - const int3 &v_init = path[count-1]; - int x = v_init.x; - int y = v_init.y; - int z = v_init.z; - - for (int i = 0; i < count; i++) { - //printf("%f\t%f\n",p[i], d[i]); - //exp_d += p[i] * d[i]; - const int3 &v = path[i]; - const double occ = sigma[n][ts][v.z][v.y][v.x]; - if (occ > 0.5) { - exp_d = d[i]; - - x = v.x; - y = v.y; - z = v.z; - - break; - } - - } - //printf("%f\n",exp_d); - - // add an imaginary sample at the end point should gt_d exceeds max_d - double p_out = exp(-csd[count-1]); - double max_d = d[count-1]; - - // if (gt_d > max_d) - // exp_d += (p_out * gt_d); - - // p_out is the probability the ray escapes the voxel grid - //exp_d += (p_out * max_d); - if (train_phase == 1) { - gt_d = min(gt_d, max_d); - } - - // write the rendered ray distance (max_d) - pred_dist[n][c] = exp_d; - gt_dist[n][c] = gt_d; - - coord_index[n][c][0] = double(x); - coord_index[n][c][1] = double(y); - coord_index[n][c][2] = double(z); - - // // write occupancy - // for (int i = 0; i < count; i ++) { - // const int3 &v = path[i]; - // auto & occ = pog[n][t][v.z][v.y][v.x]; - // if (p[i] >= occ) { - // occ = p[i]; - // } - // } - } - } -} - -/* - * input shape - * sigma : N x T x H x L x W - * origin : N x T x 3 - * points : N x M x 4 - * output shape - * dist : N x M - */ -std::vector render_forward_cuda( - torch::Tensor sigma, - torch::Tensor origin, - torch::Tensor points, - torch::Tensor tindex, - const std::vector grid, - std::string phase_name) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto T = grid[0]; - const auto H = grid[1]; - const auto L = grid[2]; - const auto W = grid[3]; - - const auto device = sigma.device(); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // - // const auto dtype = points.dtype(); - // const auto options = torch::TensorOptions().dtype(dtype).device(device).requires_grad(false); - // auto pog = torch::zeros({N, T, H, L, W}, options); - - // perform rendering - auto gt_dist = -torch::ones({N, M}, device); - auto pred_dist = -torch::ones({N, M}, device); - - auto coord_index = torch::zeros({N, M, 3}, device); - - PhaseName train_phase; - if (phase_name.compare("test") == 0) { - train_phase = TEST; - } else if (phase_name.compare("train") == 0){ - train_phase = TRAIN; - } else { - std::cout << "UNKNOWN PHASE NAME: " << phase_name << std::endl; - exit(1); - } - - AT_DISPATCH_FLOATING_TYPES(sigma.type(), "render_forward_cuda", ([&] { - hipLaunchKernelGGL(( render_forward_cuda_kernel), dim3(blocks), dim3(threads), 0, 0, - sigma.packed_accessor32(), - origin.packed_accessor32(), - points.packed_accessor32(), - tindex.packed_accessor32(), - // pog.packed_accessor32(), - pred_dist.packed_accessor32(), - gt_dist.packed_accessor32(), - coord_index.packed_accessor32(), - train_phase); - })); - - hipDeviceSynchronize(); - - // return {pog, pred_dist, gt_dist}; - return {pred_dist, gt_dist, coord_index}; -} - -template -__global__ void render_cuda_kernel( - const torch::PackedTensorAccessor32 sigma, - const torch::PackedTensorAccessor32 origin, - const torch::PackedTensorAccessor32 points, - const torch::PackedTensorAccessor32 tindex, - // const torch::PackedTensorAccessor32 occupancy, - torch::PackedTensorAccessor32 pred_dist, - torch::PackedTensorAccessor32 gt_dist, - torch::PackedTensorAccessor32 grad_sigma, - // torch::PackedTensorAccessor32 grad_sigma_count, - LossType loss_type) { - - // batch index - const auto n = blockIdx.y; - - // ray index - const auto c = blockIdx.x * blockDim.x + threadIdx.x; - - // num of rays - const auto M = points.size(1); - const auto T = sigma.size(1); - - // we allocated more threads than num_rays - if (c < M) { - // ray end point - const auto t = tindex[n][c]; - - // invalid points - // assert(t < T); - assert(T == 1 || t < T); - - // time index for sigma - // when T = 1, we have a static sigma - const auto ts = (T == 1) ? 0 : t; - - // if t < 0, it is a padded point - if (t < 0) return; - - // grid shape - const int vzsize = sigma.size(2); - const int vysize = sigma.size(3); - const int vxsize = sigma.size(4); - // assert(vzsize + vysize + vxsize <= MAX_D); - - // origin - const double xo = origin[n][t][0]; - const double yo = origin[n][t][1]; - const double zo = origin[n][t][2]; - - // end point - const double xe = points[n][c][0]; - const double ye = points[n][c][1]; - const double ze = points[n][c][2]; - - // locate the voxel where the origin resides - const int vxo = int(xo); - const int vyo = int(yo); - const int vzo = int(zo); - - // - const int vxe = int(xe); - const int vye = int(ye); - const int vze = int(ze); - - // NOTE: new - int vx = vxo; - int vy = vyo; - int vz = vzo; - - // origin to end - const double rx = xe - xo; - const double ry = ye - yo; - const double rz = ze - zo; - double gt_d = sqrt(rx * rx + ry * ry + rz * rz); - - // directional vector - const double dx = rx / gt_d; - const double dy = ry / gt_d; - const double dz = rz / gt_d; - - // In which direction the voxel ids are incremented. - const int stepX = (dx >= 0) ? 1 : -1; - const int stepY = (dy >= 0) ? 1 : -1; - const int stepZ = (dz >= 0) ? 1 : -1; - - // Distance along the ray to the next voxel border from the current position (tMaxX, tMaxY, tMaxZ). - const double next_voxel_boundary_x = vx + (stepX < 0 ? 0 : 1); - const double next_voxel_boundary_y = vy + (stepY < 0 ? 0 : 1); - const double next_voxel_boundary_z = vz + (stepZ < 0 ? 0 : 1); - - // tMaxX, tMaxY, tMaxZ -- distance until next intersection with voxel-border - // the value of t at which the ray crosses the first vertical voxel boundary - double tMaxX = (dx!=0) ? (next_voxel_boundary_x - xo)/dx : DBL_MAX; // - double tMaxY = (dy!=0) ? (next_voxel_boundary_y - yo)/dy : DBL_MAX; // - double tMaxZ = (dz!=0) ? (next_voxel_boundary_z - zo)/dz : DBL_MAX; // - - // tDeltaX, tDeltaY, tDeltaZ -- - // how far along the ray we must move for the horizontal component to equal the width of a voxel - // the direction in which we traverse the grid - // can only be FLT_MAX if we never go in that direction - const double tDeltaX = (dx!=0) ? stepX/dx : DBL_MAX; - const double tDeltaY = (dy!=0) ? stepY/dy : DBL_MAX; - const double tDeltaZ = (dz!=0) ? stepZ/dz : DBL_MAX; - - int3 path[MAX_D]; - double csd[MAX_D]; // cumulative sum of sigma times delta - double p[MAX_D]; // alpha - double d[MAX_D]; - double dt[MAX_D]; - - // forward raymarching with voxel traversal - int step = 0; // total number of voxels traversed - int count = 0; // number of voxels traversed inside the voxel grid - double last_d = 0.0; // correct initialization - - // voxel traversal raycasting - bool was_inside = false; - while (true) { - bool inside = (0 <= vx && vx < vxsize) && - (0 <= vy && vy < vysize) && - (0 <= vz && vz < vzsize); - if (inside) { // now inside - was_inside = true; - path[count] = make_int3(vx, vy, vz); - } else if (was_inside) { // was inside but no longer - // we know we are not coming back so terminate - break; - } else if (last_d > gt_d) { - break; - } /* else { // has not gone inside yet - // assert(count == 0); - // (1) when we have hit the destination but haven't gone inside the voxel grid - // (2) when we have traveled MAX_D voxels but haven't found one valid voxel - // handle intersection corner cases in case of infinite loop - // bool hit = (vx == vxe && vy == vye && vz == vze); - // if (hit || step >= MAX_D) - // break; - if (last_d >= gt_d || step >= MAX_D) break; - } */ - // _d represents the ray distance has traveled before escaping the current voxel cell - double _d = 0.0; - // voxel traversal - if (tMaxX < tMaxY) { - if (tMaxX < tMaxZ) { - _d = tMaxX; - vx += stepX; - tMaxX += tDeltaX; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } else { - if (tMaxY < tMaxZ) { - _d = tMaxY; - vy += stepY; - tMaxY += tDeltaY; - } else { - _d = tMaxZ; - vz += stepZ; - tMaxZ += tDeltaZ; - } - } - if (inside) { - // get sigma at the current voxel - const int3 &v = path[count]; // use the recorded index - const double _sigma = sigma[n][ts][v.z][v.y][v.x]; - const double _delta = max(0.0, _d - last_d); // THIS TURNS OUT IMPORTANT - const double sd = _sigma * _delta; - if (count == 0) { // the first voxel inside - csd[count] = sd; - p[count] = 1 - exp(-sd); - } else { - csd[count] = csd[count-1] + sd; - p[count] = exp(-csd[count-1]) - exp(-csd[count]); - } - // record the traveled distance - d[count] = _d; - dt[count] = _delta; - // count the number of voxels we have escaped - count ++; - } - last_d = _d; - step ++; - - if (step > MAX_STEP) { - break; - } - } - - // the total number of voxels visited should not exceed this number - assert(count <= MAX_D); - - // WHEN THERE IS AN INTERSECTION BETWEEN THE RAY AND THE VOXEL GRID - if (count > 0) { - // compute the expected ray distance - double exp_d = 0.0; - for (int i = 0; i < count; i ++) - exp_d += p[i] * d[i]; - - // add an imaginary sample at the end point should gt_d exceeds max_d - double p_out = exp(-csd[count-1]); - double max_d = d[count-1]; - - exp_d += (p_out * max_d); - gt_d = min(gt_d, max_d); - - // write the rendered ray distance (max_d) - pred_dist[n][c] = exp_d; - gt_dist[n][c] = gt_d; - - /* backward raymarching */ - double dd_dsigma[MAX_D]; - for (int i = count - 1; i >= 0; i --) { - // NOTE: probably need to double check again - if (i == count - 1) - dd_dsigma[i] = p_out * max_d; - else - dd_dsigma[i] = dd_dsigma[i+1] - exp(-csd[i]) * (d[i+1] - d[i]); - } - - for (int i = count - 1; i >= 0; i --) - dd_dsigma[i] *= dt[i]; - - // option 2: cap at the boundary - for (int i = count - 1; i >= 0; i --) - dd_dsigma[i] -= dt[i] * p_out * max_d; - - double dl_dd = 1.0; - if (loss_type == L1) - dl_dd = (exp_d >= gt_d) ? 1 : -1; - else if (loss_type == L2) - dl_dd = (exp_d - gt_d); - else if (loss_type == ABSREL) - dl_dd = (exp_d >= gt_d) ? (1.0/gt_d) : -(1.0/gt_d); - - // apply chain rule - for (int i = 0; i < count; i ++) { - const int3 &v = path[i]; - // NOTE: potential race conditions when writing gradients - grad_sigma[n][ts][v.z][v.y][v.x] += dl_dd * dd_dsigma[i]; - // grad_sigma_count[n][ts][v.z][v.y][v.x] += 1; - } - } - } -} - -/* - * input shape - * sigma : N x T x H x L x W - * origin : N x T x 3 - * points : N x M x 4 - * output shape - * dist : N x M - * loss : N x M - * grad_sigma : N x T x H x L x W - */ -std::vector render_cuda( - torch::Tensor sigma, - torch::Tensor origin, - torch::Tensor points, - torch::Tensor tindex, - std::string loss_name) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto device = sigma.device(); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // perform rendering - auto gt_dist = -torch::ones({N, M}, device); - auto pred_dist = -torch::ones({N, M}, device); - auto grad_sigma = torch::zeros_like(sigma); - // auto grad_sigma_count = torch::zeros_like(sigma); - - LossType loss_type; - if (loss_name.compare("l1") == 0) { - loss_type = L1; - } else if (loss_name.compare("l2") == 0) { - loss_type = L2; - } else if (loss_name.compare("absrel") == 0) { - loss_type = ABSREL; - } else if (loss_name.compare("bce") == 0){ - loss_type = L1; - } else { - std::cout << "UNKNOWN LOSS TYPE: " << loss_name << std::endl; - exit(1); - } - - AT_DISPATCH_FLOATING_TYPES(sigma.type(), "render_cuda", ([&] { - hipLaunchKernelGGL(( render_cuda_kernel), dim3(blocks), dim3(threads), 0, 0, - sigma.packed_accessor32(), - origin.packed_accessor32(), - points.packed_accessor32(), - tindex.packed_accessor32(), - // occupancy.packed_accessor32(), - pred_dist.packed_accessor32(), - gt_dist.packed_accessor32(), - grad_sigma.packed_accessor32(), - // grad_sigma_count.packed_accessor32(), - loss_type); - })); - - hipDeviceSynchronize(); - - // grad_sigma_count += (grad_sigma_count == 0); - // grad_sigma /= grad_sigma_count; - - return {pred_dist, gt_dist, grad_sigma}; -} - - -/* - * input shape - * origin : N x T x 3 - * points : N x M x 3 - * tindex : N x M - * output shape - * occupancy: N x T x H x L x W - */ -torch::Tensor init_cuda( - torch::Tensor points, - torch::Tensor tindex, - const std::vector grid) { - - const auto N = points.size(0); // batch size - const auto M = points.size(1); // num of rays - - const auto T = grid[0]; - const auto H = grid[1]; - const auto L = grid[2]; - const auto W = grid[3]; - - const auto dtype = points.dtype(); - const auto device = points.device(); - const auto options = torch::TensorOptions().dtype(dtype).device(device).requires_grad(false); - auto occupancy = torch::zeros({N, T, H, L, W}, options); - - const int threads = 1024; - const dim3 blocks((M + threads - 1) / threads, N); - - // initialize occupancy such that every voxel with one or more points is occupied - AT_DISPATCH_FLOATING_TYPES(points.type(), "init_cuda", ([&] { - hipLaunchKernelGGL(( init_cuda_kernel), dim3(blocks), dim3(threads), 0, 0, - points.packed_accessor32(), - tindex.packed_accessor32(), - occupancy.packed_accessor32()); - })); - - // synchronize - hipDeviceSynchronize(); - - return occupancy; -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 7210bc9029efb18f3231dfb09641cab9cd81d961..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/bevdet_occ/bevdet-occ-r50.py b/docker-hub/FlashOCC/Flashocc/projects/configs/bevdet_occ/bevdet-occ-r50.py deleted file mode 100644 index e3bd357848d1530fb4c667c1605848837e37c6bb..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/bevdet_occ/bevdet-occ-r50.py +++ /dev/null @@ -1,270 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 0.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 32 - -model = dict( - type='BEVDetOCC', - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=256, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformer', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=256, - out_channels=numC_Trans, - sid=False, - collapse_z=False, - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet3D', - numC_input=numC_Trans, - num_layer=[1, 2, 4], - with_cp=False, - num_channels=[numC_Trans, numC_Trans*2, numC_Trans*4], - stride=[1, 2, 2], - backbone_output_ids=[0, 1, 2]), - img_bev_encoder_neck=dict(type='LSSFPN3D', - in_channels=numC_Trans*7, - out_channels=numC_Trans), - occ_head=dict( - type='BEVOCCHead3D', - in_dim=numC_Trans, - out_dim=32, - use_mask=True, - num_classes=18, - use_predicter=True, - class_balance=False, - loss_occ=dict( - type='CrossEntropyLoss', - use_sigmoid=False, - ignore_index=255, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=True, - filter_empty_gt=False, - img_info_prototype='bevdet', -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# with pretrain -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 6.65 -# ===> barrier - IoU = 36.97 -# ===> bicycle - IoU = 8.33 -# ===> bus - IoU = 38.69 -# ===> car - IoU = 44.46 -# ===> construction_vehicle - IoU = 15.21 -# ===> motorcycle - IoU = 13.67 -# ===> pedestrian - IoU = 16.39 -# ===> traffic_cone - IoU = 15.27 -# ===> trailer - IoU = 27.11 -# ===> truck - IoU = 31.04 -# ===> driveable_surface - IoU = 78.7 -# ===> other_flat - IoU = 36.45 -# ===> sidewalk - IoU = 48.27 -# ===> terrain - IoU = 51.68 -# ===> manmade - IoU = 36.82 -# ===> vegetation - IoU = 32.09 -# ===> mIoU of 6019 samples: 31.64 - - -# with det pretrain; use_mask=False; class_balance=True -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 4.36 -# ===> barrier - IoU = 28.87 -# ===> bicycle - IoU = 2.86 -# ===> bus - IoU = 29.27 -# ===> car - IoU = 32.45 -# ===> construction_vehicle - IoU = 11.05 -# ===> motorcycle - IoU = 12.82 -# ===> pedestrian - IoU = 10.11 -# ===> traffic_cone - IoU = 9.47 -# ===> trailer - IoU = 7.93 -# ===> truck - IoU = 21.58 -# ===> driveable_surface - IoU = 49.85 -# ===> other_flat - IoU = 25.5 -# ===> sidewalk - IoU = 26.78 -# ===> terrain - IoU = 21.14 -# ===> manmade - IoU = 5.76 -# ===> vegetation - IoU = 7.09 -# ===> mIoU of 6019 samples: 18.05 \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2.py b/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2.py deleted file mode 100644 index 5fa7664be9bdaee7dac751b8c01f1b00997119f8..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2.py +++ /dev/null @@ -1,260 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (512, 1408), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -# Model -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 80 - -multi_adj_frame_id_cfg = (1, 1+1, 1) - -model = dict( - type='BEVStereo4DOCC', - align_after_view_transfromation=False, - num_adj=len(range(*multi_adj_frame_id_cfg)), - img_backbone=dict( - type='SwinTransformer', - pretrain_img_size=224, - patch_size=4, - window_size=12, - mlp_ratio=4, - embed_dims=128, - depths=[2, 2, 18, 2], - num_heads=[4, 8, 16, 32], - strides=(4, 2, 2, 2), - out_indices=(2, 3), - qkv_bias=True, - qk_scale=None, - patch_norm=True, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0.1, - use_abs_pos_embed=False, - return_stereo_feat=True, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN', requires_grad=True), - pretrain_style='official', - output_missing_index_as_none=False), - img_neck=dict( - type='FPN_LSS', - in_channels=512 + 1024, - out_channels=512, - # with_cp=False, - extra_upsample=None, - input_feature_index=(0, 1), - scale_factor=2), - img_view_transformer=dict( - type='LSSViewTransformerBEVStereo', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - sid=False, - collapse_z=True, - loss_depth_weight=0.05, - depthnet_cfg=dict(use_dcn=False, - aspp_mid_channels=96, - stereo=True, - bias=5.), - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet', - with_cp=True, - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - occ_head=dict( - type='BEVOCCHead2D', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=True, - num_classes=18, - use_predicter=True, - class_balance=False, - loss_occ=dict( - type='CrossEntropyLoss', - use_sigmoid=False, - ignore_index=255, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar','mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - classes=class_names, - modality=input_modality, - stereo=True, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - data_root=data_root, - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, # with 32 GPU - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), - dict( - type='SyncbnControlHook', - syncbn_start_epoch=0, - ), -] - -evaluation = dict(interval=6, start=0, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=3) -# load_from="ckpts/bevdet-stbase-4d-stereo-512x1408-cbgs.pth" -resume_from="work_dirs/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2/epoch_5.pth" -# fp16 = dict(loss_scale='dynamic') - -# bash tools/dist_train.sh projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2.py 4 \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_2e-4.py b/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_2e-4.py deleted file mode 100644 index 3785cd1738c9215d15d9032adc7287b71de31d12..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_2e-4.py +++ /dev/null @@ -1,302 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (512, 1408), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -# Model -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 80 - -multi_adj_frame_id_cfg = (1, 1+1, 1) - -model = dict( - type='BEVStereo4DOCC', - align_after_view_transfromation=False, - num_adj=len(range(*multi_adj_frame_id_cfg)), - img_backbone=dict( - type='SwinTransformer', - pretrain_img_size=224, - patch_size=4, - window_size=12, - mlp_ratio=4, - embed_dims=128, - depths=[2, 2, 18, 2], - num_heads=[4, 8, 16, 32], - strides=(4, 2, 2, 2), - out_indices=(2, 3), - qkv_bias=True, - qk_scale=None, - patch_norm=True, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0.1, - use_abs_pos_embed=False, - return_stereo_feat=True, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN', requires_grad=True), - pretrain_style='official', - output_missing_index_as_none=False), - img_neck=dict( - type='FPN_LSS', - in_channels=512 + 1024, - out_channels=512, - # with_cp=False, - extra_upsample=None, - input_feature_index=(0, 1), - scale_factor=2), - img_view_transformer=dict( - type='LSSViewTransformerBEVStereo', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - sid=False, - collapse_z=True, - loss_depth_weight=0.05, - depthnet_cfg=dict(use_dcn=False, - aspp_mid_channels=96, - stereo=True, - bias=5.), - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet', - with_cp=True, - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - occ_head=dict( - type='BEVOCCHead2D', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=True, - num_classes=18, - use_predicter=True, - class_wise=False, - loss_occ=dict( - type='CrossEntropyLoss', - use_sigmoid=False, - ignore_index=255, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar','mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - classes=class_names, - modality=input_modality, - stereo=True, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - data_root=data_root, - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, # with 32 GPU - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=2e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), - dict( - type='SyncbnControlHook', - syncbn_start_epoch=0, - ), -] - -evaluation = dict(interval=6, start=0, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=3) -load_from="ckpts/bevdet-stbase-4d-stereo-512x1408-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') - -# bash tools/dist_train.sh projects/configs/flashocc/flashocc-stbase-4d-stereo-512x1408.py 4 -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 13.42 -# ===> barrier - IoU = 51.07 -# ===> bicycle - IoU = 27.68 -# ===> bus - IoU = 51.57 -# ===> car - IoU = 56.22 -# ===> construction_vehicle - IoU = 27.27 -# ===> motorcycle - IoU = 29.98 -# ===> pedestrian - IoU = 29.93 -# ===> traffic_cone - IoU = 29.8 -# ===> trailer - IoU = 37.77 -# ===> truck - IoU = 43.52 -# ===> driveable_surface - IoU = 83.81 -# ===> other_flat - IoU = 46.55 -# ===> sidewalk - IoU = 56.15 -# ===> terrain - IoU = 59.56 -# ===> manmade - IoU = 50.84 -# ===> vegetation - IoU = 44.67 -# ===> mIoU of 6019 samples: 43.52 - -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 13.31 -# ===> barrier - IoU = 51.62 -# ===> bicycle - IoU = 28.07 -# ===> bus - IoU = 50.91 -# ===> car - IoU = 55.69 -# ===> construction_vehicle - IoU = 27.46 -# ===> motorcycle - IoU = 31.05 -# ===> pedestrian - IoU = 29.98 -# ===> traffic_cone - IoU = 29.2 -# ===> trailer - IoU = 38.86 -# ===> truck - IoU = 43.68 -# ===> driveable_surface - IoU = 83.87 -# ===> other_flat - IoU = 45.63 -# ===> sidewalk - IoU = 56.33 -# ===> terrain - IoU = 59.01 -# ===> manmade - IoU = 50.63 -# ===> vegetation - IoU = 44.56 -# ===> mIoU of 6019 samples: 43.52 -# {'mIoU': array([0.13311691, 0.51617081, 0.28070517, 0.50911942, 0.55694228, -# 0.27461342, 0.31050779, 0.29979125, 0.29204287, 0.38862984, -# 0.43680049, 0.83872518, 0.45630227, 0.56327839, 0.59008883, -# 0.50627122, 0.44564523, 0.90959399])} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-pano.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-pano.py deleted file mode 100644 index 149772559c7c30a17a621be362ca8296d52da321..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-pano.py +++ /dev/null @@ -1,356 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 80 - -model = dict( - type='BEVDepthPano', # single-frame - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=256, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=256, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=256, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.3, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera', 'gt_bboxes_3d', 'gt_labels_3d']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs', 'gt_bboxes_3d', 'gt_labels_3d']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet', -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 10.21 -# ===> barrier - IoU = 42.14 -# ===> bicycle - IoU = 22.82 -# ===> bus - IoU = 40.13 -# ===> car - IoU = 42.86 -# ===> construction_vehicle - IoU = 20.69 -# ===> motorcycle - IoU = 24.58 -# ===> pedestrian - IoU = 23.7 -# ===> traffic_cone - IoU = 24.02 -# ===> trailer - IoU = 25.48 -# ===> truck - IoU = 30.9 -# ===> driveable_surface - IoU = 58.65 -# ===> other_flat - IoU = 32.04 -# ===> sidewalk - IoU = 34.27 -# ===> terrain - IoU = 31.12 -# ===> manmade - IoU = 18.26 -# ===> vegetation - IoU = 17.79 -# ===> mIoU of 6019 samples: 29.39 -# {'mIoU': array([0.102, 0.421, 0.228, 0.401, 0.429, 0.207, 0.246, 0.237, 0.24 , -# 0.255, 0.309, 0.586, 0.32 , 0.343, 0.311, 0.183, 0.178, 0.833])} - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.090 | 0.102 | 0.105 | -# | barrier | 0.387 | 0.442 | 0.465 | -# | bicycle | 0.218 | 0.257 | 0.265 | -# | bus | 0.514 | 0.613 | 0.669 | -# | car | 0.487 | 0.564 | 0.592 | -# | construction_vehicle | 0.176 | 0.254 | 0.288 | -# | motorcycle | 0.203 | 0.292 | 0.310 | -# | pedestrian | 0.301 | 0.349 | 0.366 | -# | traffic_cone | 0.280 | 0.313 | 0.321 | -# | trailer | 0.227 | 0.313 | 0.390 | -# | truck | 0.395 | 0.493 | 0.537 | -# | driveable_surface | 0.534 | 0.618 | 0.708 | -# | other_flat | 0.289 | 0.326 | 0.356 | -# | sidewalk | 0.234 | 0.280 | 0.329 | -# | terrain | 0.222 | 0.291 | 0.356 | -# | manmade | 0.280 | 0.351 | 0.401 | -# | vegetation | 0.176 | 0.273 | 0.359 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.295 | 0.361 | 0.401 | -# +----------------------+----------+----------+----------+ -# +----------------------+---------+---------+---------+ -# | Class Names | RayPQ@1 | RayPQ@2 | RayPQ@4 | -# +----------------------+---------+---------+---------+ -# | others | 0.017 | 0.025 | 0.026 | -# | barrier | 0.125 | 0.182 | 0.218 | -# | bicycle | 0.051 | 0.072 | 0.076 | -# | bus | 0.275 | 0.366 | 0.422 | -# | car | 0.242 | 0.332 | 0.356 | -# | construction_vehicle | 0.016 | 0.058 | 0.092 | -# | motorcycle | 0.071 | 0.124 | 0.137 | -# | pedestrian | 0.017 | 0.022 | 0.023 | -# | traffic_cone | 0.032 | 0.040 | 0.044 | -# | trailer | 0.035 | 0.055 | 0.063 | -# | truck | 0.145 | 0.232 | 0.282 | -# | driveable_surface | 0.410 | 0.537 | 0.665 | -# | other_flat | 0.062 | 0.087 | 0.109 | -# | sidewalk | 0.008 | 0.030 | 0.064 | -# | terrain | 0.010 | 0.026 | 0.047 | -# | manmade | 0.054 | 0.091 | 0.134 | -# | vegetation | 0.003 | 0.022 | 0.092 | -# +----------------------+---------+---------+---------+ -# | MEAN | 0.092 | 0.135 | 0.168 | -# +----------------------+---------+---------+---------+ -# {'RayIoU': 0.35223182059688496, 'RayIoU@1': 0.29499743138394385, 'RayIoU@2': 0.3607063492639709, 'RayIoU@4': 0.4009916811427401, -# 'RayPQ': 0.13182524545677765, 'RayPQ@1': 0.09247682620339576, 'RayPQ@2': 0.1354024129684159, 'RayPQ@4': 0.16759649719852124} - diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano.py deleted file mode 100644 index 5d576850a6d5ef7a65608a40ab53b989c7b5f560..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano.py +++ /dev/null @@ -1,357 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 1.0], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 64 - -model = dict( - type='BEVDepthPano', # single-frame - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=256, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=256, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=128), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=128, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.3, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=128, - out_dim=128, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera', 'gt_bboxes_3d', 'gt_labels_3d']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs', 'gt_bboxes_3d', 'gt_labels_3d']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet', -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 10.33 -# ===> barrier - IoU = 41.02 -# ===> bicycle - IoU = 22.16 -# ===> bus - IoU = 39.75 -# ===> car - IoU = 42.63 -# ===> construction_vehicle - IoU = 20.53 -# ===> motorcycle - IoU = 24.01 -# ===> pedestrian - IoU = 23.71 -# ===> traffic_cone - IoU = 24.65 -# ===> trailer - IoU = 25.58 -# ===> truck - IoU = 30.63 -# ===> driveable_surface - IoU = 58.0 -# ===> other_flat - IoU = 32.12 -# ===> sidewalk - IoU = 33.78 -# ===> terrain - IoU = 31.02 -# ===> manmade - IoU = 17.67 -# ===> vegetation - IoU = 17.74 -# ===> mIoU of 6019 samples: 29.14 -# {'mIoU': array([0.103, 0.41 , 0.222, 0.397, 0.426, 0.205, 0.24 , 0.237, 0.246, -# 0.256, 0.306, 0.58 , 0.321, 0.338, 0.31 , 0.177, 0.177, 0.832])} - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.095 | 0.107 | 0.110 | -# | barrier | 0.374 | 0.429 | 0.452 | -# | bicycle | 0.208 | 0.242 | 0.248 | -# | bus | 0.498 | 0.603 | 0.659 | -# | car | 0.489 | 0.568 | 0.598 | -# | construction_vehicle | 0.171 | 0.247 | 0.279 | -# | motorcycle | 0.190 | 0.277 | 0.298 | -# | pedestrian | 0.295 | 0.344 | 0.361 | -# | traffic_cone | 0.290 | 0.324 | 0.332 | -# | trailer | 0.207 | 0.292 | 0.368 | -# | truck | 0.411 | 0.507 | 0.551 | -# | driveable_surface | 0.531 | 0.614 | 0.704 | -# | other_flat | 0.286 | 0.325 | 0.357 | -# | sidewalk | 0.234 | 0.280 | 0.328 | -# | terrain | 0.220 | 0.290 | 0.356 | -# | manmade | 0.267 | 0.343 | 0.392 | -# | vegetation | 0.174 | 0.272 | 0.358 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.291 | 0.357 | 0.397 | -# +----------------------+----------+----------+----------+ -# 6019it [09:34, 10.48it/s] -# +----------------------+---------+---------+---------+ -# | Class Names | RayPQ@1 | RayPQ@2 | RayPQ@4 | -# +----------------------+---------+---------+---------+ -# | others | 0.017 | 0.024 | 0.025 | -# | barrier | 0.107 | 0.169 | 0.204 | -# | bicycle | 0.069 | 0.086 | 0.088 | -# | bus | 0.244 | 0.350 | 0.408 | -# | car | 0.238 | 0.326 | 0.352 | -# | construction_vehicle | 0.018 | 0.081 | 0.105 | -# | motorcycle | 0.061 | 0.105 | 0.117 | -# | pedestrian | 0.016 | 0.022 | 0.023 | -# | traffic_cone | 0.030 | 0.049 | 0.052 | -# | trailer | 0.029 | 0.047 | 0.056 | -# | truck | 0.151 | 0.240 | 0.286 | -# | driveable_surface | 0.407 | 0.531 | 0.662 | -# | other_flat | 0.054 | 0.078 | 0.098 | -# | sidewalk | 0.009 | 0.030 | 0.061 | -# | terrain | 0.006 | 0.022 | 0.045 | -# | manmade | 0.044 | 0.091 | 0.128 | -# | vegetation | 0.001 | 0.021 | 0.091 | -# +----------------------+---------+---------+---------+ -# | MEAN | 0.088 | 0.134 | 0.165 | -# +----------------------+---------+---------+---------+ -# {'RayIoU': 0.34819957391233375, 'RayIoU@1': 0.29065973127346445, 'RayIoU@2': 0.3566749015912661, 'RayIoU@4': 0.39726408887227066, -# 'RayPQ': 0.12890890185841564, 'RayPQ@1': 0.08832135839934552, 'RayPQ@2': 0.1336058084882046, 'RayPQ@4': 0.1647995386876968} diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth.py deleted file mode 100644 index c3d591dfac96f86db8b550ce9e981c688a88ddfa..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth.py +++ /dev/null @@ -1,336 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] - -numC_Trans = 80 - -model = dict( - type='BEVDepthPano', # single-frame - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=256, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=256, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=256, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.3, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=False), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet', -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# use_mask = False -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.090 | 0.102 | 0.105 | -# | barrier | 0.387 | 0.442 | 0.465 | -# | bicycle | 0.218 | 0.257 | 0.265 | -# | bus | 0.514 | 0.613 | 0.669 | -# | car | 0.487 | 0.564 | 0.592 | -# | construction_vehicle | 0.176 | 0.254 | 0.288 | -# | motorcycle | 0.203 | 0.292 | 0.310 | -# | pedestrian | 0.301 | 0.349 | 0.366 | -# | traffic_cone | 0.280 | 0.313 | 0.321 | -# | trailer | 0.227 | 0.313 | 0.390 | -# | truck | 0.395 | 0.493 | 0.537 | -# | driveable_surface | 0.534 | 0.618 | 0.708 | -# | other_flat | 0.289 | 0.326 | 0.356 | -# | sidewalk | 0.234 | 0.280 | 0.329 | -# | terrain | 0.222 | 0.291 | 0.356 | -# | manmade | 0.280 | 0.351 | 0.401 | -# | vegetation | 0.176 | 0.273 | 0.359 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.295 | 0.361 | 0.401 | -# +----------------------+----------+----------+----------+ - - -# +----------------------+---------+---------+---------+ -# | Class Names | RayPQ@1 | RayPQ@2 | RayPQ@4 | -# +----------------------+---------+---------+---------+ -# | others | 0.017 | 0.025 | 0.026 | -# | barrier | 0.125 | 0.182 | 0.218 | -# | bicycle | 0.051 | 0.072 | 0.076 | -# | bus | 0.275 | 0.366 | 0.422 | -# | car | 0.242 | 0.332 | 0.356 | -# | construction_vehicle | 0.016 | 0.058 | 0.092 | -# | motorcycle | 0.071 | 0.124 | 0.137 | -# | pedestrian | 0.017 | 0.022 | 0.023 | -# | traffic_cone | 0.032 | 0.040 | 0.044 | -# | trailer | 0.035 | 0.055 | 0.063 | -# | truck | 0.145 | 0.232 | 0.282 | -# | driveable_surface | 0.410 | 0.537 | 0.665 | -# | other_flat | 0.062 | 0.087 | 0.109 | -# | sidewalk | 0.008 | 0.030 | 0.064 | -# | terrain | 0.010 | 0.026 | 0.047 | -# | manmade | 0.054 | 0.091 | 0.134 | -# | vegetation | 0.003 | 0.022 | 0.092 | -# +----------------------+---------+---------+---------+ -# | MEAN | 0.092 | 0.135 | 0.168 | -# +----------------------+---------+---------+---------+ -# {'RayIoU': 0.35223182059688496, 'RayIoU@1': 0.29499743138394385, 'RayIoU@2': 0.3607063492639709, 'RayIoU@4': 0.4009916811427401, 'RayPQ': 0.13182524545677765, 'RayPQ@1': 0.09247682620339576, 'RayPQ@2': 0.1354024129684159, 'RayPQ@4': 0.16759649719852124} - diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f-pano.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f-pano.py deleted file mode 100644 index b7403fa22f694246b02d5d6bec215b04249286c5..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f-pano.py +++ /dev/null @@ -1,294 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 16+1, 1) - -model = dict( - type='BEVDepth4DPano', - num_adj=multi_adj_frame_id_cfg[1]-1, - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=256, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.1, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera', 'gt_bboxes_3d', 'gt_labels_3d']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs', 'gt_bboxes_3d', 'gt_labels_3d']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f.py deleted file mode 100644 index 302ce01b6f8b768823233cd94473268819bca720..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f.py +++ /dev/null @@ -1,283 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 16+1, 1) - -model = dict( - type='BEVDepth4DOCC', - num_adj=multi_adj_frame_id_cfg[1]-1, - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# use_mask = False -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 11.94 -# ===> barrier - IoU = 44.84 -# ===> bicycle - IoU = 26.66 -# ===> bus - IoU = 41.53 -# ===> car - IoU = 44.42 -# ===> construction_vehicle - IoU = 20.79 -# ===> motorcycle - IoU = 26.96 -# ===> pedestrian - IoU = 25.98 -# ===> traffic_cone - IoU = 29.25 -# ===> trailer - IoU = 24.24 -# ===> truck - IoU = 32.28 -# ===> driveable_surface - IoU = 60.5 -# ===> other_flat - IoU = 33.07 -# ===> sidewalk - IoU = 37.01 -# ===> terrain - IoU = 33.54 -# ===> manmade - IoU = 21.75 -# ===> vegetation - IoU = 21.58 -# ===> mIoU of 6019 samples: 31.55 -# {'mIoU': array([0.119, 0.448, 0.267, 0.415, 0.444, 0.208, 0.27 , 0.26 , 0.293, -# 0.242, 0.323, 0.605, 0.331, 0.37 , 0.335, 0.217, 0.216, 0.839])} - - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.110 | 0.118 | 0.119 | -# | barrier | 0.444 | 0.484 | 0.499 | -# | bicycle | 0.278 | 0.311 | 0.319 | -# | bus | 0.537 | 0.635 | 0.691 | -# | car | 0.512 | 0.585 | 0.611 | -# | construction_vehicle | 0.153 | 0.218 | 0.238 | -# | motorcycle | 0.228 | 0.310 | 0.330 | -# | pedestrian | 0.338 | 0.387 | 0.401 | -# | traffic_cone | 0.342 | 0.362 | 0.370 | -# | trailer | 0.209 | 0.293 | 0.368 | -# | truck | 0.422 | 0.511 | 0.555 | -# | driveable_surface | 0.570 | 0.653 | 0.742 | -# | other_flat | 0.301 | 0.340 | 0.375 | -# | sidewalk | 0.266 | 0.319 | 0.370 | -# | terrain | 0.261 | 0.334 | 0.400 | -# | manmade | 0.360 | 0.435 | 0.485 | -# | vegetation | 0.244 | 0.354 | 0.442 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.328 | 0.391 | 0.430 | -# +----------------------+----------+----------+----------+ -# {'RayIoU': 0.38313147213727416, 'RayIoU@1': 0.3279517851047602, 'RayIoU@2': 0.3911038935232673, 'RayIoU@4': 0.4303387377837949} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f-pano.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f-pano.py deleted file mode 100644 index ac743acfb3a22b81c2dbee2395dce2948ff26d21..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f-pano.py +++ /dev/null @@ -1,368 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 8+1, 1) - -model = dict( - type='BEVDepth4DPano', - num_adj=multi_adj_frame_id_cfg[1]-1, - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=256, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.3, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera', 'gt_bboxes_3d', 'gt_labels_3d']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs', 'gt_bboxes_3d', 'gt_labels_3d']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# use_mask = False -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 11.51 -# ===> barrier - IoU = 45.87 -# ===> bicycle - IoU = 24.65 -# ===> bus - IoU = 41.75 -# ===> car - IoU = 46.15 -# ===> construction_vehicle - IoU = 20.96 -# ===> motorcycle - IoU = 26.82 -# ===> pedestrian - IoU = 26.77 -# ===> traffic_cone - IoU = 29.66 -# ===> trailer - IoU = 24.65 -# ===> truck - IoU = 32.75 -# ===> driveable_surface - IoU = 60.39 -# ===> other_flat - IoU = 32.87 -# ===> sidewalk - IoU = 36.49 -# ===> terrain - IoU = 33.16 -# ===> manmade - IoU = 21.3 -# ===> vegetation - IoU = 20.92 -# ===> mIoU of 6019 samples: 31.57 -# {'mIoU': array([0.115, 0.459, 0.247, 0.418, 0.461, 0.21 , 0.268, 0.268, 0.297, -# 0.247, 0.328, 0.604, 0.329, 0.365, 0.332, 0.213, 0.209, 0.839])} - - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.101 | 0.108 | 0.110 | -# | barrier | 0.439 | 0.480 | 0.497 | -# | bicycle | 0.258 | 0.286 | 0.293 | -# | bus | 0.540 | 0.649 | 0.700 | -# | car | 0.531 | 0.603 | 0.629 | -# | construction_vehicle | 0.180 | 0.252 | 0.282 | -# | motorcycle | 0.247 | 0.328 | 0.343 | -# | pedestrian | 0.347 | 0.393 | 0.409 | -# | traffic_cone | 0.346 | 0.371 | 0.378 | -# | trailer | 0.209 | 0.292 | 0.384 | -# | truck | 0.452 | 0.544 | 0.587 | -# | driveable_surface | 0.562 | 0.646 | 0.734 | -# | other_flat | 0.290 | 0.328 | 0.363 | -# | sidewalk | 0.261 | 0.313 | 0.363 | -# | terrain | 0.260 | 0.330 | 0.394 | -# | manmade | 0.345 | 0.421 | 0.471 | -# | vegetation | 0.229 | 0.337 | 0.423 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.329 | 0.393 | 0.433 | -# +----------------------+----------+----------+----------+ -# 6019it [10:36, 9.46it/s] -# +----------------------+---------+---------+---------+ -# | Class Names | RayPQ@1 | RayPQ@2 | RayPQ@4 | -# +----------------------+---------+---------+---------+ -# | others | 0.026 | 0.032 | 0.033 | -# | barrier | 0.184 | 0.232 | 0.253 | -# | bicycle | 0.088 | 0.103 | 0.108 | -# | bus | 0.311 | 0.406 | 0.458 | -# | car | 0.300 | 0.380 | 0.403 | -# | construction_vehicle | 0.032 | 0.057 | 0.081 | -# | motorcycle | 0.114 | 0.156 | 0.169 | -# | pedestrian | 0.025 | 0.030 | 0.031 | -# | traffic_cone | 0.071 | 0.081 | 0.085 | -# | trailer | 0.049 | 0.077 | 0.088 | -# | truck | 0.182 | 0.274 | 0.314 | -# | driveable_surface | 0.457 | 0.574 | 0.702 | -# | other_flat | 0.062 | 0.086 | 0.106 | -# | sidewalk | 0.018 | 0.042 | 0.091 | -# | terrain | 0.017 | 0.039 | 0.074 | -# | manmade | 0.077 | 0.144 | 0.194 | -# | vegetation | 0.002 | 0.061 | 0.162 | -# +----------------------+---------+---------+---------+ -# | MEAN | 0.119 | 0.163 | 0.197 | -# +----------------------+---------+---------+---------+ -# {'RayIoU': 0.3850202377154096, 'RayIoU@1': 0.3291477679560127, 'RayIoU@2': 0.39307010079658805, 'RayIoU@4': 0.4328428443936281, -# 'RayPQ': 0.15961266397677248, 'RayPQ@1': 0.11850092407498894, 'RayPQ@2': 0.1631862461686837, 'RayPQ@4': 0.19715082168664483} diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py deleted file mode 100644 index a3d22387bf5c365c8553766a4645c980824c1b6b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py +++ /dev/null @@ -1,283 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 8+1, 1) - -model = dict( - type='BEVDepth4DOCC', - num_adj=multi_adj_frame_id_cfg[1]-1, - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - -# use_mask = False -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 11.5 -# ===> barrier - IoU = 44.1 -# ===> bicycle - IoU = 25.89 -# ===> bus - IoU = 41.0 -# ===> car - IoU = 44.57 -# ===> construction_vehicle - IoU = 21.88 -# ===> motorcycle - IoU = 27.31 -# ===> pedestrian - IoU = 25.95 -# ===> traffic_cone - IoU = 29.04 -# ===> trailer - IoU = 24.17 -# ===> truck - IoU = 31.81 -# ===> driveable_surface - IoU = 60.74 -# ===> other_flat - IoU = 33.84 -# ===> sidewalk - IoU = 36.62 -# ===> terrain - IoU = 33.96 -# ===> manmade - IoU = 21.54 -# ===> vegetation - IoU = 21.36 -# ===> mIoU of 6019 samples: 31.49 -# {'mIoU': array([0.115, 0.441, 0.259, 0.41 , 0.446, 0.219, 0.273, 0.259, 0.29 , -# 0.242, 0.318, 0.607, 0.338, 0.366, 0.34 , 0.215, 0.214, 0.839])} - - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.107 | 0.115 | 0.116 | -# | barrier | 0.442 | 0.485 | 0.501 | -# | bicycle | 0.267 | 0.296 | 0.302 | -# | bus | 0.533 | 0.632 | 0.683 | -# | car | 0.516 | 0.590 | 0.616 | -# | construction_vehicle | 0.170 | 0.251 | 0.282 | -# | motorcycle | 0.231 | 0.325 | 0.350 | -# | pedestrian | 0.340 | 0.386 | 0.400 | -# | traffic_cone | 0.348 | 0.372 | 0.380 | -# | trailer | 0.232 | 0.317 | 0.400 | -# | truck | 0.427 | 0.514 | 0.559 | -# | driveable_surface | 0.566 | 0.649 | 0.736 | -# | other_flat | 0.302 | 0.341 | 0.374 | -# | sidewalk | 0.261 | 0.313 | 0.363 | -# | terrain | 0.258 | 0.333 | 0.399 | -# | manmade | 0.348 | 0.426 | 0.479 | -# | vegetation | 0.234 | 0.342 | 0.430 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.328 | 0.393 | 0.434 | -# +----------------------+----------+----------+----------+ -# {'RayIoU': 0.3851476341258822, 'RayIoU@1': 0.3284556495395326, 'RayIoU@2': 0.39334760720480005, 'RayIoU@4': 0.43363964563331386} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-pano.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-pano.py deleted file mode 100644 index b545fb5483b70cfdf629916e22841c5aca8f3b0b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-pano.py +++ /dev/null @@ -1,367 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-40.0, -40.0, -5.0, 40.0, 40.0, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 1+1, 1) - -model = dict( - type='BEVDepth4DPano', - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - aux_centerness_head=dict( - type='Centerness_Head', - task_specific_weight=[1, 1, 0, 0, 0], - in_channels=256, - tasks=[ - dict(num_class=10, class_names=['car', 'truck', - 'construction_vehicle', - 'bus', 'trailer', - 'barrier', - 'motorcycle', 'bicycle', - 'pedestrian', 'traffic_cone']), - ], - common_heads=dict( - reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - share_conv_channel=64, - bbox_coder=dict( - type='CenterPointBBoxCoder', - pc_range=point_cloud_range[:2], - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - max_num=500, - score_threshold=0.3, # - out_size_factor=4, - voxel_size=voxel_size[:2], - code_size=9), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=0.25), - norm_bbox=True), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ), - # model training and testing settings - train_cfg=dict( - pts=dict( - point_cloud_range=point_cloud_range, - grid_size=[800, 800, 40], - voxel_size=voxel_size, - out_size_factor=4, - dense_reg=1, - gaussian_overlap=0.1, - max_objs=500, - min_radius=2, - code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2])), - test_cfg=dict( - pts=dict( - max_per_img=500, - max_pool_nms=False, - min_radius=[4, 12, 10, 1, 0.85, 0.175], - score_threshold=0.1, - out_size_factor=4, - voxel_size=voxel_size[:2], - pre_max_size=1000, - post_max_size=500, - - # Scale-NMS - nms_type=['rotate'], - nms_thr=[0.2], - nms_rescale_factor=[[1.0, 0.7, 0.7, 0.4, 0.55, - 1.1, 1.0, 1.0, 1.5, 3.5]] - ) - ), -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera', 'gt_bboxes_3d', 'gt_labels_3d']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs', 'gt_bboxes_3d', 'gt_labels_3d']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - - - -# ===> per class IoU of 6019 samples: -# ===> others - IoU = 10.89 -# ===> barrier - IoU = 43.92 -# ===> bicycle - IoU = 24.42 -# ===> bus - IoU = 41.91 -# ===> car - IoU = 45.18 -# ===> construction_vehicle - IoU = 18.73 -# ===> motorcycle - IoU = 25.59 -# ===> pedestrian - IoU = 25.67 -# ===> traffic_cone - IoU = 25.86 -# ===> trailer - IoU = 25.29 -# ===> truck - IoU = 31.84 -# ===> driveable_surface - IoU = 59.03 -# ===> other_flat - IoU = 31.53 -# ===> sidewalk - IoU = 34.67 -# ===> terrain - IoU = 31.49 -# ===> manmade - IoU = 19.91 -# ===> vegetation - IoU = 19.31 -# ===> mIoU of 6019 samples: 30.31 -# {'mIoU': array([0.109, 0.439, 0.244, 0.419, 0.452, 0.187, 0.256, 0.257, 0.259, -# 0.253, 0.318, 0.59 , 0.315, 0.347, 0.315, 0.199, 0.193, 0.835])} - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.094 | 0.105 | 0.107 | -# | barrier | 0.411 | 0.460 | 0.480 | -# | bicycle | 0.252 | 0.286 | 0.293 | -# | bus | 0.541 | 0.646 | 0.698 | -# | car | 0.520 | 0.594 | 0.621 | -# | construction_vehicle | 0.164 | 0.235 | 0.264 | -# | motorcycle | 0.212 | 0.305 | 0.321 | -# | pedestrian | 0.326 | 0.373 | 0.389 | -# | traffic_cone | 0.312 | 0.341 | 0.348 | -# | trailer | 0.220 | 0.291 | 0.372 | -# | truck | 0.430 | 0.520 | 0.565 | -# | driveable_surface | 0.552 | 0.633 | 0.720 | -# | other_flat | 0.293 | 0.330 | 0.361 | -# | sidewalk | 0.242 | 0.291 | 0.340 | -# | terrain | 0.236 | 0.305 | 0.369 | -# | manmade | 0.303 | 0.378 | 0.429 | -# | vegetation | 0.193 | 0.294 | 0.381 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.312 | 0.376 | 0.415 | -# +----------------------+----------+----------+----------+ -# 6019it [09:13, 10.87it/s] -# +----------------------+---------+---------+---------+ -# | Class Names | RayPQ@1 | RayPQ@2 | RayPQ@4 | -# +----------------------+---------+---------+---------+ -# | others | 0.020 | 0.028 | 0.030 | -# | barrier | 0.155 | 0.211 | 0.235 | -# | bicycle | 0.083 | 0.097 | 0.102 | -# | bus | 0.299 | 0.391 | 0.442 | -# | car | 0.277 | 0.360 | 0.384 | -# | construction_vehicle | 0.011 | 0.062 | 0.077 | -# | motorcycle | 0.098 | 0.149 | 0.166 | -# | pedestrian | 0.021 | 0.026 | 0.027 | -# | traffic_cone | 0.052 | 0.069 | 0.071 | -# | trailer | 0.043 | 0.062 | 0.071 | -# | truck | 0.158 | 0.248 | 0.293 | -# | driveable_surface | 0.440 | 0.559 | 0.680 | -# | other_flat | 0.065 | 0.089 | 0.107 | -# | sidewalk | 0.012 | 0.029 | 0.060 | -# | terrain | 0.009 | 0.028 | 0.053 | -# | manmade | 0.060 | 0.108 | 0.153 | -# | vegetation | 0.001 | 0.029 | 0.111 | -# +----------------------+---------+---------+---------+ -# | MEAN | 0.106 | 0.150 | 0.180 | -# +----------------------+---------+---------+---------+ -# {'RayIoU': 0.3676099569727112, 'RayIoU@1': 0.3118578145261225, 'RayIoU@2': 0.3757836068619914, 'RayIoU@4': 0.4151884495300196, -# 'RayPQ': 0.14529917059571107, 'RayPQ@1': 0.1061843618020449, 'RayPQ@2': 0.14961373290314467, 'RayPQ@4': 0.18009941708194366} - diff --git a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d.py b/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d.py deleted file mode 100644 index 76dfae891acbe630eebbcf31245c854a80160eef..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d.py +++ /dev/null @@ -1,280 +0,0 @@ -_base_ = ['../../../mmdetection3d/configs/_base_/datasets/nus-3d.py', - '../../../mmdetection3d/configs/_base_/default_runtime.py'] - -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -data_config = { - 'cams': [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ], - 'Ncams': - 6, - 'input_size': (256, 704), - 'src_size': (900, 1600), - - # Augmentation - 'resize': (-0.06, 0.11), - 'rot': (-5.4, 5.4), - 'flip': True, - 'crop_h': (0.0, 0.0), - 'resize_test': 0.00, -} - -grid_config = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 0.5], -} - -voxel_size = [0.1, 0.1, 0.2] -numC_Trans = 80 -multi_adj_frame_id_cfg = (1, 1+1, 1) - -model = dict( - type='BEVDepth4DOCC', - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(2, 3), - frozen_stages=-1, - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=False, - with_cp=True, - style='pytorch', - pretrained='torchvision://resnet50', - ), - img_neck=dict( - type='CustomFPN', - in_channels=[1024, 2048], - out_channels=512, - num_outs=1, - start_level=0, - out_ids=[0]), - img_view_transformer=dict( - type='LSSViewTransformerBEVDepth', - grid_config=grid_config, - input_size=data_config['input_size'], - in_channels=512, - out_channels=numC_Trans, - loss_depth_weight=1, - depthnet_cfg=dict(use_dcn=False, aspp_mid_channels=96), - downsample=16), - pre_process=dict( - type='CustomResNet', - numC_input=numC_Trans, - num_layer=[1, ], - num_channels=[numC_Trans, ], - stride=[1, ], - backbone_output_ids=[0, ]), - img_bev_encoder_backbone=dict( - type='CustomResNet', - numC_input=numC_Trans * (len(range(*multi_adj_frame_id_cfg))+1), - num_channels=[numC_Trans * 2, numC_Trans * 4, numC_Trans * 8]), - img_bev_encoder_neck=dict( - type='FPN_LSS', - in_channels=numC_Trans * 8 + numC_Trans * 2, - out_channels=256), - occ_head=dict( - type='BEVOCCHead2D_V2', - in_dim=256, - out_dim=256, - Dz=16, - use_mask=False, - num_classes=18, - use_predicter=True, - class_balance=True, - loss_occ=dict( - type='CustomFocalLoss', - use_sigmoid=True, - loss_weight=1.0 - ), - ) -) - -# Data -dataset_type = 'NuScenesDatasetOccpancy' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -bda_aug_conf = dict( - rot_lim=(-0., 0.), - scale_lim=(1., 1.), - flip_dx_ratio=0.5, - flip_dy_ratio=0.5 -) - -train_pipeline = [ - dict( - type='PrepareImageInputs', - is_train=True, - data_config=data_config, - sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=True), - dict(type='LoadOccGTFromFile'), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='PointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict( - type='Collect3D', keys=['img_inputs', 'gt_depth', 'voxel_semantics', - 'mask_lidar', 'mask_camera']) -] - -test_pipeline = [ - dict(type='PrepareImageInputs', data_config=data_config, sequential=True), - dict( - type='LoadAnnotationsBEVDepth', - bda_aug_conf=bda_aug_conf, - classes=class_names, - is_train=False), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points', 'img_inputs']) - ]) -] - - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False) - -share_data_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - stereo=False, - filter_empty_gt=False, - img_info_prototype='bevdet4d', - multi_adj_frame_id_cfg=multi_adj_frame_id_cfg, -) - -test_data_config = dict( - pipeline=test_pipeline, - ann_file=data_root + 'bevdetv2-nuscenes_infos_val.pkl') - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - data_root=data_root, - ann_file=data_root + 'bevdetv2-nuscenes_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - test_mode=False, - use_valid_flag=True, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=test_data_config, - test=test_data_config) - -for key in ['val', 'train', 'test']: - data[key].update(share_data_config) - -# Optimizer -optimizer = dict(type='AdamW', lr=1e-4, weight_decay=1e-2) -optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2)) -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=200, - warmup_ratio=0.001, - step=[24, ]) -runner = dict(type='EpochBasedRunner', max_epochs=24) - -custom_hooks = [ - dict( - type='MEGVIIEMAHook', - init_updates=10560, - priority='NORMAL', - ), -] - -load_from = "ckpts/bevdet-r50-4d-depth-cbgs.pth" -# fp16 = dict(loss_scale='dynamic') -evaluation = dict(interval=1, start=20, pipeline=test_pipeline) -checkpoint_config = dict(interval=1, max_keep_ckpts=5) - -# use_mask = False -# ===> others - IoU = 9.99 -# ===> barrier - IoU = 41.3 -# ===> bicycle - IoU = 22.84 -# ===> bus - IoU = 41.17 -# ===> car - IoU = 41.89 -# ===> construction_vehicle - IoU = 20.84 -# ===> motorcycle - IoU = 25.25 -# ===> pedestrian - IoU = 23.98 -# ===> traffic_cone - IoU = 24.36 -# ===> trailer - IoU = 26.39 -# ===> truck - IoU = 30.41 -# ===> driveable_surface - IoU = 58.26 -# ===> other_flat - IoU = 31.86 -# ===> sidewalk - IoU = 34.47 -# ===> terrain - IoU = 31.96 -# ===> manmade - IoU = 18.87 -# ===> vegetation - IoU = 18.95 -# ===> mIoU of 6019 samples: 29.57 -# {'mIoU': array([0.1 , 0.413, 0.228, 0.412, 0.419, 0.208, 0.253, 0.24 , 0.244, -# 0.264, 0.304, 0.583, 0.319, 0.345, 0.32 , 0.189, 0.189, 0.833])} - - -# +----------------------+----------+----------+----------+ -# | Class Names | RayIoU@1 | RayIoU@2 | RayIoU@4 | -# +----------------------+----------+----------+----------+ -# | others | 0.095 | 0.106 | 0.109 | -# | barrier | 0.392 | 0.444 | 0.466 | -# | bicycle | 0.236 | 0.279 | 0.287 | -# | bus | 0.513 | 0.616 | 0.675 | -# | car | 0.492 | 0.567 | 0.596 | -# | construction_vehicle | 0.170 | 0.256 | 0.296 | -# | motorcycle | 0.216 | 0.304 | 0.330 | -# | pedestrian | 0.315 | 0.363 | 0.378 | -# | traffic_cone | 0.280 | 0.315 | 0.323 | -# | trailer | 0.210 | 0.294 | 0.397 | -# | truck | 0.419 | 0.517 | 0.565 | -# | driveable_surface | 0.540 | 0.621 | 0.708 | -# | other_flat | 0.284 | 0.320 | 0.354 | -# | sidewalk | 0.242 | 0.289 | 0.337 | -# | terrain | 0.233 | 0.302 | 0.367 | -# | manmade | 0.291 | 0.370 | 0.422 | -# | vegetation | 0.190 | 0.290 | 0.376 | -# +----------------------+----------+----------+----------+ -# | MEAN | 0.301 | 0.368 | 0.411 | -# +----------------------+----------+----------+----------+ -# {'RayIoU': 0.3599406945036808, 'RayIoU@1': 0.30094679699387594, 'RayIoU@2': 0.36785252629427645, 'RayIoU@4': 0.4110227602228899} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/PKG-INFO b/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/PKG-INFO deleted file mode 100644 index cd5bb58e66029822ee6f75460ae37a7d21abd32f..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/PKG-INFO +++ /dev/null @@ -1,16 +0,0 @@ -Metadata-Version: 2.1 -Name: flashocc-plugin -Version: 0.0.0 -Summary: OpenMMLab's next-generation platformfor general 3D object detection. -Home-page: https://github.com/open-mmlab/mmdetection3d -Author: MMDetection3D Contributors -Author-email: zwwdev@gmail.com -License: Apache License 2.0 -Keywords: computer vision,3D object detection -Classifier: Development Status :: 4 - Beta -Classifier: License :: OSI Approved :: Apache Software License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.6 -Classifier: Programming Language :: Python :: 3.7 -Description-Content-Type: text/markdown diff --git a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/SOURCES.txt b/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/SOURCES.txt deleted file mode 100644 index 605fd3ddb703e37908c0a00f784e56b3752d6cdb..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/SOURCES.txt +++ /dev/null @@ -1,104 +0,0 @@ -__init__.py -setup.py -configs/bevdet_occ/bevdet-occ-r50-4d-stereo.py -configs/bevdet_occ/bevdet-occ-r50.py -configs/bevdet_occ/bevdet-occ-stbase-4d-stereo-512x1408.py -configs/flashocc/flashocc-r50-4d-stereo.py -configs/flashocc/flashocc-r50-M0-trt.py -configs/flashocc/flashocc-r50-M0.py -configs/flashocc/flashocc-r50-trt.py -configs/flashocc/flashocc-r50.py -configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_1e-2.py -configs/flashocc/flashocc-stbase-4d-stereo-512x1408_4x4_2e-4.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth-pano.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano-trt.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny-pano.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth-tiny.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth-trt.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f-pano.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm16f.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f-pano.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-longterm8f.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d-pano.py -configs/panoptic-flashocc/panoptic-flashocc-r50-depth4d.py -flashocc_plugin.egg-info/PKG-INFO -flashocc_plugin.egg-info/SOURCES.txt -flashocc_plugin.egg-info/dependency_links.txt -flashocc_plugin.egg-info/not-zip-safe -flashocc_plugin.egg-info/top_level.txt -mmdet3d_plugin/__init__.py -mmdet3d_plugin/core/__init__.py -mmdet3d_plugin/core/bbox/__init__.py -mmdet3d_plugin/core/bbox/coders/__init__.py -mmdet3d_plugin/core/bbox/coders/centerpoint_bbox_coders.py -mmdet3d_plugin/core/evaluation/__init__.py -mmdet3d_plugin/core/evaluation/occ_metrics.py -mmdet3d_plugin/core/evaluation/ray_metrics.py -mmdet3d_plugin/core/evaluation/ray_pq.py -mmdet3d_plugin/core/hook/__init__.py -mmdet3d_plugin/core/hook/ema.py -mmdet3d_plugin/core/hook/sequentialcontrol.py -mmdet3d_plugin/core/hook/syncbncontrol.py -mmdet3d_plugin/core/hook/utils.py -mmdet3d_plugin/core/post_processing/__init__.py -mmdet3d_plugin/core/post_processing/box3d_nms.py -mmdet3d_plugin/datasets/__init__.py -mmdet3d_plugin/datasets/ego_pose_dataset.py -mmdet3d_plugin/datasets/nuscenes_dataset_bevdet.py -mmdet3d_plugin/datasets/nuscenes_dataset_occ.py -mmdet3d_plugin/datasets/pipelines/__init__.py -mmdet3d_plugin/datasets/pipelines/formating.py -mmdet3d_plugin/datasets/pipelines/loading.py -mmdet3d_plugin/models/__init__.py -mmdet3d_plugin/models/backbones/__init__.py -mmdet3d_plugin/models/backbones/resnet.py -mmdet3d_plugin/models/backbones/swin.py -mmdet3d_plugin/models/dense_heads/__init__.py -mmdet3d_plugin/models/dense_heads/bev_centerpoint_head.py -mmdet3d_plugin/models/dense_heads/bev_occ_head.py -mmdet3d_plugin/models/detectors/__init__.py -mmdet3d_plugin/models/detectors/bevdepth.py -mmdet3d_plugin/models/detectors/bevdepth4d.py -mmdet3d_plugin/models/detectors/bevdet.py -mmdet3d_plugin/models/detectors/bevdet4d.py -mmdet3d_plugin/models/detectors/bevdet_occ.py -mmdet3d_plugin/models/detectors/bevstereo4d.py -mmdet3d_plugin/models/losses/__init__.py -mmdet3d_plugin/models/losses/cross_entropy_loss.py -mmdet3d_plugin/models/losses/focal_loss.py -mmdet3d_plugin/models/losses/lovasz_softmax.py -mmdet3d_plugin/models/losses/semkitti_loss.py -mmdet3d_plugin/models/model_utils/__init__.py -mmdet3d_plugin/models/model_utils/depthnet.py -mmdet3d_plugin/models/necks/__init__.py -mmdet3d_plugin/models/necks/fpn.py -mmdet3d_plugin/models/necks/lss_fpn.py -mmdet3d_plugin/models/necks/view_transformer.py -mmdet3d_plugin/ops/__init__.py -mmdet3d_plugin/ops/bev_pool/__init__.py -mmdet3d_plugin/ops/bev_pool/bev_pool.py -mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.cpp -mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.h -mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.cu -mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.hip -mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.cpp -mmdet3d_plugin/ops/bev_pool/src/bev_pooling.cpp -mmdet3d_plugin/ops/bev_pool/src/bev_pooling_hip.cpp -mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.cpp -mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.h -mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.cu -mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.hip -mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.cpp -mmdet3d_plugin/ops/bev_pool_v2/__init__.py -mmdet3d_plugin/ops/bev_pool_v2/bev_pool.py -mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool.cpp -mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_cuda.cu -mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_cuda.hip -mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_hip.cpp -mmdet3d_plugin/ops/nearest_assign/__init__.py -mmdet3d_plugin/ops/nearest_assign/nearest_assign.py -mmdet3d_plugin/ops/nearest_assign/src/nearest_assign.cpp -mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.cu -mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.hip -mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_hip.cpp \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/dependency_links.txt b/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/dependency_links.txt deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/not-zip-safe b/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/not-zip-safe deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/not-zip-safe +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/top_level.txt b/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/top_level.txt deleted file mode 100644 index c1752976813adf0da3df5f370c702a1221f491f5..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/flashocc_plugin.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -mmdet3d_plugin diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 5a63c105fba1fdbd1612b1b8382df536f52398eb..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 3583bf5e18d7e8b8482de3c18ec65c4f5a80e3e7..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__init__.py deleted file mode 100644 index c59c082bb38da9be7bdc84a802a9c9d4bc947e43..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .coders import * \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 4cce4b9563bb65859b52bd6714c043a613be7970..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__init__.py deleted file mode 100644 index 816bdcafa01285dd4d3fa25862a6c9036609936b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .centerpoint_bbox_coders import CenterPointBBoxCoder - -__all__ = ['CenterPointBBoxCoder'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index ffd5ed9c386b9b17e415d45fade59901d70d76d6..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/centerpoint_bbox_coders.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/centerpoint_bbox_coders.cpython-310.pyc deleted file mode 100644 index 5cb673155cfb9539af203e104c46055b2da277bf..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/bbox/coders/__pycache__/centerpoint_bbox_coders.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 6e221dc3750f06b09e3f09397498ff2ca5633ec4..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/occ_metrics.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/occ_metrics.cpython-310.pyc deleted file mode 100644 index 9c365a7a2deedc43c0e7b4f609f6374b357b92f2..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/occ_metrics.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_metrics.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_metrics.cpython-310.pyc deleted file mode 100644 index d0f1b23ab09242082a03ede87530dd682282ad1c..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_metrics.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_pq.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_pq.cpython-310.pyc deleted file mode 100644 index 8c3254adecadc42551a39fcb22733e062f9d7c45..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/__pycache__/ray_pq.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/occ_metrics.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/occ_metrics.py deleted file mode 100644 index 74dac7893ad4852dbe7110d1ff10f5b9889e13cb..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/occ_metrics.py +++ /dev/null @@ -1,260 +0,0 @@ -import numpy as np -import os -from pathlib import Path -from tqdm import tqdm -import pickle as pkl -import argparse -import time -import torch -import sys, platform -from sklearn.neighbors import KDTree -from termcolor import colored -from pathlib import Path -from copy import deepcopy -from functools import reduce - -np.seterr(divide='ignore', invalid='ignore') -os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" - - -def pcolor(string, color, on_color=None, attrs=None): - """ - Produces a colored string for printing - - Parameters - ---------- - string : str - String that will be colored - color : str - Color to use - on_color : str - Background color to use - attrs : list of str - Different attributes for the string - - Returns - ------- - string: str - Colored string - """ - return colored(string, color, on_color, attrs) - - -def getCellCoordinates(points, voxelSize): - return (points / voxelSize).astype(np.int) - - -def getNumUniqueCells(cells): - M = cells.max() + 1 - return np.unique(cells[:, 0] + M * cells[:, 1] + M ** 2 * cells[:, 2]).shape[0] - - -class Metric_mIoU(): - def __init__(self, - save_dir='.', - num_classes=18, - use_lidar_mask=False, - use_image_mask=False, - ): - self.class_names = ['others','barrier', 'bicycle', 'bus', 'car', 'construction_vehicle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'trailer', 'truck', - 'driveable_surface', 'other_flat', 'sidewalk', - 'terrain', 'manmade', 'vegetation','free'] - self.save_dir = save_dir - self.use_lidar_mask = use_lidar_mask - self.use_image_mask = use_image_mask - self.num_classes = num_classes - - self.point_cloud_range = [-40.0, -40.0, -1.0, 40.0, 40.0, 5.4] - self.occupancy_size = [0.4, 0.4, 0.4] - self.voxel_size = 0.4 - self.occ_xdim = int((self.point_cloud_range[3] - self.point_cloud_range[0]) / self.occupancy_size[0]) - self.occ_ydim = int((self.point_cloud_range[4] - self.point_cloud_range[1]) / self.occupancy_size[1]) - self.occ_zdim = int((self.point_cloud_range[5] - self.point_cloud_range[2]) / self.occupancy_size[2]) - self.voxel_num = self.occ_xdim * self.occ_ydim * self.occ_zdim - self.hist = np.zeros((self.num_classes, self.num_classes)) - self.cnt = 0 - - def hist_info(self, n_cl, pred, gt): - """ - build confusion matrix - # empty classes:0 - non-empty class: 0-16 - free voxel class: 17 - - Args: - n_cl (int): num_classes_occupancy - pred (1-d array): pred_occupancy_label, (N_valid, ) - gt (1-d array): gt_occupancu_label, (N_valid, ) - - Returns: - tuple:(hist, correctly number_predicted_labels, num_labelled_sample) - """ - assert pred.shape == gt.shape - k = (gt >= 0) & (gt < n_cl) # exclude 255 - labeled = np.sum(k) # N_total - correct = np.sum((pred[k] == gt[k])) # N_correct - - return ( - np.bincount( - n_cl * gt[k].astype(int) + pred[k].astype(int), minlength=n_cl ** 2 - ).reshape(n_cl, n_cl), # (N_cls, N_cls), - correct, # N_correct - labeled, # N_total - ) - - def per_class_iu(self, hist): - - return np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist)) - - def compute_mIoU(self, pred, label, n_classes): - """ - Args: - pred: (N_valid, ) - label: (N_valid, ) - n_classes: int=18 - - Returns: - - """ - hist = np.zeros((n_classes, n_classes)) # (N_cls, N_cls) - new_hist, correct, labeled = self.hist_info(n_classes, pred.flatten(), label.flatten()) - hist += new_hist # (N_cls, N_cls) - mIoUs = self.per_class_iu(hist) - # for ind_class in range(n_classes): - # print(str(round(mIoUs[ind_class] * 100, 2))) - # print('===> mIoU: ' + str(round(np.nanmean(mIoUs) * 100, 2))) - return round(np.nanmean(mIoUs) * 100, 2), hist - - def add_batch(self, semantics_pred, semantics_gt, mask_lidar, mask_camera): - """ - Args: - semantics_pred: (Dx, Dy, Dz, n_cls) - semantics_gt: (Dx, Dy, Dz) - mask_lidar: (Dx, Dy, Dz) - mask_camera: (Dx, Dy, Dz) - - Returns: - - """ - self.cnt += 1 - if self.use_image_mask: - masked_semantics_gt = semantics_gt[mask_camera] # (N_valid, ) - masked_semantics_pred = semantics_pred[mask_camera] # (N_valid, ) - elif self.use_lidar_mask: - masked_semantics_gt = semantics_gt[mask_lidar] - masked_semantics_pred = semantics_pred[mask_lidar] - else: - masked_semantics_gt = semantics_gt - masked_semantics_pred = semantics_pred - - # # pred = np.random.randint(low=0, high=17, size=masked_semantics.shape) - _, _hist = self.compute_mIoU(masked_semantics_pred, masked_semantics_gt, self.num_classes) - self.hist += _hist # (N_cls, N_cls) 列对应每个gt类别,行对应每个预测类别, 这样只有对角线位置上的预测是准确的. - - def count_miou(self): - mIoU = self.per_class_iu(self.hist) - # assert cnt == num_samples, 'some samples are not included in the miou calculation' - print(f'===> per class IoU of {self.cnt} samples:') - for ind_class in range(self.num_classes-1): - print(f'===> {self.class_names[ind_class]} - IoU = ' + str(round(mIoU[ind_class] * 100, 2))) - - print(f'===> mIoU of {self.cnt} samples: ' + str(round(np.nanmean(mIoU[:self.num_classes-1]) * 100, 2))) - # print(f'===> sample-wise averaged mIoU of {cnt} samples: ' + str(round(np.nanmean(mIoU_avg), 2))) - - eval_res = dict() - # eval_res['class_name'] = self.class_names - eval_res['mIoU'] = mIoU - # eval_res['cnt'] = self.cnt - return eval_res - - -class Metric_FScore(): - def __init__(self, - - leaf_size=10, - threshold_acc=0.6, - threshold_complete=0.6, - voxel_size=[0.4, 0.4, 0.4], - range=[-40, -40, -1, 40, 40, 5.4], - void=[17, 255], - use_lidar_mask=False, - use_image_mask=False, ) -> None: - - self.leaf_size = leaf_size - self.threshold_acc = threshold_acc - self.threshold_complete = threshold_complete - self.voxel_size = voxel_size - self.range = range - self.void = void - self.use_lidar_mask = use_lidar_mask - self.use_image_mask = use_image_mask - self.cnt=0 - self.tot_acc = 0. - self.tot_cmpl = 0. - self.tot_f1_mean = 0. - self.eps = 1e-8 - - - - def voxel2points(self, voxel): - # occIdx = torch.where(torch.logical_and(voxel != FREE, voxel != NOT_OBSERVED)) - # if isinstance(voxel, np.ndarray): voxel = torch.from_numpy(voxel) - mask = np.logical_not(reduce(np.logical_or, [voxel == self.void[i] for i in range(len(self.void))])) - occIdx = np.where(mask) - - points = np.concatenate((occIdx[0][:, None] * self.voxel_size[0] + self.voxel_size[0] / 2 + self.range[0], \ - occIdx[1][:, None] * self.voxel_size[1] + self.voxel_size[1] / 2 + self.range[1], \ - occIdx[2][:, None] * self.voxel_size[2] + self.voxel_size[2] / 2 + self.range[2]), - axis=1) - return points - - def add_batch(self, semantics_pred, semantics_gt, mask_lidar, mask_camera ): - - # for scene_token in tqdm(preds_dict.keys()): - self.cnt += 1 - - if self.use_image_mask: - semantics_gt[mask_camera == False] = 255 - semantics_pred[mask_camera == False] = 255 - elif self.use_lidar_mask: - semantics_gt[mask_lidar == False] = 255 - semantics_pred[mask_lidar == False] = 255 - else: - pass - - ground_truth = self.voxel2points(semantics_gt) - prediction = self.voxel2points(semantics_pred) - if prediction.shape[0] == 0: - accuracy=0 - completeness=0 - fmean=0 - - else: - prediction_tree = KDTree(prediction, leaf_size=self.leaf_size) - ground_truth_tree = KDTree(ground_truth, leaf_size=self.leaf_size) - complete_distance, _ = prediction_tree.query(ground_truth) - complete_distance = complete_distance.flatten() - - accuracy_distance, _ = ground_truth_tree.query(prediction) - accuracy_distance = accuracy_distance.flatten() - - # evaluate completeness - complete_mask = complete_distance < self.threshold_complete - completeness = complete_mask.mean() - - # evalute accuracy - accuracy_mask = accuracy_distance < self.threshold_acc - accuracy = accuracy_mask.mean() - - fmean = 2.0 / (1 / (accuracy+self.eps) + 1 / (completeness+self.eps)) - - self.tot_acc += accuracy - self.tot_cmpl += completeness - self.tot_f1_mean += fmean - - def count_fscore(self,): - base_color, attrs = 'red', ['bold', 'dark'] - print(pcolor('\n######## F score: {} #######'.format(self.tot_f1_mean / self.cnt), base_color, attrs=attrs)) - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_metrics.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_metrics.py deleted file mode 100644 index e90f7bf16ec995bc115c3d34accad9fb2fec175b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_metrics.py +++ /dev/null @@ -1,282 +0,0 @@ -# Acknowledgments: https://github.com/tarashakhurana/4d-occ-forecasting -# Modified by Haisong Liu -import math -import copy -import numpy as np -import torch -from torch.utils.cpp_extension import load -from tqdm import tqdm -from prettytable import PrettyTable -from .ray_pq import Metric_RayPQ - - -dvr = load("dvr", sources=["lib/dvr/dvr.cpp", "lib/dvr/dvr.cu"], verbose=True, extra_cuda_cflags=['-allow-unsupported-compiler']) -_pc_range = [-40, -40, -1.0, 40, 40, 5.4] -_voxel_size = 0.4 - -occ_class_names = [ - 'others', 'barrier', 'bicycle', 'bus', 'car', 'construction_vehicle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'trailer', 'truck', - 'driveable_surface', 'other_flat', 'sidewalk', - 'terrain', 'manmade', 'vegetation', 'free' -] - -# https://github.com/tarashakhurana/4d-occ-forecasting/blob/ff986082cd6ea10e67ab7839bf0e654736b3f4e2/test_fgbg.py#L29C1-L46C16 -def get_rendered_pcds(origin, points, tindex, pred_dist): - pcds = [] - - for t in range(len(origin)): - mask = (tindex == t) - # skip the ones with no data - if not mask.any(): - continue - _pts = points[mask, :3] - # use ground truth lidar points for the raycasting direction - v = _pts - origin[t][None, :] - d = v / np.sqrt((v ** 2).sum(axis=1, keepdims=True)) - pred_pts = origin[t][None, :] + d * pred_dist[mask][:, None] - pcds.append(torch.from_numpy(pred_pts)) - - return pcds - - -def meshgrid3d(occ_size, pc_range): - W, H, D = occ_size - - xs = torch.linspace(0.5, W - 0.5, W).view(W, 1, 1).expand(W, H, D) / W - ys = torch.linspace(0.5, H - 0.5, H).view(1, H, 1).expand(W, H, D) / H - zs = torch.linspace(0.5, D - 0.5, D).view(1, 1, D).expand(W, H, D) / D - xs = xs * (pc_range[3] - pc_range[0]) + pc_range[0] - ys = ys * (pc_range[4] - pc_range[1]) + pc_range[1] - zs = zs * (pc_range[5] - pc_range[2]) + pc_range[2] - xyz = torch.stack((xs, ys, zs), -1) - - return xyz - - -def generate_lidar_rays(): - # prepare lidar ray angles - pitch_angles = [] - for k in range(10): - angle = math.pi / 2 - math.atan(k + 1) - pitch_angles.append(-angle) - - # nuscenes lidar fov: [0.2107773983152201, -0.5439104895672159] (rad) - while pitch_angles[-1] < 0.21: - delta = pitch_angles[-1] - pitch_angles[-2] - pitch_angles.append(pitch_angles[-1] + delta) - - lidar_rays = [] - for pitch_angle in pitch_angles: - for azimuth_angle in np.arange(0, 360, 1): - azimuth_angle = np.deg2rad(azimuth_angle) - - x = np.cos(pitch_angle) * np.cos(azimuth_angle) - y = np.cos(pitch_angle) * np.sin(azimuth_angle) - z = np.sin(pitch_angle) - - lidar_rays.append((x, y, z)) - - return np.array(lidar_rays, dtype=np.float32) - - -def process_one_sample(sem_pred, lidar_rays, output_origin, instance_pred=None): - # lidar origin in ego coordinate - # lidar_origin = torch.tensor([[[0.9858, 0.0000, 1.8402]]]) - T = output_origin.shape[1] - pred_pcds_t = [] - - free_id = len(occ_class_names) - 1 - occ_pred = copy.deepcopy(sem_pred) - occ_pred[sem_pred < free_id] = 1 - occ_pred[sem_pred == free_id] = 0 - occ_pred = occ_pred.permute(2, 1, 0) - occ_pred = occ_pred[None, None, :].contiguous().float() - - offset = torch.Tensor(_pc_range[:3])[None, None, :] - scaler = torch.Tensor([_voxel_size] * 3)[None, None, :] - - lidar_tindex = torch.zeros([1, lidar_rays.shape[0]]) - - for t in range(T): - lidar_origin = output_origin[:, t:t+1, :] # [1, 1, 3] - lidar_endpts = lidar_rays[None] + lidar_origin # [1, 15840, 3] - - output_origin_render = ((lidar_origin - offset) / scaler).float() # [1, 1, 3] - output_points_render = ((lidar_endpts - offset) / scaler).float() # [1, N, 3] - output_tindex_render = lidar_tindex # [1, N], all zeros - - with torch.no_grad(): - pred_dist, _, coord_index = dvr.render_forward( - occ_pred.cuda(), - output_origin_render.cuda(), - output_points_render.cuda(), - output_tindex_render.cuda(), - [1, 16, 200, 200], - "test" - ) - pred_dist *= _voxel_size - - pred_pcds = get_rendered_pcds( - lidar_origin[0].cpu().numpy(), - lidar_endpts[0].cpu().numpy(), - lidar_tindex[0].cpu().numpy(), - pred_dist[0].cpu().numpy() - ) - coord_index = coord_index[0, :, :].long().cpu() # [N, 3] - - pred_label = sem_pred[coord_index[:, 0], coord_index[:, 1], coord_index[:, 2]][:, None] # [N, 1] - pred_dist = pred_dist[0, :, None].cpu() - - if instance_pred is not None: - pred_instance = instance_pred[coord_index[:, 0], coord_index[:, 1], coord_index[:, 2]][:, None] # [N, 1] - pred_pcds = torch.cat([pred_label.float(), pred_instance.float(), pred_dist], dim=-1) - else: - pred_pcds = torch.cat([pred_label.float(), pred_dist], dim=-1) - - pred_pcds_t.append(pred_pcds) - - pred_pcds_t = torch.cat(pred_pcds_t, dim=0) - - return pred_pcds_t.numpy() - - -def calc_metrics(pcd_pred_list, pcd_gt_list): - thresholds = [1, 2, 4] - - gt_cnt = np.zeros([len(occ_class_names)]) - pred_cnt = np.zeros([len(occ_class_names)]) - tp_cnt = np.zeros([len(thresholds), len(occ_class_names)]) - - for pcd_pred, pcd_gt in zip(pcd_pred_list, pcd_gt_list): - for j, threshold in enumerate(thresholds): - # L1 - depth_pred = pcd_pred[:, 1] - depth_gt = pcd_gt[:, 1] - l1_error = np.abs(depth_pred - depth_gt) - tp_dist_mask = (l1_error < threshold) - - for i, cls in enumerate(occ_class_names): - cls_id = occ_class_names.index(cls) - cls_mask_pred = (pcd_pred[:, 0] == cls_id) - cls_mask_gt = (pcd_gt[:, 0] == cls_id) - - gt_cnt_i = cls_mask_gt.sum() - pred_cnt_i = cls_mask_pred.sum() - if j == 0: - gt_cnt[i] += gt_cnt_i - pred_cnt[i] += pred_cnt_i - - tp_cls = cls_mask_gt & cls_mask_pred # [N] - tp_mask = np.logical_and(tp_cls, tp_dist_mask) - tp_cnt[j][i] += tp_mask.sum() - - iou_list = [] - for j, threshold in enumerate(thresholds): - iou_list.append((tp_cnt[j] / (gt_cnt + pred_cnt - tp_cnt[j]))[:-1]) - - return iou_list - - -def main_raypq(sem_pred_list, sem_gt_list, inst_pred_list, inst_gt_list, lidar_origin_list): - torch.cuda.empty_cache() - - eval_metrics_pq = Metric_RayPQ( - num_classes=len(occ_class_names), - thresholds=[1, 2, 4] - ) - - # generate lidar rays - lidar_rays = generate_lidar_rays() - lidar_rays = torch.from_numpy(lidar_rays) - - for sem_pred, sem_gt, inst_pred, inst_gt, lidar_origins in \ - tqdm(zip(sem_pred_list, sem_gt_list, inst_pred_list, inst_gt_list, lidar_origin_list), ncols=50): - sem_pred = torch.from_numpy(np.reshape(sem_pred, [200, 200, 16])) - sem_gt = torch.from_numpy(np.reshape(sem_gt, [200, 200, 16])) - - inst_pred = torch.from_numpy(np.reshape(inst_pred, [200, 200, 16])) - inst_gt = torch.from_numpy(np.reshape(inst_gt, [200, 200, 16])) - - pcd_pred = process_one_sample(sem_pred, lidar_rays, lidar_origins, instance_pred=inst_pred) - pcd_gt = process_one_sample(sem_gt, lidar_rays, lidar_origins, instance_pred=inst_gt) - - # evalute on non-free rays - valid_mask = (pcd_gt[:, 0].astype(np.int32) != len(occ_class_names) - 1) - pcd_pred = pcd_pred[valid_mask] - pcd_gt = pcd_gt[valid_mask] - - assert pcd_pred.shape == pcd_gt.shape - - sem_gt = pcd_gt[:, 0].astype(np.int32) - sem_pred = pcd_pred[:, 0].astype(np.int32) - - instances_gt = pcd_gt[:, 1].astype(np.int32) - instances_pred = pcd_pred[:, 1].astype(np.int32) - - # L1 - depth_gt = pcd_gt[:, 2] - depth_pred = pcd_pred[:, 2] - l1_error = np.abs(depth_pred - depth_gt) - - eval_metrics_pq.add_batch(sem_pred, sem_gt, instances_pred, instances_gt, l1_error) - - torch.cuda.empty_cache() - - return eval_metrics_pq.count_pq() - - -def main(sem_pred_list, sem_gt_list, lidar_origin_list): - torch.cuda.empty_cache() - - # generate lidar rays - lidar_rays = generate_lidar_rays() - lidar_rays = torch.from_numpy(lidar_rays) - - pcd_pred_list, pcd_gt_list = [], [] - for sem_pred, sem_gt, lidar_origins in tqdm(zip(sem_pred_list, sem_gt_list, lidar_origin_list), ncols=50): - sem_pred = torch.from_numpy(np.reshape(sem_pred, [200, 200, 16])) - sem_gt = torch.from_numpy(np.reshape(sem_gt, [200, 200, 16])) - - pcd_pred = process_one_sample(sem_pred, lidar_rays, lidar_origins) - pcd_gt = process_one_sample(sem_gt, lidar_rays, lidar_origins) - - # evalute on non-free rays - valid_mask = (pcd_gt[:, 0].astype(np.int32) != len(occ_class_names) - 1) - pcd_pred = pcd_pred[valid_mask] - pcd_gt = pcd_gt[valid_mask] - - assert pcd_pred.shape == pcd_gt.shape - pcd_pred_list.append(pcd_pred) - pcd_gt_list.append(pcd_gt) - - iou_list = calc_metrics(pcd_pred_list, pcd_gt_list) - rayiou = np.nanmean(iou_list) - rayiou_0 = np.nanmean(iou_list[0]) - rayiou_1 = np.nanmean(iou_list[1]) - rayiou_2 = np.nanmean(iou_list[2]) - - table = PrettyTable([ - 'Class Names', - 'RayIoU@1', 'RayIoU@2', 'RayIoU@4' - ]) - table.float_format = '.3' - - for i in range(len(occ_class_names) - 1): - table.add_row([ - occ_class_names[i], - iou_list[0][i], iou_list[1][i], iou_list[2][i] - ], divider=(i == len(occ_class_names) - 2)) - - table.add_row(['MEAN', rayiou_0, rayiou_1, rayiou_2]) - - print(table) - - torch.cuda.empty_cache() - - return { - 'RayIoU': rayiou, - 'RayIoU@1': rayiou_0, - 'RayIoU@2': rayiou_1, - 'RayIoU@4': rayiou_2, - } diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_pq.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_pq.py deleted file mode 100644 index b48e8feabc71b0049c946c96b05d250fe19be522..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/evaluation/ray_pq.py +++ /dev/null @@ -1,197 +0,0 @@ -import numpy as np -from prettytable import PrettyTable - - -class Metric_RayPQ: - def __init__(self, - num_classes=18, - thresholds=[1, 2, 4]): - """ - Args: - ignore_index (llist): Class ids that not be considered in pq counting. - """ - if num_classes == 18: - self.class_names = [ - 'others','barrier', 'bicycle', 'bus', 'car', 'construction_vehicle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'trailer', 'truck', - 'driveable_surface', 'other_flat', 'sidewalk', - 'terrain', 'manmade', 'vegetation','free' - ] - else: - raise ValueError - - self.num_classes = num_classes - self.id_offset = 2 ** 16 - self.eps = 1e-5 - self.thresholds = thresholds - - self.min_num_points = 10 - self.include = np.array( - [n for n in range(self.num_classes - 1)], - dtype=int) - self.cnt = 0 - - # panoptic stuff - self.pan_tp = np.zeros([len(self.thresholds), num_classes], dtype=int) - self.pan_iou = np.zeros([len(self.thresholds), num_classes], dtype=np.double) - self.pan_fp = np.zeros([len(self.thresholds), num_classes], dtype=int) - self.pan_fn = np.zeros([len(self.thresholds), num_classes], dtype=int) - - def add_batch(self,semantics_pred,semantics_gt,instances_pred,instances_gt, l1_error): - self.cnt += 1 - self.add_panoptic_sample(semantics_pred, semantics_gt, instances_pred, instances_gt, l1_error) - - def add_panoptic_sample(self, semantics_pred, semantics_gt, instances_pred, instances_gt, l1_error): - """Add one sample of panoptic predictions and ground truths for - evaluation. - - Args: - semantics_pred (np.ndarray): Semantic predictions. - semantics_gt (np.ndarray): Semantic ground truths. - instances_pred (np.ndarray): Instance predictions. - instances_gt (np.ndarray): Instance ground truths. - """ - # get instance_class_id from instance_gt - instance_class_ids = [self.num_classes - 1] - for i in range(1, instances_gt.max() + 1): - class_id = np.unique(semantics_gt[instances_gt == i]) - # assert class_id.shape[0] == 1, "each instance must belong to only one class" - if class_id.shape[0] == 1: - instance_class_ids.append(class_id[0]) - else: - instance_class_ids.append(self.num_classes - 1) - instance_class_ids = np.array(instance_class_ids) - - instance_count = 1 - final_instance_class_ids = [] - final_instances = np.zeros_like(instances_gt) # empty space has instance id "0" - - for class_id in range(self.num_classes - 1): - if np.sum(semantics_gt == class_id) == 0: - continue - - if self.class_names[class_id] in ['car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'motorcycle', 'bicycle', 'pedestrian']: - # treat as instances - for instance_id in range(len(instance_class_ids)): - if instance_class_ids[instance_id] != class_id: - continue - final_instances[instances_gt == instance_id] = instance_count - instance_count += 1 - final_instance_class_ids.append(class_id) - else: - # treat as semantics - final_instances[semantics_gt == class_id] = instance_count - instance_count += 1 - final_instance_class_ids.append(class_id) - - instances_gt = final_instances - - # avoid zero (ignored label) - instances_pred = instances_pred + 1 - instances_gt = instances_gt + 1 - - for j, threshold in enumerate(self.thresholds): - tp_dist_mask = l1_error < threshold - # for each class (except the ignored ones) - for cl in self.include: - # get a class mask - pred_inst_in_cl_mask = semantics_pred == cl - gt_inst_in_cl_mask = semantics_gt == cl - - # get instance points in class (makes outside stuff 0) - pred_inst_in_cl = instances_pred * pred_inst_in_cl_mask.astype(int) - gt_inst_in_cl = instances_gt * gt_inst_in_cl_mask.astype(int) - - # generate the areas for each unique instance prediction - unique_pred, counts_pred = np.unique( - pred_inst_in_cl[pred_inst_in_cl > 0], return_counts=True) - id2idx_pred = {id: idx for idx, id in enumerate(unique_pred)} - matched_pred = np.array([False] * unique_pred.shape[0]) - - # generate the areas for each unique instance gt_np - unique_gt, counts_gt = np.unique( - gt_inst_in_cl[gt_inst_in_cl > 0], return_counts=True) - id2idx_gt = {id: idx for idx, id in enumerate(unique_gt)} - matched_gt = np.array([False] * unique_gt.shape[0]) - - # generate intersection using offset - valid_combos = np.logical_and(pred_inst_in_cl > 0, - gt_inst_in_cl > 0) - # add dist_mask - valid_combos = np.logical_and(valid_combos, tp_dist_mask) - - id_offset_combo = pred_inst_in_cl[ - valid_combos] + self.id_offset * gt_inst_in_cl[valid_combos] - unique_combo, counts_combo = np.unique( - id_offset_combo, return_counts=True) - - # generate an intersection map - # count the intersections with over 0.5 IoU as TP - gt_labels = unique_combo // self.id_offset - pred_labels = unique_combo % self.id_offset - gt_areas = np.array([counts_gt[id2idx_gt[id]] for id in gt_labels]) - pred_areas = np.array( - [counts_pred[id2idx_pred[id]] for id in pred_labels]) - intersections = counts_combo - unions = gt_areas + pred_areas - intersections - ious = intersections.astype(float) / unions.astype(float) - - tp_indexes = ious > 0.5 - self.pan_tp[j][cl] += np.sum(tp_indexes) - self.pan_iou[j][cl] += np.sum(ious[tp_indexes]) - - matched_gt[[id2idx_gt[id] for id in gt_labels[tp_indexes]]] = True - matched_pred[[id2idx_pred[id] - for id in pred_labels[tp_indexes]]] = True - - # count the FN - if len(counts_gt) > 0: - self.pan_fn[j][cl] += np.sum( - np.logical_and(counts_gt >= self.min_num_points, - ~matched_gt)) - - # count the FP - if len(matched_pred) > 0: - self.pan_fp[j][cl] += np.sum( - np.logical_and(counts_pred >= self.min_num_points, - ~matched_pred)) - - def count_pq(self): - sq_all = self.pan_iou.astype(np.double) / np.maximum( - self.pan_tp.astype(np.double), self.eps) - rq_all = self.pan_tp.astype(np.double) / np.maximum( - self.pan_tp.astype(np.double) + 0.5 * self.pan_fp.astype(np.double) - + 0.5 * self.pan_fn.astype(np.double), self.eps) - pq_all = sq_all * rq_all - - # mask classes not occurring in dataset - mask = (self.pan_tp + self.pan_fp + self.pan_fn) > 0 - pq_all[~mask] = float('nan') - - table = PrettyTable([ - 'Class Names', - 'RayPQ@%d' % self.thresholds[0], - 'RayPQ@%d' % self.thresholds[1], - 'RayPQ@%d' % self.thresholds[2] - ]) - table.float_format = '.3' - - for i in range(len(self.class_names) - 1): - table.add_row([ - self.class_names[i], - pq_all[0][i], pq_all[1][i], pq_all[2][i], - ], divider=(i == len(self.class_names) - 2)) - - table.add_row([ - 'MEAN', - np.nanmean(pq_all[0]), np.nanmean(pq_all[1]), np.nanmean(pq_all[2]) - ]) - - print(table) - - return { - 'RayPQ': np.nanmean(pq_all), - 'RayPQ@1': np.nanmean(pq_all[0]), - 'RayPQ@2': np.nanmean(pq_all[1]), - 'RayPQ@4': np.nanmean(pq_all[2]), - } diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index cfbf725952e12477daa90d7c48d929645e194173..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/ema.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/ema.cpython-310.pyc deleted file mode 100644 index 5797d493de4d484670544e0995a6b81d699fc1df..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/ema.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/sequentialcontrol.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/sequentialcontrol.cpython-310.pyc deleted file mode 100644 index 0406cd60f77257df872004fba897bfb0757a151a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/sequentialcontrol.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/syncbncontrol.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/syncbncontrol.cpython-310.pyc deleted file mode 100644 index 040eb0424cdfc9b3a6d2b0066fb8963d522447c1..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/syncbncontrol.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/utils.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/utils.cpython-310.pyc deleted file mode 100644 index 5981f8ba99d573fd7bb43a5d71ed272838e44f87..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/__pycache__/utils.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/sequentialcontrol.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/sequentialcontrol.py deleted file mode 100644 index 602c29c2126f5496f3bec6cb1b92c00993ed4a31..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/sequentialcontrol.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from mmcv.runner.hooks import HOOKS, Hook -from .utils import is_parallel - -__all__ = ['SequentialControlHook'] - - -@HOOKS.register_module() -class SequentialControlHook(Hook): - """ """ - - def __init__(self, temporal_start_epoch=1): - super().__init__() - self.temporal_start_epoch=temporal_start_epoch - - def set_temporal_flag(self, runner, flag): - if is_parallel(runner.model.module): - runner.model.module.module.with_prev=flag - else: - runner.model.module.with_prev = flag - - def before_run(self, runner): - self.set_temporal_flag(runner, False) - - def before_train_epoch(self, runner): - if runner.epoch > self.temporal_start_epoch: - self.set_temporal_flag(runner, True) \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/syncbncontrol.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/syncbncontrol.py deleted file mode 100644 index ce6d4fe42fe43d437ec8ea486548fb3a3d160d01..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/hook/syncbncontrol.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from mmcv.runner.hooks import HOOKS, Hook -from .utils import is_parallel -from torch.nn import SyncBatchNorm - -__all__ = ['SyncbnControlHook'] - - -@HOOKS.register_module() -class SyncbnControlHook(Hook): - """ """ - - def __init__(self, syncbn_start_epoch=1): - super().__init__() - self.is_syncbn=False - self.syncbn_start_epoch = syncbn_start_epoch - - def cvt_syncbn(self, runner): - if is_parallel(runner.model.module): - runner.model.module.module=\ - SyncBatchNorm.convert_sync_batchnorm(runner.model.module.module, - process_group=None) - else: - runner.model.module=\ - SyncBatchNorm.convert_sync_batchnorm(runner.model.module, - process_group=None) - - def before_train_epoch(self, runner): - if runner.epoch>= self.syncbn_start_epoch and not self.is_syncbn: - print('start use syncbn') - self.cvt_syncbn(runner) - self.is_syncbn=True - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__init__.py deleted file mode 100644 index 63a2c3e0d20fca1b206f2149a0fd1ffe676e4d75..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .box3d_nms import nms_bev \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index c3bbfbc17666440d989a1622fd531dd831aee930..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/box3d_nms.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/box3d_nms.cpython-310.pyc deleted file mode 100644 index f5d615a3cb8f79cd32b0d415b369661b004f3314..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/core/post_processing/__pycache__/box3d_nms.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__init__.py deleted file mode 100644 index 00de1cd7074718aaca50e35af73be3a8b7789fd0..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .nuscenes_dataset_bevdet import NuScenesDatasetBEVDet -from .nuscenes_dataset_occ import NuScenesDatasetOccpancy -from .pipelines import * - -__all__ = ['NuScenesDatasetBEVDet', 'NuScenesDatasetOccpancy'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 7500fe00e8f06154ecf2010bb84f78d033961206..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/ego_pose_dataset.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/ego_pose_dataset.cpython-310.pyc deleted file mode 100644 index 260942e88544193d36cc231c050b20a086ecb85b..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/ego_pose_dataset.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_bevdet.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_bevdet.cpython-310.pyc deleted file mode 100644 index 85c76abcb9ae77aaf8cb56a94cf09b8f9d834b6a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_bevdet.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_occ.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_occ.cpython-310.pyc deleted file mode 100644 index f64a64a09c016195aa3e8782966c5060ddfbd375..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/__pycache__/nuscenes_dataset_occ.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/ego_pose_dataset.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/ego_pose_dataset.py deleted file mode 100644 index 86559cd4f5243c65511e2fcf29832e0ee1ea37cf..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/ego_pose_dataset.py +++ /dev/null @@ -1,94 +0,0 @@ -import torch -import numpy as np -from pyquaternion import Quaternion -from torch.utils.data import Dataset -np.set_printoptions(precision=3, suppress=True) - - -def trans_matrix(T, R): - tm = np.eye(4) - tm[:3, :3] = R.rotation_matrix - tm[:3, 3] = T - return tm - - -class EgoPoseDataset(Dataset): - def __init__(self, data_infos): - super(EgoPoseDataset, self).__init__() - - self.data_infos = data_infos - self.scene_frames = {} - - for info in data_infos: - scene_token = self.get_scene_token(info) - if scene_token not in self.scene_frames: - self.scene_frames[scene_token] = [] - self.scene_frames[scene_token].append(info) - - def __len__(self): - return len(self.data_infos) - - def get_scene_token(self, info): - if 'scene_token' in info: - scene_name = info['scene_token'] - else: - scene_name = info['occ_path'].split('occupancy/')[-1].split('/')[0] - return scene_name - - def get_ego_from_lidar(self, info): - ego_from_lidar = trans_matrix( - np.array(info['lidar2ego_translation']), - Quaternion(info['lidar2ego_rotation'])) - return ego_from_lidar - - def get_global_pose(self, info, inverse=False): - global_from_ego = trans_matrix( - np.array(info['ego2global_translation']), - Quaternion(info['ego2global_rotation'])) - ego_from_lidar = trans_matrix( - np.array(info['lidar2ego_translation']), - Quaternion(info['lidar2ego_rotation'])) - pose = global_from_ego.dot(ego_from_lidar) - if inverse: - pose = np.linalg.inv(pose) - return pose - - def __getitem__(self, idx): - info = self.data_infos[idx] - - ref_sample_token = info['token'] - ref_lidar_from_global = self.get_global_pose(info, inverse=True) - ref_ego_from_lidar = self.get_ego_from_lidar(info) - - scene_token = self.get_scene_token(info) - scene_frame = self.scene_frames[scene_token] - ref_index = scene_frame.index(info) - - # NOTE: getting output frames - output_origin_list = [] - for curr_index in range(len(scene_frame)): - # if this exists a valid target - if curr_index == ref_index: - origin_tf = np.array([0.0, 0.0, 0.0], dtype=np.float32) - else: - # transform from the current lidar frame to global and then to the reference lidar frame - global_from_curr = self.get_global_pose(scene_frame[curr_index], inverse=False) - ref_from_curr = ref_lidar_from_global.dot(global_from_curr) - origin_tf = np.array(ref_from_curr[:3, 3], dtype=np.float32) - - origin_tf_pad = np.ones([4]) - origin_tf_pad[:3] = origin_tf # pad to [4] - origin_tf = np.dot(ref_ego_from_lidar[:3], origin_tf_pad.T).T # [3] - - # origin - if np.abs(origin_tf[0]) < 39 and np.abs(origin_tf[1]) < 39: - output_origin_list.append(origin_tf) - - # select 8 origins - if len(output_origin_list) > 8: - select_idx = np.round(np.linspace(0, len(output_origin_list) - 1, 8)).astype(np.int64) - output_origin_list = [output_origin_list[i] for i in select_idx] - - output_origin_tensor = torch.from_numpy(np.stack(output_origin_list)) # [T, 3] - - return (ref_sample_token, output_origin_tensor) diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/nuscenes_dataset_occ.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/nuscenes_dataset_occ.py deleted file mode 100644 index 36494ec2c933b00744dd320459e30aa5cc800c8c..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/nuscenes_dataset_occ.py +++ /dev/null @@ -1,187 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import os -import mmcv -import torch -import cv2 -import numpy as np -from tqdm import tqdm - -from mmdet3d.datasets import DATASETS -from .nuscenes_dataset_bevdet import NuScenesDatasetBEVDet as NuScenesDataset -from ..core.evaluation.occ_metrics import Metric_mIoU, Metric_FScore -from .ego_pose_dataset import EgoPoseDataset -from ..core.evaluation.ray_metrics import main as calc_rayiou -from torch.utils.data import DataLoader -from ..core.evaluation.ray_metrics import main_raypq -import torch -import glob - - -colors_map = np.array( - [ - [0, 0, 0, 255], # 0 undefined - [255, 158, 0, 255], # 1 car orange - [0, 0, 230, 255], # 2 pedestrian Blue - [47, 79, 79, 255], # 3 sign Darkslategrey - [220, 20, 60, 255], # 4 CYCLIST Crimson - [255, 69, 0, 255], # 5 traiffic_light Orangered - [255, 140, 0, 255], # 6 pole Darkorange - [233, 150, 70, 255], # 7 construction_cone Darksalmon - [255, 61, 99, 255], # 8 bycycle Red - [112, 128, 144, 255],# 9 motorcycle Slategrey - [222, 184, 135, 255],# 10 building Burlywood - [0, 175, 0, 255], # 11 vegetation Green - [165, 42, 42, 255], # 12 trunk nuTonomy green - [0, 207, 191, 255], # 13 curb, road, lane_marker, other_ground - [75, 0, 75, 255], # 14 walkable, sidewalk - [255, 0, 0, 255], # 15 unobsrvd - [0, 0, 0, 0], # 16 undefined - [0, 0, 0, 0], # 16 undefined - ]) - - -@DATASETS.register_module() -class NuScenesDatasetOccpancy(NuScenesDataset): - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - input_dict = super(NuScenesDatasetOccpancy, self).get_data_info(index) - # standard protocol modified from SECOND.Pytorch - # input_dict['occ_gt_path'] = os.path.join(self.data_root, self.data_infos[index]['occ_path']) - input_dict['occ_gt_path'] = self.data_infos[index]['occ_path'] - return input_dict - - def evaluate(self, occ_results, runner=None, show_dir=None, **eval_kwargs): - metric = eval_kwargs['metric'][0] - print("metric = ", metric) - if metric == 'ray-iou': - occ_gts = [] - occ_preds = [] - lidar_origins = [] - inst_gts = [] - inst_preds = [] - - print('\nStarting Evaluation...') - - data_loader = DataLoader( - EgoPoseDataset(self.data_infos), - batch_size=1, - shuffle=False, - num_workers=8 - ) - - sample_tokens = [info['token'] for info in self.data_infos] - - for i, batch in enumerate(data_loader): - # if i > 5: - # break - token = batch[0][0] - output_origin = batch[1] - - data_id = sample_tokens.index(token) - info = self.data_infos[data_id] - # occ_gt = np.load(os.path.join(self.data_root, info['occ_path'], 'labels.npz')) - # occ_gt = np.load(os.path.join(info['occ_path'], 'labels.npz')) - occ_gt = np.load(os.path.join(info['occ_path'].replace('data/nuscenes/gts/', 'data/nuscenes/occ3d_panoptic/'), 'labels.npz')) - gt_semantics = occ_gt['semantics'] # (Dx, Dy, Dz) - mask_lidar = occ_gt['mask_lidar'].astype(bool) # (Dx, Dy, Dz) - mask_camera = occ_gt['mask_camera'].astype(bool) # (Dx, Dy, Dz) - occ_pred = occ_results[data_id]['pred_occ'].cpu().numpy() # (Dx, Dy, Dz) - # occ_pred = occ_results[data_id]['pred_occ'] # (Dx, Dy, Dz) - - lidar_origins.append(output_origin) - occ_gts.append(gt_semantics) - occ_preds.append(occ_pred) - - if 'pano_inst' in occ_results[data_id].keys(): - pano_inst = occ_results[data_id]['pano_inst'].cpu() - # pano_inst = torch.from_numpy(occ_results[data_id]['pano_inst']) - pano_inst = pano_inst.squeeze(0).numpy() - gt_instances = occ_gt['instances'] - inst_gts.append(gt_instances) - inst_preds.append(pano_inst) - - eval_results = calc_rayiou(occ_preds, occ_gts, lidar_origins) - if len(inst_preds) > 0: - eval_results.update(main_raypq(occ_preds, occ_gts, inst_preds, inst_gts, lidar_origins)) - # eval_results = main_raypq(occ_preds, occ_gts, inst_preds, inst_gts, lidar_origins) - else: - self.occ_eval_metrics = Metric_mIoU( - num_classes=18, - use_lidar_mask=False, - use_image_mask=True) - - print('\nStarting Evaluation...') - for index, occ_pred in enumerate(tqdm(occ_results)): - # occ_pred: (Dx, Dy, Dz) - info = self.data_infos[index] - # occ_gt = np.load(os.path.join(self.data_root, info['occ_path'], 'labels.npz')) - occ_gt = np.load(os.path.join(info['occ_path'], 'labels.npz')) - gt_semantics = occ_gt['semantics'] # (Dx, Dy, Dz) - mask_lidar = occ_gt['mask_lidar'].astype(bool) # (Dx, Dy, Dz) - mask_camera = occ_gt['mask_camera'].astype(bool) # (Dx, Dy, Dz) - # occ_pred = occ_pred - self.occ_eval_metrics.add_batch( - occ_pred['pred_occ'] if (isinstance(occ_pred, dict) and 'pred_occ' in occ_pred) else occ_pred, # (Dx, Dy, Dz) - gt_semantics, # (Dx, Dy, Dz) - mask_lidar, # (Dx, Dy, Dz) - mask_camera # (Dx, Dy, Dz) - ) - - # if index % 100 == 0 and show_dir is not None: - # gt_vis = self.vis_occ(gt_semantics) - # pred_vis = self.vis_occ(occ_pred) - # mmcv.imwrite(np.concatenate([gt_vis, pred_vis], axis=1), - # os.path.join(show_dir + "%d.jpg"%index)) - - if show_dir is not None: - mmcv.mkdir_or_exist(show_dir) - # scene_name = info['scene_name'] - scene_name = [tem for tem in info['occ_path'].split('/') if 'scene-' in tem][0] - sample_token = info['token'] - mmcv.mkdir_or_exist(os.path.join(show_dir, scene_name, sample_token)) - save_path = os.path.join(show_dir, scene_name, sample_token, 'pred.npz') - np.savez_compressed(save_path, pred=occ_pred['pred_occ'] if (isinstance(occ_pred, dict) and 'pred_occ' in occ_pred) else occ_pred, gt=occ_gt, sample_token=sample_token) - - eval_results = self.occ_eval_metrics.count_miou() - - return eval_results - - - def vis_occ(self, semantics): - # simple visualization of result in BEV - semantics_valid = np.logical_not(semantics == 17) - d = np.arange(16).reshape(1, 1, 16) - d = np.repeat(d, 200, axis=0) - d = np.repeat(d, 200, axis=1).astype(np.float32) - d = d * semantics_valid - selected = np.argmax(d, axis=2) - - selected_torch = torch.from_numpy(selected) - semantics_torch = torch.from_numpy(semantics) - - occ_bev_torch = torch.gather(semantics_torch, dim=2, - index=selected_torch.unsqueeze(-1)) - occ_bev = occ_bev_torch.numpy() - - occ_bev = occ_bev.flatten().astype(np.int32) - occ_bev_vis = colors_map[occ_bev].astype(np.uint8) - occ_bev_vis = occ_bev_vis.reshape(200, 200, 4)[::-1, ::-1, :3] - occ_bev_vis = cv2.resize(occ_bev_vis,(400,400)) - return occ_bev_vis diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__init__.py deleted file mode 100644 index 38754965fb51170b2ae2051faf027e187d722c3a..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from .loading import PrepareImageInputs, LoadAnnotationsBEVDepth, PointToMultiViewDepth -from mmdet3d.datasets.pipelines import LoadPointsFromFile -from mmdet3d.datasets.pipelines import ObjectRangeFilter, ObjectNameFilter -from .formating import DefaultFormatBundle3D, Collect3D - -__all__ = ['PrepareImageInputs', 'LoadAnnotationsBEVDepth', 'ObjectRangeFilter', 'ObjectNameFilter', - 'PointToMultiViewDepth', 'DefaultFormatBundle3D', 'Collect3D'] - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index d36e3ac33c420e82345fac4245b30848db82bfcb..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/formating.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/formating.cpython-310.pyc deleted file mode 100644 index aca401e5af7d0985ea32559d8ad0b32e4400c264..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/formating.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/loading.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/loading.cpython-310.pyc deleted file mode 100644 index 27bb8ef02852d1e337083c9bf7509e376ef4975a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/__pycache__/loading.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/loading.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/loading.py deleted file mode 100644 index b4180a03ebb365c742e825c665ced2bc0fd476fd..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/datasets/pipelines/loading.py +++ /dev/null @@ -1,533 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import os - -import mmcv -import numpy as np -import torch -from PIL import Image -from pyquaternion import Quaternion - -from mmdet3d.core.points import BasePoints, get_points_type -from mmdet.datasets.pipelines import LoadAnnotations, LoadImageFromFile -from mmdet3d.core.bbox import LiDARInstance3DBoxes -from mmdet3d.datasets.builder import PIPELINES -from torchvision.transforms.functional import rotate - - -def mmlabNormalize(img): - from mmcv.image.photometric import imnormalize - mean = np.array([123.675, 116.28, 103.53], dtype=np.float32) - std = np.array([58.395, 57.12, 57.375], dtype=np.float32) - to_rgb = True - img = imnormalize(np.array(img), mean, std, to_rgb) - img = torch.tensor(img).float().permute(2, 0, 1).contiguous() - return img - - -@PIPELINES.register_module() -class PrepareImageInputs(object): - def __init__( - self, - data_config, - is_train=False, - sequential=False, - ): - self.is_train = is_train - self.data_config = data_config - self.normalize_img = mmlabNormalize - self.sequential = sequential - - def choose_cams(self): - """ - Returns: - cam_names: List[CAM_Name0, CAM_Name1, ...] - """ - if self.is_train and self.data_config['Ncams'] < len( - self.data_config['cams']): - cam_names = np.random.choice( - self.data_config['cams'], - self.data_config['Ncams'], - replace=False) - else: - cam_names = self.data_config['cams'] - return cam_names - - def sample_augmentation(self, H, W, flip=None, scale=None): - """ - Args: - H: - W: - flip: - scale: - Returns: - resize: resize比例float. - resize_dims: (resize_W, resize_H) - crop: (crop_w, crop_h, crop_w + fW, crop_h + fH) - flip: 0 / 1 - rotate: 随机旋转角度float - """ - fH, fW = self.data_config['input_size'] - if self.is_train: - resize = float(fW) / float(W) - resize += np.random.uniform(*self.data_config['resize']) # resize的比例, 位于[fW/W − 0.06, fW/W + 0.11]之间. - resize_dims = (int(W * resize), int(H * resize)) # resize后的size - newW, newH = resize_dims - crop_h = int((1 - np.random.uniform(*self.data_config['crop_h'])) * - newH) - fH # s * H - H_in - crop_w = int(np.random.uniform(0, max(0, newW - fW))) # max(0, s * W - fW) - crop = (crop_w, crop_h, crop_w + fW, crop_h + fH) - flip = self.data_config['flip'] and np.random.choice([0, 1]) - rotate = np.random.uniform(*self.data_config['rot']) - else: - resize = float(fW) / float(W) - if scale is not None: - resize += scale - else: - resize += self.data_config.get('resize_test', 0.0) - resize_dims = (int(W * resize), int(H * resize)) - newW, newH = resize_dims - crop_h = int((1 - np.mean(self.data_config['crop_h'])) * newH) - fH - crop_w = int(max(0, newW - fW) / 2) - crop = (crop_w, crop_h, crop_w + fW, crop_h + fH) - flip = False if flip is None else flip - rotate = 0 - return resize, resize_dims, crop, flip, rotate - - def img_transform_core(self, img, resize_dims, crop, flip, rotate): - # adjust image - img = img.resize(resize_dims) - img = img.crop(crop) - if flip: - img = img.transpose(method=Image.FLIP_LEFT_RIGHT) - img = img.rotate(rotate) - return img - - def get_rot(self, h): - return torch.Tensor([ - [np.cos(h), np.sin(h)], - [-np.sin(h), np.cos(h)], - ]) - - def img_transform(self, img, post_rot, post_tran, resize, resize_dims, - crop, flip, rotate): - """ - Args: - img: PIL.Image - post_rot: torch.eye(2) - post_tran: torch.eye(2) - resize: float, resize的比例. - resize_dims: Tuple(W, H), resize后的图像尺寸 - crop: (crop_w, crop_h, crop_w + fW, crop_h + fH) - flip: bool - rotate: float 旋转角度 - Returns: - img: PIL.Image - post_rot: Tensor (2, 2) - post_tran: Tensor (2, ) - """ - # adjust image - img = self.img_transform_core(img, resize_dims, crop, flip, rotate) - - # post-homography transformation - # 将上述变换以矩阵表示. - post_rot *= resize - post_tran -= torch.Tensor(crop[:2]) - if flip: - A = torch.Tensor([[-1, 0], [0, 1]]) - b = torch.Tensor([crop[2] - crop[0], 0]) - post_rot = A.matmul(post_rot) - post_tran = A.matmul(post_tran) + b - A = self.get_rot(rotate / 180 * np.pi) - b = torch.Tensor([crop[2] - crop[0], crop[3] - crop[1]]) / 2 - b = A.matmul(-b) + b - post_rot = A.matmul(post_rot) - post_tran = A.matmul(post_tran) + b - - return img, post_rot, post_tran - - def get_sensor_transforms(self, info, cam_name): - """ - Args: - info: - cam_name: 当前要读取的CAM. - Returns: - sensor2ego: (4, 4) - ego2global: (4, 4) - """ - w, x, y, z = info['cams'][cam_name]['sensor2ego_rotation'] # 四元数格式 - # sensor to ego - sensor2ego_rot = torch.Tensor( - Quaternion(w, x, y, z).rotation_matrix) # (3, 3) - sensor2ego_tran = torch.Tensor( - info['cams'][cam_name]['sensor2ego_translation']) # (3, ) - sensor2ego = sensor2ego_rot.new_zeros((4, 4)) - sensor2ego[3, 3] = 1 - sensor2ego[:3, :3] = sensor2ego_rot - sensor2ego[:3, -1] = sensor2ego_tran - - # ego to global - w, x, y, z = info['cams'][cam_name]['ego2global_rotation'] # 四元数格式 - ego2global_rot = torch.Tensor( - Quaternion(w, x, y, z).rotation_matrix) # (3, 3) - ego2global_tran = torch.Tensor( - info['cams'][cam_name]['ego2global_translation']) # (3, ) - ego2global = ego2global_rot.new_zeros((4, 4)) - ego2global[3, 3] = 1 - ego2global[:3, :3] = ego2global_rot - ego2global[:3, -1] = ego2global_tran - return sensor2ego, ego2global - - def get_inputs(self, results, flip=None, scale=None): - """ - Args: - results: - flip: - scale: - - Returns: - imgs: (N_views, 3, H, W) # N_views = 6 * (N_history + 1) - sensor2egos: (N_views, 4, 4) - ego2globals: (N_views, 4, 4) - intrins: (N_views, 3, 3) - post_rots: (N_views, 3, 3) - post_trans: (N_views, 3) - """ - imgs = [] - sensor2egos = [] - ego2globals = [] - intrins = [] - post_rots = [] - post_trans = [] - cam_names = self.choose_cams() - results['cam_names'] = cam_names - canvas = [] - - for cam_name in cam_names: - cam_data = results['curr']['cams'][cam_name] - filename = cam_data['data_path'] - img = Image.open(filename) - - # 初始化图像增广的旋转和平移矩阵 - post_rot = torch.eye(2) - post_tran = torch.zeros(2) - # 当前相机内参 - intrin = torch.Tensor(cam_data['cam_intrinsic']) - - # 获取当前相机的sensor2ego(4x4), ego2global(4x4)矩阵. - sensor2ego, ego2global = \ - self.get_sensor_transforms(results['curr'], cam_name) - - # image view augmentation (resize, crop, horizontal flip, rotate) - img_augs = self.sample_augmentation( - H=img.height, W=img.width, flip=flip, scale=scale) - resize, resize_dims, crop, flip, rotate = img_augs - - # img: PIL.Image; post_rot: Tensor (2, 2); post_tran: Tensor (2, ) - img, post_rot2, post_tran2 = \ - self.img_transform(img, post_rot, - post_tran, - resize=resize, - resize_dims=resize_dims, - crop=crop, - flip=flip, - rotate=rotate) - - # for convenience, make augmentation matrices 3x3 - # 以3x3矩阵表示图像的增广 - post_tran = torch.zeros(3) - post_rot = torch.eye(3) - post_tran[:2] = post_tran2 - post_rot[:2, :2] = post_rot2 - - canvas.append(np.array(img)) # 保存未归一化的图像,应该是为了做可视化. - imgs.append(self.normalize_img(img)) - - if self.sequential: - assert 'adjacent' in results - for adj_info in results['adjacent']: - filename_adj = adj_info['cams'][cam_name]['data_path'] - img_adjacent = Image.open(filename_adj) - # 对选择的邻近帧图像也进行增广, 增广参数与当前帧图像相同. - img_adjacent = self.img_transform_core( - img_adjacent, - resize_dims=resize_dims, - crop=crop, - flip=flip, - rotate=rotate) - imgs.append(self.normalize_img(img_adjacent)) - - intrins.append(intrin) # 相机内参 (3, 3) - sensor2egos.append(sensor2ego) # camera2ego变换 (4, 4) - ego2globals.append(ego2global) # ego2global变换 (4, 4) - post_rots.append(post_rot) # 图像增广旋转 (3, 3) - post_trans.append(post_tran) # 图像增广平移 (3, ) - - if self.sequential: - for adj_info in results['adjacent']: - # adjacent与current使用相同的图像增广, 相机内参也相同. - post_trans.extend(post_trans[:len(cam_names)]) - post_rots.extend(post_rots[:len(cam_names)]) - intrins.extend(intrins[:len(cam_names)]) - - for cam_name in cam_names: - # 获得adjacent帧对应的camera2ego变换 (4, 4)和ego2global变换 (4, 4). - sensor2ego, ego2global = \ - self.get_sensor_transforms(adj_info, cam_name) - sensor2egos.append(sensor2ego) - ego2globals.append(ego2global) - - imgs = torch.stack(imgs) # (N_views, 3, H, W) # N_views = 6 * (N_history + 1) - - sensor2egos = torch.stack(sensor2egos) # (N_views, 4, 4) - ego2globals = torch.stack(ego2globals) # (N_views, 4, 4) - intrins = torch.stack(intrins) # (N_views, 3, 3) - post_rots = torch.stack(post_rots) # (N_views, 3, 3) - post_trans = torch.stack(post_trans) # (N_views, 3) - results['canvas'] = canvas # List[(H, W, 3), (H, W, 3), ...] len = 6 - - return imgs, sensor2egos, ego2globals, intrins, post_rots, post_trans - - def __call__(self, results): - results['img_inputs'] = self.get_inputs(results) - return results - - -@PIPELINES.register_module() -class LoadAnnotationsBEVDepth(object): - def __init__(self, bda_aug_conf, classes, is_train=True): - self.bda_aug_conf = bda_aug_conf - self.is_train = is_train - self.classes = classes - - def sample_bda_augmentation(self): - """Generate bda augmentation values based on bda_config.""" - if self.is_train: - rotate_bda = np.random.uniform(*self.bda_aug_conf['rot_lim']) - scale_bda = np.random.uniform(*self.bda_aug_conf['scale_lim']) - flip_dx = np.random.uniform() < self.bda_aug_conf['flip_dx_ratio'] - flip_dy = np.random.uniform() < self.bda_aug_conf['flip_dy_ratio'] - else: - rotate_bda = 0 - scale_bda = 1.0 - flip_dx = False - flip_dy = False - return rotate_bda, scale_bda, flip_dx, flip_dy - - def bev_transform(self, gt_boxes, rotate_angle, scale_ratio, flip_dx, - flip_dy): - """ - Args: - gt_boxes: (N, 9) - rotate_angle: - scale_ratio: - flip_dx: bool - flip_dy: bool - - Returns: - gt_boxes: (N, 9) - rot_mat: (3, 3) - """ - rotate_angle = torch.tensor(rotate_angle / 180 * np.pi) - rot_sin = torch.sin(rotate_angle) - rot_cos = torch.cos(rotate_angle) - rot_mat = torch.Tensor([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], - [0, 0, 1]]) - scale_mat = torch.Tensor([[scale_ratio, 0, 0], [0, scale_ratio, 0], - [0, 0, scale_ratio]]) - flip_mat = torch.Tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) - if flip_dx: # 沿着y轴翻转 - flip_mat = flip_mat @ torch.Tensor([[-1, 0, 0], [0, 1, 0], - [0, 0, 1]]) - if flip_dy: # 沿着x轴翻转 - flip_mat = flip_mat @ torch.Tensor([[1, 0, 0], [0, -1, 0], - [0, 0, 1]]) - rot_mat = flip_mat @ (scale_mat @ rot_mat) # 变换矩阵(3, 3) - if gt_boxes.shape[0] > 0: - gt_boxes[:, :3] = ( - rot_mat @ gt_boxes[:, :3].unsqueeze(-1)).squeeze(-1) # 变换后的3D框中心坐标 - gt_boxes[:, 3:6] *= scale_ratio # 变换后的3D框尺寸 - gt_boxes[:, 6] += rotate_angle # 旋转后的3D框的方位角 - # 翻转也会进一步改变方位角 - if flip_dx: - gt_boxes[:, 6] = 2 * torch.asin(torch.tensor(1.0)) - gt_boxes[:, 6] - if flip_dy: - gt_boxes[:, 6] = -gt_boxes[:, 6] - gt_boxes[:, 7:] = ( - rot_mat[:2, :2] @ gt_boxes[:, 7:].unsqueeze(-1)).squeeze(-1) - return gt_boxes, rot_mat - - def __call__(self, results): - gt_boxes, gt_labels = results['ann_infos'] # (N_gt, 9), (N_gt, ) - gt_boxes, gt_labels = torch.Tensor(np.array(gt_boxes)), torch.tensor(np.array(gt_labels)) - rotate_bda, scale_bda, flip_dx, flip_dy = self.sample_bda_augmentation() - - bda_mat = torch.zeros(4, 4) - bda_mat[3, 3] = 1 - # gt_boxes: (N, 9) BEV增广变换后的3D框 - # bda_rot: (3, 3) BEV增广矩阵, 包括旋转、缩放和翻转. - gt_boxes, bda_rot = self.bev_transform(gt_boxes, rotate_bda, scale_bda, - flip_dx, flip_dy) - bda_mat[:3, :3] = bda_rot - - if len(gt_boxes) == 0: - gt_boxes = torch.zeros(0, 9) - results['gt_bboxes_3d'] = \ - LiDARInstance3DBoxes(gt_boxes, box_dim=gt_boxes.shape[-1], - origin=(0.5, 0.5, 0.5)) - results['gt_labels_3d'] = gt_labels - - imgs, sensor2egos, ego2globals, intrins = results['img_inputs'][:4] - post_rots, post_trans = results['img_inputs'][4:] - results['img_inputs'] = (imgs, sensor2egos, ego2globals, intrins, post_rots, - post_trans, bda_rot) - - results['flip_dx'] = flip_dx - results['flip_dy'] = flip_dy - results['rotate_bda'] = rotate_bda - results['scale_bda'] = scale_bda - - # if 'voxel_semantics' in results: - # if flip_dx: - # results['voxel_semantics'] = results['voxel_semantics'][::-1, ...].copy() - # results['mask_lidar'] = results['mask_lidar'][::-1, ...].copy() - # results['mask_camera'] = results['mask_camera'][::-1, ...].copy() - # if flip_dy: - # results['voxel_semantics'] = results['voxel_semantics'][:, ::-1, ...].copy() - # results['mask_lidar'] = results['mask_lidar'][:, ::-1, ...].copy() - # results['mask_camera'] = results['mask_camera'][:, ::-1, ...].copy() - - return results - - -@PIPELINES.register_module() -class PointToMultiViewDepth(object): - def __init__(self, grid_config, downsample=1): - self.downsample = downsample - self.grid_config = grid_config - - def points2depthmap(self, points, height, width): - """ - Args: - points: (N_points, 3): 3: (u, v, d) - height: int - width: int - - Returns: - depth_map:(H, W) - """ - height, width = height // self.downsample, width // self.downsample - depth_map = torch.zeros((height, width), dtype=torch.float32) - coor = torch.round(points[:, :2] / self.downsample) # (N_points, 2) 2: (u, v) - depth = points[:, 2] # (N_points, )哦 - kept1 = (coor[:, 0] >= 0) & (coor[:, 0] < width) & ( - coor[:, 1] >= 0) & (coor[:, 1] < height) & ( - depth < self.grid_config['depth'][1]) & ( - depth >= self.grid_config['depth'][0]) - # 获取有效投影点. - coor, depth = coor[kept1], depth[kept1] # (N, 2), (N, ) - ranks = coor[:, 0] + coor[:, 1] * width - sort = (ranks + depth / 100.).argsort() - coor, depth, ranks = coor[sort], depth[sort], ranks[sort] - kept2 = torch.ones(coor.shape[0], device=coor.device, dtype=torch.bool) - kept2[1:] = (ranks[1:] != ranks[:-1]) - coor, depth = coor[kept2], depth[kept2] - coor = coor.to(torch.long) - depth_map[coor[:, 1], coor[:, 0]] = depth - return depth_map - - def __call__(self, results): - points_lidar = results['points'] - imgs, sensor2egos, ego2globals, intrins = results['img_inputs'][:4] - post_rots, post_trans, bda = results['img_inputs'][4:] - depth_map_list = [] - for cid in range(len(results['cam_names'])): - cam_name = results['cam_names'][cid] # CAM_TYPE - # 猜测liadr和cam不是严格同步的,因此lidar_ego和cam_ego可能会不一致. - # 因此lidar-->cam的路径不采用: lidar --> ego --> cam - # 而是: lidar --> lidar_ego --> global --> cam_ego --> cam - lidar2lidarego = np.eye(4, dtype=np.float32) - lidar2lidarego[:3, :3] = Quaternion( - results['curr']['lidar2ego_rotation']).rotation_matrix - lidar2lidarego[:3, 3] = results['curr']['lidar2ego_translation'] - lidar2lidarego = torch.from_numpy(lidar2lidarego) - - lidarego2global = np.eye(4, dtype=np.float32) - lidarego2global[:3, :3] = Quaternion( - results['curr']['ego2global_rotation']).rotation_matrix - lidarego2global[:3, 3] = results['curr']['ego2global_translation'] - lidarego2global = torch.from_numpy(lidarego2global) - - cam2camego = np.eye(4, dtype=np.float32) - cam2camego[:3, :3] = Quaternion( - results['curr']['cams'][cam_name] - ['sensor2ego_rotation']).rotation_matrix - cam2camego[:3, 3] = results['curr']['cams'][cam_name][ - 'sensor2ego_translation'] - cam2camego = torch.from_numpy(cam2camego) - - camego2global = np.eye(4, dtype=np.float32) - camego2global[:3, :3] = Quaternion( - results['curr']['cams'][cam_name] - ['ego2global_rotation']).rotation_matrix - camego2global[:3, 3] = results['curr']['cams'][cam_name][ - 'ego2global_translation'] - camego2global = torch.from_numpy(camego2global) - - cam2img = np.eye(4, dtype=np.float32) - cam2img = torch.from_numpy(cam2img) - cam2img[:3, :3] = intrins[cid] - - # lidar --> lidar_ego --> global --> cam_ego --> cam - lidar2cam = torch.inverse(camego2global.matmul(cam2camego)).matmul( - lidarego2global.matmul(lidar2lidarego)) - lidar2img = cam2img.matmul(lidar2cam) - points_img = points_lidar.tensor[:, :3].matmul( - lidar2img[:3, :3].T) + lidar2img[:3, 3].unsqueeze(0) # (N_points, 3) 3: (ud, vd, d) - points_img = torch.cat( - [points_img[:, :2] / points_img[:, 2:3], points_img[:, 2:3]], - 1) # (N_points, 3): 3: (u, v, d) - - # 再考虑图像增广 - points_img = points_img.matmul( - post_rots[cid].T) + post_trans[cid:cid + 1, :] # (N_points, 3): 3: (u, v, d) - depth_map = self.points2depthmap(points_img, - imgs.shape[2], # H - imgs.shape[3] # W - ) - depth_map_list.append(depth_map) - depth_map = torch.stack(depth_map_list) - results['gt_depth'] = depth_map - return results - - -@PIPELINES.register_module() -class LoadOccGTFromFile(object): - def __call__(self, results): - occ_gt_path = results['occ_gt_path'] - occ_gt_path = os.path.join(occ_gt_path, "labels.npz") - - occ_labels = np.load(occ_gt_path) - semantics = occ_labels['semantics'] - mask_lidar = occ_labels['mask_lidar'] - mask_camera = occ_labels['mask_camera'] - - semantics = torch.from_numpy(semantics) - mask_lidar = torch.from_numpy(mask_lidar) - mask_camera = torch.from_numpy(mask_camera) - - if results.get('flip_dx', False): - semantics = torch.flip(semantics, [0]) - mask_lidar = torch.flip(mask_lidar, [0]) - mask_camera = torch.flip(mask_camera, [0]) - - if results.get('flip_dy', False): - semantics = torch.flip(semantics, [1]) - mask_lidar = torch.flip(mask_lidar, [1]) - mask_camera = torch.flip(mask_camera, [1]) - - results['voxel_semantics'] = semantics - results['mask_lidar'] = mask_lidar - results['mask_camera'] = mask_camera - - return results - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__init__.py deleted file mode 100644 index 51e4044f892a8b27678599400da075b2f21b038a..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .backbones import * -from .necks import * -from .dense_heads import * -from .detectors import * -from .losses import * \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 275cd19af7a89aba2777bf6ffaacc4f19b1cd501..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 0a1db6bed7e8264dc1064fdfa01840b62ca421f2..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/resnet.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/resnet.cpython-310.pyc deleted file mode 100644 index 602edbb7b4058550f09828f25bac5887c4113a5e..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/resnet.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/swin.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/swin.cpython-310.pyc deleted file mode 100644 index 3f1ab4949beac023af211315cce65a0ab9dd3f95..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/__pycache__/swin.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/resnet.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/resnet.py deleted file mode 100644 index 4f36d5c9a583ca1080790d9af74e99124c6dcb60..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/resnet.py +++ /dev/null @@ -1,189 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. - -import torch.utils.checkpoint as checkpoint -from torch import nn - -from mmcv.cnn.bricks.conv_module import ConvModule -from mmdet.models.backbones.resnet import BasicBlock, Bottleneck -from mmdet3d.models import BACKBONES - - -@BACKBONES.register_module() -class CustomResNet(nn.Module): - def __init__( - self, - numC_input, - num_layer=[2, 2, 2], - num_channels=None, - stride=[2, 2, 2], - backbone_output_ids=None, - norm_cfg=dict(type='BN'), - with_cp=False, - block_type='Basic', - ): - super(CustomResNet, self).__init__() - # build backbone - assert len(num_layer) == len(stride) - num_channels = [numC_input*2**(i+1) for i in range(len(num_layer))] \ - if num_channels is None else num_channels - self.backbone_output_ids = range(len(num_layer)) \ - if backbone_output_ids is None else backbone_output_ids - - layers = [] - if block_type == 'BottleNeck': - curr_numC = numC_input - for i in range(len(num_layer)): - # 在第一个block中对输入进行downsample - layer = [Bottleneck(inplanes=curr_numC, planes=num_channels[i]//4, stride=stride[i], - downsample=nn.Conv2d(curr_numC, num_channels[i], 3, stride[i], 1), - norm_cfg=norm_cfg)] - curr_numC = num_channels[i] - layer.extend([Bottleneck(inplanes=curr_numC, planes=num_channels[i]//4, stride=1, - downsample=None, norm_cfg=norm_cfg) for _ in range(num_layer[i] - 1)]) - layers.append(nn.Sequential(*layer)) - elif block_type == 'Basic': - curr_numC = numC_input - for i in range(len(num_layer)): - # 在第一个block中对输入进行downsample - layer = [BasicBlock(inplanes=curr_numC, planes=num_channels[i], stride=stride[i], - downsample=nn.Conv2d(curr_numC, num_channels[i], 3, stride[i], 1), - norm_cfg=norm_cfg)] - curr_numC = num_channels[i] - layer.extend([BasicBlock(inplanes=curr_numC, planes=num_channels[i], stride=1, - downsample=None, norm_cfg=norm_cfg) for _ in range(num_layer[i] - 1)]) - layers.append(nn.Sequential(*layer)) - else: - assert False - - self.layers = nn.Sequential(*layers) - self.with_cp = with_cp - - def forward(self, x): - """ - Args: - x: (B, C=64, Dy, Dx) - Returns: - feats: List[ - (B, 2*C, Dy/2, Dx/2), - (B, 4*C, Dy/4, Dx/4), - (B, 8*C, Dy/8, Dx/8), - ] - """ - feats = [] - x_tmp = x - for lid, layer in enumerate(self.layers): - if self.with_cp: - x_tmp = checkpoint.checkpoint(layer, x_tmp) - else: - x_tmp = layer(x_tmp) - if lid in self.backbone_output_ids: - feats.append(x_tmp) - return feats - - -class BasicBlock3D(nn.Module): - def __init__(self, - channels_in, channels_out, stride=1, downsample=None): - super(BasicBlock3D, self).__init__() - self.conv1 = ConvModule( - channels_in, - channels_out, - kernel_size=3, - stride=stride, - padding=1, - bias=False, - conv_cfg=dict(type='Conv3d'), - norm_cfg=dict(type='BN3d', ), - act_cfg=dict(type='ReLU',inplace=True)) - self.conv2 = ConvModule( - channels_out, - channels_out, - kernel_size=3, - stride=1, - padding=1, - bias=False, - conv_cfg=dict(type='Conv3d'), - norm_cfg=dict(type='BN3d', ), - act_cfg=None) - self.downsample = downsample - self.relu = nn.ReLU(inplace=True) - - def forward(self, x): - if self.downsample is not None: - identity = self.downsample(x) - else: - identity = x - x = self.conv1(x) - x = self.conv2(x) - x = x + identity - return self.relu(x) - - -@BACKBONES.register_module() -class CustomResNet3D(nn.Module): - def __init__( - self, - numC_input, - num_layer=[2, 2, 2], - num_channels=None, - stride=[2, 2, 2], - backbone_output_ids=None, - with_cp=False, - ): - super(CustomResNet3D, self).__init__() - # build backbone - assert len(num_layer) == len(stride) - num_channels = [numC_input * 2 ** (i + 1) for i in range(len(num_layer))] \ - if num_channels is None else num_channels - self.backbone_output_ids = range(len(num_layer)) \ - if backbone_output_ids is None else backbone_output_ids - layers = [] - curr_numC = numC_input - for i in range(len(num_layer)): - layer = [ - BasicBlock3D( - curr_numC, - num_channels[i], - stride=stride[i], - downsample=ConvModule( - curr_numC, - num_channels[i], - kernel_size=3, - stride=stride[i], - padding=1, - bias=False, - conv_cfg=dict(type='Conv3d'), - norm_cfg=dict(type='BN3d', ), - act_cfg=None)) - ] - curr_numC = num_channels[i] - layer.extend([ - BasicBlock3D(curr_numC, curr_numC) - for _ in range(num_layer[i] - 1) - ]) - layers.append(nn.Sequential(*layer)) - self.layers = nn.Sequential(*layers) - - self.with_cp = with_cp - - def forward(self, x): - """ - Args: - x: (B, C, Dz, Dy, Dx) - Returns: - feats: List[ - (B, C, Dz, Dy, Dx), - (B, 2C, Dz/2, Dy/2, Dx/2), - (B, 4C, Dz/4, Dy/4, Dx/4), - ] - """ - feats = [] - x_tmp = x - for lid, layer in enumerate(self.layers): - if self.with_cp: - x_tmp = checkpoint.checkpoint(layer, x_tmp) - else: - x_tmp = layer(x_tmp) - if lid in self.backbone_output_ids: - feats.append(x_tmp) - return feats \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/swin.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/swin.py deleted file mode 100644 index 2e96ce03d725dcac04f3d94be599217a89ae6ab6..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/backbones/swin.py +++ /dev/null @@ -1,977 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import warnings -from copy import deepcopy - -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import build_norm_layer, trunc_normal_init, build_conv_layer -from mmcv.cnn.bricks.transformer import FFN, build_dropout -from mmcv.cnn.utils.weight_init import constant_init -from mmcv.runner import _load_checkpoint -from mmcv.runner.base_module import BaseModule, ModuleList -from torch.nn.modules.linear import Linear -from torch.nn.modules.normalization import LayerNorm -import torch.utils.checkpoint as checkpoint - -from mmseg.ops import resize -from mmdet3d.utils import get_root_logger -from mmdet3d.models.builder import BACKBONES -from mmcv.cnn.bricks.registry import ATTENTION -from torch.nn.modules.utils import _pair as to_2tuple -from collections import OrderedDict - - -def swin_convert(ckpt): - new_ckpt = OrderedDict() - - def correct_unfold_reduction_order(x): - out_channel, in_channel = x.shape - x = x.reshape(out_channel, 4, in_channel // 4) - x = x[:, [0, 2, 1, 3], :].transpose(1, - 2).reshape(out_channel, in_channel) - return x - - def correct_unfold_norm_order(x): - in_channel = x.shape[0] - x = x.reshape(4, in_channel // 4) - x = x[[0, 2, 1, 3], :].transpose(0, 1).reshape(in_channel) - return x - - for k, v in ckpt.items(): - if k.startswith('head'): - continue - elif k.startswith('layers'): - new_v = v - if 'attn.' in k: - new_k = k.replace('attn.', 'attn.w_msa.') - elif 'mlp.' in k: - if 'mlp.fc1.' in k: - new_k = k.replace('mlp.fc1.', 'ffn.layers.0.0.') - elif 'mlp.fc2.' in k: - new_k = k.replace('mlp.fc2.', 'ffn.layers.1.') - else: - new_k = k.replace('mlp.', 'ffn.') - elif 'downsample' in k: - new_k = k - if 'reduction.' in k: - new_v = correct_unfold_reduction_order(v) - elif 'norm.' in k: - new_v = correct_unfold_norm_order(v) - else: - new_k = k - new_k = new_k.replace('layers', 'stages', 1) - elif k.startswith('patch_embed'): - new_v = v - if 'proj' in k: - new_k = k.replace('proj', 'projection') - else: - new_k = k - else: - new_v = v - new_k = k - - new_ckpt[new_k] = new_v - - return new_ckpt - -# Modified from Pytorch-Image-Models -class PatchEmbed(BaseModule): - """Image to Patch Embedding V2. - - We use a conv layer to implement PatchEmbed. - Args: - in_channels (int): The num of input channels. Default: 3 - embed_dims (int): The dimensions of embedding. Default: 768 - conv_type (dict, optional): The config dict for conv layers type - selection. Default: None. - kernel_size (int): The kernel_size of embedding conv. Default: 16. - stride (int): The slide stride of embedding conv. - Default: None (Default to be equal with kernel_size). - padding (int): The padding length of embedding conv. Default: 0. - dilation (int): The dilation rate of embedding conv. Default: 1. - pad_to_patch_size (bool, optional): Whether to pad feature map shape - to multiple patch size. Default: True. - norm_cfg (dict, optional): Config dict for normalization layer. - init_cfg (`mmcv.ConfigDict`, optional): The Config for initialization. - Default: None. - """ - - def __init__(self, - in_channels=3, - embed_dims=768, - conv_type=None, - kernel_size=16, - stride=16, - padding=0, - dilation=1, - pad_to_patch_size=True, - norm_cfg=None, - init_cfg=None): - super(PatchEmbed, self).__init__() - - self.embed_dims = embed_dims - self.init_cfg = init_cfg - - if stride is None: - stride = kernel_size - - self.pad_to_patch_size = pad_to_patch_size - - # The default setting of patch size is equal to kernel size. - patch_size = kernel_size - if isinstance(patch_size, int): - patch_size = to_2tuple(patch_size) - elif isinstance(patch_size, tuple): - if len(patch_size) == 1: - patch_size = to_2tuple(patch_size[0]) - assert len(patch_size) == 2, \ - f'The size of patch should have length 1 or 2, ' \ - f'but got {len(patch_size)}' - - self.patch_size = patch_size - - # Use conv layer to embed - conv_type = conv_type or 'Conv2d' - self.projection = build_conv_layer( - dict(type=conv_type), - in_channels=in_channels, - out_channels=embed_dims, - kernel_size=kernel_size, - stride=stride, - padding=padding, - dilation=dilation) - - if norm_cfg is not None: - self.norm = build_norm_layer(norm_cfg, embed_dims)[1] - else: - self.norm = None - - def forward(self, x): - H, W = x.shape[2], x.shape[3] - - # TODO: Process overlapping op - if self.pad_to_patch_size: - # Modify H, W to multiple of patch size. - if H % self.patch_size[0] != 0: - x = F.pad( - x, (0, 0, 0, self.patch_size[0] - H % self.patch_size[0])) - if W % self.patch_size[1] != 0: - x = F.pad( - x, (0, self.patch_size[1] - W % self.patch_size[1], 0, 0)) - - x = self.projection(x) - self.DH, self.DW = x.shape[2], x.shape[3] - x = x.flatten(2).transpose(1, 2) - - if self.norm is not None: - x = self.norm(x) - - return x - - - -class PatchMerging(BaseModule): - """Merge patch feature map. - - This layer use nn.Unfold to group feature map by kernel_size, and use norm - and linear layer to embed grouped feature map. - Args: - in_channels (int): The num of input channels. - out_channels (int): The num of output channels. - stride (int | tuple): the stride of the sliding length in the - unfold layer. Defaults: 2. (Default to be equal with kernel_size). - bias (bool, optional): Whether to add bias in linear layer or not. - Defaults: False. - norm_cfg (dict, optional): Config dict for normalization layer. - Defaults: dict(type='LN'). - init_cfg (dict, optional): The extra config for initialization. - Defaults: None. - """ - - def __init__(self, - in_channels, - out_channels, - stride=2, - bias=False, - norm_cfg=dict(type='LN'), - init_cfg=None): - super().__init__(init_cfg) - self.in_channels = in_channels - self.out_channels = out_channels - self.stride = stride - - self.sampler = nn.Unfold( - kernel_size=stride, dilation=1, padding=0, stride=stride) - - sample_dim = stride**2 * in_channels - - if norm_cfg is not None: - self.norm = build_norm_layer(norm_cfg, sample_dim)[1] - else: - self.norm = None - - self.reduction = nn.Linear(sample_dim, out_channels, bias=bias) - - def forward(self, x, hw_shape): - """ - x: x.shape -> [B, H*W, C] - hw_shape: (H, W) - """ - B, L, C = x.shape - H, W = hw_shape - assert L == H * W, 'input feature has wrong size' - - x = x.view(B, H, W, C).permute([0, 3, 1, 2]) # B, C, H, W - - # stride is fixed to be equal to kernel_size. - if (H % self.stride != 0) or (W % self.stride != 0): - x = F.pad(x, (0, W % self.stride, 0, H % self.stride)) - - # Use nn.Unfold to merge patch. About 25% faster than original method, - # but need to modify pretrained model for compatibility - x = self.sampler(x) # B, 4*C, H/2*W/2 - x = x.transpose(1, 2) # B, H/2*W/2, 4*C - - x = self.norm(x) if self.norm else x - x = self.reduction(x) - - down_hw_shape = (H + 1) // 2, (W + 1) // 2 - return x, down_hw_shape - - -@ATTENTION.register_module() -class WindowMSA(BaseModule): - """Window based multi-head self-attention (W-MSA) module with relative - position bias. - - Args: - embed_dims (int): Number of input channels. - window_size (tuple[int]): The height and width of the window. - num_heads (int): Number of attention heads. - qkv_bias (bool, optional): If True, add a learnable bias to q, k, v. - Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - attn_drop_rate (float, optional): Dropout ratio of attention weight. - Default: 0.0 - proj_drop_rate (float, optional): Dropout ratio of output. Default: 0.0 - init_cfg (dict | None, optional): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - window_size, - qkv_bias=True, - qk_scale=None, - attn_drop_rate=0., - proj_drop_rate=0., - init_cfg=None): - - super().__init__() - self.embed_dims = embed_dims - self.window_size = window_size # Wh, Ww - self.num_heads = num_heads - head_embed_dims = embed_dims // num_heads - self.scale = qk_scale or head_embed_dims**-0.5 - self.init_cfg = init_cfg - - # define a parameter table of relative position bias - self.relative_position_bias_table = nn.Parameter( - torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), - num_heads)) # 2*Wh-1 * 2*Ww-1, nH - - # About 2x faster than original impl - Wh, Ww = self.window_size - rel_index_coords = self.double_step_seq(2 * Ww - 1, Wh, 1, Ww) - rel_position_index = rel_index_coords + rel_index_coords.T - rel_position_index = rel_position_index.flip(1).contiguous() - self.register_buffer('relative_position_index', rel_position_index) - - self.qkv = nn.Linear(embed_dims, embed_dims * 3, bias=qkv_bias) - self.attn_drop = nn.Dropout(attn_drop_rate) - self.proj = nn.Linear(embed_dims, embed_dims) - self.proj_drop = nn.Dropout(proj_drop_rate) - - self.softmax = nn.Softmax(dim=-1) - - def init_weights(self): - trunc_normal_init(self.relative_position_bias_table, std=0.02) - - def forward(self, x, mask=None): - """ - Args: - - x (tensor): input features with shape of (num_windows*B, N, C) - mask (tensor | None, Optional): mask with shape of (num_windows, - Wh*Ww, Wh*Ww), value should be between (-inf, 0]. - """ - B, N, C = x.shape - qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, - C // self.num_heads).permute(2, 0, 3, 1, 4) - q, k, v = qkv[0], qkv[1], qkv[ - 2] # make torchscript happy (cannot use tensor as tuple) - - q = q * self.scale - attn = (q @ k.transpose(-2, -1)) - - relative_position_bias = self.relative_position_bias_table[ - self.relative_position_index.view(-1)].view( - self.window_size[0] * self.window_size[1], - self.window_size[0] * self.window_size[1], - -1) # Wh*Ww,Wh*Ww,nH - relative_position_bias = relative_position_bias.permute( - 2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww - attn = attn + relative_position_bias.unsqueeze(0) - - if mask is not None: - nW = mask.shape[0] - attn = attn.view(B // nW, nW, self.num_heads, N, - N) + mask.unsqueeze(1).unsqueeze(0) - attn = attn.view(-1, self.num_heads, N, N) - attn = self.softmax(attn) - else: - attn = self.softmax(attn) - - attn = self.attn_drop(attn) - - x = (attn @ v).transpose(1, 2).reshape(B, N, C) - x = self.proj(x) - x = self.proj_drop(x) - return x - - @staticmethod - def double_step_seq(step1, len1, step2, len2): - seq1 = torch.arange(0, step1 * len1, step1) - seq2 = torch.arange(0, step2 * len2, step2) - return (seq1[:, None] + seq2[None, :]).reshape(1, -1) - - -@ATTENTION.register_module() -class ShiftWindowMSA(BaseModule): - """Shift Window Multihead Self-Attention Module. - - Args: - embed_dims (int): Number of input channels. - num_heads (int): Number of attention heads. - window_size (int): The height and width of the window. - shift_size (int, optional): The shift step of each window towards - right-bottom. If zero, act as regular window-msa. Defaults to 0. - qkv_bias (bool, optional): If True, add a learnable bias to q, k, v. - Default: True - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Defaults: None. - attn_drop_rate (float, optional): Dropout ratio of attention weight. - Defaults: 0. - proj_drop_rate (float, optional): Dropout ratio of output. - Defaults: 0. - dropout_layer (dict, optional): The dropout_layer used before output. - Defaults: dict(type='DropPath', drop_prob=0.). - init_cfg (dict, optional): The extra config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - window_size, - shift_size=0, - qkv_bias=True, - qk_scale=None, - attn_drop_rate=0, - proj_drop_rate=0, - dropout_layer=dict(type='DropPath', drop_prob=0.), - init_cfg=None): - super().__init__(init_cfg) - - self.window_size = window_size - self.shift_size = shift_size - assert 0 <= self.shift_size < self.window_size - - self.w_msa = WindowMSA( - embed_dims=embed_dims, - num_heads=num_heads, - window_size=to_2tuple(window_size), - qkv_bias=qkv_bias, - qk_scale=qk_scale, - attn_drop_rate=attn_drop_rate, - proj_drop_rate=proj_drop_rate, - init_cfg=None) - - self.drop = build_dropout(dropout_layer) - - def forward(self, query, hw_shape): - B, L, C = query.shape - H, W = hw_shape - assert L == H * W, 'input feature has wrong size' - query = query.view(B, H, W, C) - - # pad feature maps to multiples of window size - pad_r = (self.window_size - W % self.window_size) % self.window_size - pad_b = (self.window_size - H % self.window_size) % self.window_size - query = F.pad(query, (0, 0, 0, pad_r, 0, pad_b)) - H_pad, W_pad = query.shape[1], query.shape[2] - - # cyclic shift - if self.shift_size > 0: - shifted_query = torch.roll( - query, - shifts=(-self.shift_size, -self.shift_size), - dims=(1, 2)) - - # calculate attention mask for SW-MSA - img_mask = torch.zeros((1, H_pad, W_pad, 1), - device=query.device) # 1 H W 1 - h_slices = (slice(0, -self.window_size), - slice(-self.window_size, - -self.shift_size), slice(-self.shift_size, None)) - w_slices = (slice(0, -self.window_size), - slice(-self.window_size, - -self.shift_size), slice(-self.shift_size, None)) - cnt = 0 - for h in h_slices: - for w in w_slices: - img_mask[:, h, w, :] = cnt - cnt += 1 - - # nW, window_size, window_size, 1 - mask_windows = self.window_partition(img_mask) - mask_windows = mask_windows.view( - -1, self.window_size * self.window_size) - attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2) - attn_mask = attn_mask.masked_fill(attn_mask != 0, - float(-100.0)).masked_fill( - attn_mask == 0, float(0.0)) - else: - shifted_query = query - attn_mask = None - - # nW*B, window_size, window_size, C - query_windows = self.window_partition(shifted_query) - # nW*B, window_size*window_size, C - query_windows = query_windows.view(-1, self.window_size**2, C) - - # W-MSA/SW-MSA (nW*B, window_size*window_size, C) - attn_windows = self.w_msa(query_windows, mask=attn_mask) - - # merge windows - attn_windows = attn_windows.view(-1, self.window_size, - self.window_size, C) - - # B H' W' C - shifted_x = self.window_reverse(attn_windows, H_pad, W_pad) - # reverse cyclic shift - if self.shift_size > 0: - x = torch.roll( - shifted_x, - shifts=(self.shift_size, self.shift_size), - dims=(1, 2)) - else: - x = shifted_x - - if pad_r > 0 or pad_b: - x = x[:, :H, :W, :].contiguous() - - x = x.view(B, H * W, C) - - x = self.drop(x) - return x - - def window_reverse(self, windows, H, W): - """ - Args: - windows: (num_windows*B, window_size, window_size, C) - window_size (int): Window size - H (int): Height of image - W (int): Width of image - Returns: - x: (B, H, W, C) - """ - window_size = self.window_size - B = int(windows.shape[0] / (H * W / window_size / window_size)) - x = windows.view(B, H // window_size, W // window_size, window_size, - window_size, -1) - x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1) - return x - - def window_partition(self, x): - """ - Args: - x: (B, H, W, C) - window_size (int): window size - Returns: - windows: (num_windows*B, window_size, window_size, C) - """ - B, H, W, C = x.shape - window_size = self.window_size - x = x.view(B, H // window_size, window_size, W // window_size, - window_size, C) - windows = x.permute(0, 1, 3, 2, 4, 5).contiguous() - windows = windows.view(-1, window_size, window_size, C) - return windows - - -class SwinBlock(BaseModule): - """" - Args: - embed_dims (int): The feature dimension. - num_heads (int): Parallel attention heads. - feedforward_channels (int): The hidden dimension for FFNs. - window size (int, optional): The local window scale. Default: 7. - shift (bool): whether to shift window or not. Default False. - qkv_bias (int, optional): enable bias for qkv if True. Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - drop_rate (float, optional): Dropout rate. Default: 0. - attn_drop_rate (float, optional): Attention dropout rate. Default: 0. - drop_path_rate (float, optional): Stochastic depth rate. Default: 0.2. - act_cfg (dict, optional): The config dict of activation function. - Default: dict(type='GELU'). - norm_cfg (dict, optional): The config dict of nomalization. - Default: dict(type='LN'). - init_cfg (dict | list | None, optional): The init config. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - feedforward_channels, - window_size=7, - shift=False, - qkv_bias=True, - qk_scale=None, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0., - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - init_cfg=None): - - super(SwinBlock, self).__init__() - - self.init_cfg = init_cfg - - self.norm1 = build_norm_layer(norm_cfg, embed_dims)[1] - self.attn = ShiftWindowMSA( - embed_dims=embed_dims, - num_heads=num_heads, - window_size=window_size, - shift_size=window_size // 2 if shift else 0, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - attn_drop_rate=attn_drop_rate, - proj_drop_rate=drop_rate, - dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate), - init_cfg=None) - - self.norm2 = build_norm_layer(norm_cfg, embed_dims)[1] - self.ffn = FFN( - embed_dims=embed_dims, - feedforward_channels=feedforward_channels, - num_fcs=2, - ffn_drop=drop_rate, - dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate), - act_cfg=act_cfg, - add_identity=True, - init_cfg=None) - - def forward(self, x, hw_shape): - identity = x - x = self.norm1(x) - x = self.attn(x, hw_shape) - - x = x + identity - - identity = x - x = self.norm2(x) - x = self.ffn(x, identity=identity) - - return x - - -class SwinBlockSequence(BaseModule): - """Implements one stage in Swin Transformer. - - Args: - embed_dims (int): The feature dimension. - num_heads (int): Parallel attention heads. - feedforward_channels (int): The hidden dimension for FFNs. - depth (int): The number of blocks in this stage. - window size (int): The local window scale. Default: 7. - qkv_bias (int): enable bias for qkv if True. Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - drop_rate (float, optional): Dropout rate. Default: 0. - attn_drop_rate (float, optional): Attention dropout rate. Default: 0. - drop_path_rate (float, optional): Stochastic depth rate. Default: 0.2. - downsample (BaseModule | None, optional): The downsample operation - module. Default: None. - act_cfg (dict, optional): The config dict of activation function. - Default: dict(type='GELU'). - norm_cfg (dict, optional): The config dict of nomalization. - Default: dict(type='LN'). - init_cfg (dict | list | None, optional): The init config. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - feedforward_channels, - depth, - window_size=7, - qkv_bias=True, - qk_scale=None, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0., - downsample=None, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - init_cfg=None, - with_cp=True): - super().__init__() - - self.init_cfg = init_cfg - - drop_path_rate = drop_path_rate if isinstance( - drop_path_rate, - list) else [deepcopy(drop_path_rate) for _ in range(depth)] - - self.blocks = ModuleList() - for i in range(depth): - block = SwinBlock( - embed_dims=embed_dims, - num_heads=num_heads, - feedforward_channels=feedforward_channels, - window_size=window_size, - shift=False if i % 2 == 0 else True, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - drop_rate=drop_rate, - attn_drop_rate=attn_drop_rate, - drop_path_rate=drop_path_rate[i], - act_cfg=act_cfg, - norm_cfg=norm_cfg, - init_cfg=None) - self.blocks.append(block) - - self.downsample = downsample - self.with_cp = with_cp - - def forward(self, x, hw_shape): - for block in self.blocks: - if self.with_cp: - x = checkpoint.checkpoint(block, x, hw_shape) - else: - x = block(x, hw_shape) - - if self.downsample: - x_down, down_hw_shape = self.downsample(x, hw_shape) - return x_down, down_hw_shape, x, hw_shape - else: - return x, hw_shape, x, hw_shape - - -@BACKBONES.register_module() -class SwinTransformer(BaseModule): - """ Swin Transformer - A PyTorch implement of : `Swin Transformer: - Hierarchical Vision Transformer using Shifted Windows` - - https://arxiv.org/abs/2103.14030 - - Inspiration from - https://github.com/microsoft/Swin-Transformer - - Args: - pretrain_img_size (int | tuple[int]): The size of input image when - pretrain. Defaults: 224. - in_channels (int): The num of input channels. - Defaults: 3. - embed_dims (int): The feature dimension. Default: 96. - patch_size (int | tuple[int]): Patch size. Default: 4. - window_size (int): Window size. Default: 7. - mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. - Default: 4. - depths (tuple[int]): Depths of each Swin Transformer stage. - Default: (2, 2, 6, 2). - num_heads (tuple[int]): Parallel attention heads of each Swin - Transformer stage. Default: (3, 6, 12, 24). - strides (tuple[int]): The patch merging or patch embedding stride of - each Swin Transformer stage. (In swin, we set kernel size equal to - stride.) Default: (4, 2, 2, 2). - out_indices (tuple[int]): Output from which stages. - Default: (0, 1, 2, 3). - qkv_bias (bool, optional): If True, add a learnable bias to query, key, - value. Default: True - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - patch_norm (bool): If add a norm layer for patch embed and patch - merging. Default: True. - drop_rate (float): Dropout rate. Defaults: 0. - attn_drop_rate (float): Attention dropout rate. Default: 0. - drop_path_rate (float): Stochastic depth rate. Defaults: 0.1. - use_abs_pos_embed (bool): If True, add absolute position embedding to - the patch embedding. Defaults: False. - act_cfg (dict): Config dict for activation layer. - Default: dict(type='LN'). - norm_cfg (dict): Config dict for normalization layer at - output of backone. Defaults: dict(type='LN'). - pretrain_style (str): Choose to use official or mmcls pretrain weights. - Default: official. - pretrained (str, optional): model pretrained path. Default: None. - init_cfg (dict, optional): The Config for initialization. - Defaults to None. - """ - - def __init__(self, - pretrain_img_size=224, - in_channels=3, - embed_dims=96, - patch_size=4, - window_size=7, - mlp_ratio=4, - depths=(2, 2, 6, 2), - num_heads=(3, 6, 12, 24), - strides=(4, 2, 2, 2), - out_indices=(0, 1, 2, 3), - qkv_bias=True, - qk_scale=None, - patch_norm=True, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0.1, - use_abs_pos_embed=False, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - pretrain_style='official', - pretrained=None, - init_cfg=None, - with_cp=True, - return_stereo_feat=False, - output_missing_index_as_none=False, - frozen_stages=-1): - super(SwinTransformer, self).__init__() - - if isinstance(pretrain_img_size, int): - pretrain_img_size = to_2tuple(pretrain_img_size) - elif isinstance(pretrain_img_size, tuple): - if len(pretrain_img_size) == 1: - pretrain_img_size = to_2tuple(pretrain_img_size[0]) - assert len(pretrain_img_size) == 2, \ - f'The size of image should have length 1 or 2, ' \ - f'but got {len(pretrain_img_size)}' - - assert pretrain_style in ['official', 'mmcls'], 'We only support load ' - 'official ckpt and mmcls ckpt.' - - if isinstance(pretrained, str) or pretrained is None: - warnings.warn('DeprecationWarning: pretrained is a deprecated, ' - 'please use "init_cfg" instead') - else: - raise TypeError('pretrained must be a str or None') - - num_layers = len(depths) - self.out_indices = out_indices - self.use_abs_pos_embed = use_abs_pos_embed - self.pretrain_style = pretrain_style - self.pretrained = pretrained - self.init_cfg = init_cfg - - self.frozen_stages = frozen_stages - - assert strides[0] == patch_size, 'Use non-overlapping patch embed.' - - self.patch_embed = PatchEmbed( - in_channels=in_channels, - embed_dims=embed_dims, - conv_type='Conv2d', - kernel_size=patch_size, - stride=strides[0], - pad_to_patch_size=True, - norm_cfg=norm_cfg if patch_norm else None, - init_cfg=None) - - if self.use_abs_pos_embed: - patch_row = pretrain_img_size[0] // patch_size - patch_col = pretrain_img_size[1] // patch_size - num_patches = patch_row * patch_col - self.absolute_pos_embed = nn.Parameter( - torch.zeros((1, num_patches, embed_dims))) - - self.drop_after_pos = nn.Dropout(p=drop_rate) - - # stochastic depth - total_depth = sum(depths) - dpr = [ - x.item() for x in torch.linspace(0, drop_path_rate, total_depth) - ] # stochastic depth decay rule - - self.stages = ModuleList() - in_channels = embed_dims - for i in range(num_layers): - if i < num_layers - 1: - downsample = PatchMerging( - in_channels=in_channels, - out_channels=2 * in_channels, - stride=strides[i + 1], - norm_cfg=norm_cfg if patch_norm else None, - init_cfg=None) - else: - downsample = None - - stage = SwinBlockSequence( - embed_dims=in_channels, - num_heads=num_heads[i], - feedforward_channels=mlp_ratio * in_channels, - depth=depths[i], - window_size=window_size, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - drop_rate=drop_rate, - attn_drop_rate=attn_drop_rate, - drop_path_rate=dpr[:depths[i]], - downsample=downsample, - act_cfg=act_cfg, - norm_cfg=norm_cfg, - init_cfg=None, - with_cp=with_cp) - self.stages.append(stage) - - dpr = dpr[depths[i]:] - if downsample: - in_channels = downsample.out_channels - - self.num_features = [int(embed_dims * 2**i) for i in range(num_layers)] - # Add a norm layer for each output - for i in out_indices: - layer = build_norm_layer(norm_cfg, self.num_features[i])[1] - layer_name = f'norm{i}' - self.add_module(layer_name, layer) - self.output_missing_index_as_none = output_missing_index_as_none - - self._freeze_stages() - self.return_stereo_feat = return_stereo_feat - - def _freeze_stages(self): - if self.frozen_stages >= 0: - self.patch_embed.eval() - for param in self.patch_embed.parameters(): - param.requires_grad = False - - if self.frozen_stages >= 1 and self.use_abs_pos_embed: - self.absolute_pos_embed.requires_grad = False - - if self.frozen_stages >= 2: - self.drop_after_pos.eval() - for i in range(0, self.frozen_stages - 1): - m = self.stages[i] - m.eval() - for param in m.parameters(): - param.requires_grad = False - - def init_weights(self): - if self.pretrained is None: - super().init_weights() - if self.use_abs_pos_embed: - trunc_normal_init(self.absolute_pos_embed, std=0.02) - for m in self.modules(): - if isinstance(m, Linear): - trunc_normal_init(m.weight, std=.02) - if m.bias is not None: - constant_init(m.bias, 0) - elif isinstance(m, LayerNorm): - constant_init(m.bias, 0) - constant_init(m.weight, 1.0) - elif isinstance(self.pretrained, str): - logger = get_root_logger() - ckpt = _load_checkpoint( - self.pretrained, logger=logger, map_location='cpu') - if 'state_dict' in ckpt: - state_dict = ckpt['state_dict'] - elif 'model' in ckpt: - state_dict = ckpt['model'] - else: - state_dict = ckpt - - if self.pretrain_style == 'official': - state_dict = swin_convert(state_dict) - - # strip prefix of state_dict - if list(state_dict.keys())[0].startswith('module.'): - state_dict = {k[7:]: v for k, v in state_dict.items()} - # if list(state_dict.keys())[0].startswith('backbone.'): - # state_dict = {k[9:]: v for k, v in state_dict.items()} - # reshape absolute position embedding - if state_dict.get('absolute_pos_embed') is not None: - absolute_pos_embed = state_dict['absolute_pos_embed'] - N1, L, C1 = absolute_pos_embed.size() - N2, C2, H, W = self.absolute_pos_embed.size() - if N1 != N2 or C1 != C2 or L != H * W: - logger.warning('Error in loading absolute_pos_embed, pass') - else: - state_dict['absolute_pos_embed'] = absolute_pos_embed.view( - N2, H, W, C2).permute(0, 3, 1, 2).contiguous() - - # interpolate position bias table if needed - relative_position_bias_table_keys = [ - k for k in state_dict.keys() - if 'relative_position_bias_table' in k - ] - for table_key in relative_position_bias_table_keys: - table_pretrained = state_dict[table_key] - table_current = self.state_dict()[table_key] - L1, nH1 = table_pretrained.size() - L2, nH2 = table_current.size() - if nH1 != nH2: - logger.warning(f'Error in loading {table_key}, pass') - else: - if L1 != L2: - S1 = int(L1**0.5) - S2 = int(L2**0.5) - table_pretrained_resized = resize( - table_pretrained.permute(1, 0).reshape( - 1, nH1, S1, S1), - size=(S2, S2), - mode='bicubic') - state_dict[table_key] = table_pretrained_resized.view( - nH2, L2).permute(1, 0).contiguous() - - # load state_dict - self.load_state_dict(state_dict, False) - - def forward(self, x): - x = self.patch_embed(x) - - hw_shape = (self.patch_embed.DH, self.patch_embed.DW) - if self.use_abs_pos_embed: - x = x + self.absolute_pos_embed - x = self.drop_after_pos(x) - - outs = [] - for i, stage in enumerate(self.stages): - x, hw_shape, out, out_hw_shape = stage(x, hw_shape) - if i == 0 and self.return_stereo_feat: - out = out.view(-1, *out_hw_shape, - self.num_features[i]).permute(0, 3, 1, - 2).contiguous() - outs.append(out) - if i in self.out_indices: - norm_layer = getattr(self, f'norm{i}') - out = norm_layer(out) - out = out.view(-1, *out_hw_shape, - self.num_features[i]).permute(0, 3, 1, - 2).contiguous() - outs.append(out) - elif self.output_missing_index_as_none: - outs.append(None) - return outs - - def train(self, mode=True): - """Convert the model into training mode while keep normalization layer - freezed.""" - super(SwinTransformer, self).train(mode) - self._freeze_stages() \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__init__.py deleted file mode 100644 index 69a8bf1544cb96fc509caa8a2219d7c5297df452..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .bev_centerpoint_head import BEV_CenterHead, Centerness_Head -from .bev_occ_head import BEVOCCHead2D, BEVOCCHead3D, BEVOCCHead2D_V2 - -__all__ = ['Centerness_Head', 'BEV_CenterHead', 'BEVOCCHead2D', 'BEVOCCHead3D', 'BEVOCCHead2D_V2'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 26351e8150fdfce81c4887b080a3b1e0f5d2b174..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_centerpoint_head.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_centerpoint_head.cpython-310.pyc deleted file mode 100644 index 5673c73aacb3b6797eb92c75dd849f0141d2b013..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_centerpoint_head.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_occ_head.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_occ_head.cpython-310.pyc deleted file mode 100644 index d9b9e49738633565fa95ebc138fdafadc04e8eb5..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/__pycache__/bev_occ_head.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_centerpoint_head.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_centerpoint_head.py deleted file mode 100644 index 9136fac56d6acdb0498ee259555e255f0e3c6002..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_centerpoint_head.py +++ /dev/null @@ -1,1764 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import copy - -import torch -from mmcv.cnn import ConvModule, build_conv_layer -from mmcv.runner import BaseModule -from torch import nn - -from mmdet3d.core import (circle_nms, draw_heatmap_gaussian, gaussian_radius, - xywhr2xyxyr) -from ...core.post_processing import nms_bev -from mmdet3d.models import builder -from mmdet3d.models.utils import clip_sigmoid -from mmdet.core import build_bbox_coder, multi_apply, reduce_mean -from mmdet3d.models.builder import HEADS, build_loss - - -@HEADS.register_module(force=True) -class SeparateHead(BaseModule): - """SeparateHead for CenterHead. - - Args: - in_channels (int): Input channels for conv_layer. - heads (dict): Conv information. - head_conv (int, optional): Output channels. - Default: 64. - final_kernel (int, optional): Kernel size for the last conv layer. - Default: 1. - init_bias (float, optional): Initial bias. Default: -2.19. - conv_cfg (dict, optional): Config of conv layer. - Default: dict(type='Conv2d') - norm_cfg (dict, optional): Config of norm layer. - Default: dict(type='BN2d'). - bias (str, optional): Type of bias. Default: 'auto'. - """ - - def __init__(self, - in_channels, - heads, - head_conv=64, - final_kernel=1, - init_bias=-2.19, - conv_cfg=dict(type='Conv2d'), - norm_cfg=dict(type='BN2d'), - bias='auto', - init_cfg=None, - **kwargs): - assert init_cfg is None, 'To prevent abnormal initialization ' \ - 'behavior, init_cfg is not allowed to be set' - super(SeparateHead, self).__init__(init_cfg=init_cfg) - self.heads = heads - self.init_bias = init_bias - for head in self.heads: - # 该head的输出通道和卷积数量. - classes, num_conv = self.heads[head] - - conv_layers = [] - c_in = in_channels - for i in range(num_conv - 1): - conv_layers.append( - ConvModule( - c_in, - head_conv, - kernel_size=final_kernel, - stride=1, - padding=final_kernel // 2, - bias=bias, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg)) - c_in = head_conv - - conv_layers.append( - build_conv_layer( - conv_cfg, - head_conv, - classes, - kernel_size=final_kernel, - stride=1, - padding=final_kernel // 2, - bias=True)) - conv_layers = nn.Sequential(*conv_layers) - - self.__setattr__(head, conv_layers) - - if init_cfg is None: - self.init_cfg = dict(type='Kaiming', layer='Conv2d') - - def init_weights(self): - """Initialize weights.""" - super().init_weights() - for head in self.heads: - if head == 'heatmap': - self.__getattr__(head)[-1].bias.data.fill_(self.init_bias) - - def forward(self, x): - """Forward function for SepHead. - - Args: - x (torch.Tensor): Input feature map with the shape of - [B, 512, 128, 128]. - - Returns: - dict[str: torch.Tensor]: contains the following keys: - - -reg (torch.Tensor): 2D regression value with the - shape of [B, 2, H, W]. - -height (torch.Tensor): Height value with the - shape of [B, 1, H, W]. - -dim (torch.Tensor): Size value with the shape - of [B, 3, H, W]. - -rot (torch.Tensor): Rotation value with the - shape of [B, 2, H, W]. - -vel (torch.Tensor): Velocity value with the - shape of [B, 2, H, W]. - -heatmap (torch.Tensor): Heatmap with the shape of - [B, N, H, W]. - """ - ret_dict = dict() - for head in self.heads: - ret_dict[head] = self.__getattr__(head)(x) - - return ret_dict - - -@HEADS.register_module(force=True) -class DCNSeparateHead(BaseModule): - r"""DCNSeparateHead for CenterHead. - - .. code-block:: none - /-----> DCN for heatmap task -----> heatmap task. - feature - \-----> DCN for regression tasks -----> regression tasks - - Args: - in_channels (int): Input channels for conv_layer. - num_cls (int): Number of classes. - heads (dict): Conv information. - dcn_config (dict): Config of dcn layer. - head_conv (int, optional): Output channels. - Default: 64. - final_kernel (int, optional): Kernel size for the last conv - layer. Default: 1. - init_bias (float, optional): Initial bias. Default: -2.19. - conv_cfg (dict, optional): Config of conv layer. - Default: dict(type='Conv2d') - norm_cfg (dict, optional): Config of norm layer. - Default: dict(type='BN2d'). - bias (str, optional): Type of bias. Default: 'auto'. - """ # noqa: W605 - - def __init__(self, - in_channels, - num_cls, - heads, - dcn_config, - head_conv=64, - final_kernel=1, - init_bias=-2.19, - conv_cfg=dict(type='Conv2d'), - norm_cfg=dict(type='BN2d'), - bias='auto', - init_cfg=None, - **kwargs): - assert init_cfg is None, 'To prevent abnormal initialization ' \ - 'behavior, init_cfg is not allowed to be set' - super(DCNSeparateHead, self).__init__(init_cfg=init_cfg) - if 'heatmap' in heads: - heads.pop('heatmap') - # feature adaptation with dcn - # use separate features for classification / regression - self.feature_adapt_cls = build_conv_layer(dcn_config) - - self.feature_adapt_reg = build_conv_layer(dcn_config) - - # heatmap prediction head - cls_head = [ - ConvModule( - in_channels, - head_conv, - kernel_size=3, - padding=1, - conv_cfg=conv_cfg, - bias=bias, - norm_cfg=norm_cfg), - build_conv_layer( - conv_cfg, - head_conv, - num_cls, - kernel_size=3, - stride=1, - padding=1, - bias=bias) - ] - self.cls_head = nn.Sequential(*cls_head) - self.init_bias = init_bias - # other regression target - self.task_head = SeparateHead( - in_channels, - heads, - head_conv=head_conv, - final_kernel=final_kernel, - bias=bias) - if init_cfg is None: - self.init_cfg = dict(type='Kaiming', layer='Conv2d') - - def init_weights(self): - """Initialize weights.""" - super().init_weights() - self.cls_head[-1].bias.data.fill_(self.init_bias) - - def forward(self, x): - """Forward function for DCNSepHead. - - Args: - x (torch.Tensor): Input feature map with the shape of - [B, 512, 128, 128]. - - Returns: - dict[str: torch.Tensor]: contains the following keys: - - -reg (torch.Tensor): 2D regression value with the - shape of [B, 2, H, W]. - -height (torch.Tensor): Height value with the - shape of [B, 1, H, W]. - -dim (torch.Tensor): Size value with the shape - of [B, 3, H, W]. - -rot (torch.Tensor): Rotation value with the - shape of [B, 2, H, W]. - -vel (torch.Tensor): Velocity value with the - shape of [B, 2, H, W]. - -heatmap (torch.Tensor): Heatmap with the shape of - [B, N, H, W]. - """ - center_feat = self.feature_adapt_cls(x) - reg_feat = self.feature_adapt_reg(x) - - cls_score = self.cls_head(center_feat) - ret = self.task_head(reg_feat) - ret['heatmap'] = cls_score - - return ret - - -@HEADS.register_module() -class BEV_CenterHead(BaseModule): - """CenterHead for CenterPoint. - - Args: - in_channels (list[int] | int, optional): Channels of the input - feature map. Default: [128]. - tasks (list[dict], optional): Task information including class number - and class names. Default: None. - train_cfg (dict, optional): Train-time configs. Default: None. - test_cfg (dict, optional): Test-time configs. Default: None. - bbox_coder (dict, optional): Bbox coder configs. Default: None. - common_heads (dict, optional): Conv information for common heads. - Default: dict(). - loss_cls (dict, optional): Config of classification loss function. - Default: dict(type='GaussianFocalLoss', reduction='mean'). - loss_bbox (dict, optional): Config of regression loss function. - Default: dict(type='L1Loss', reduction='none'). - separate_head (dict, optional): Config of separate head. Default: dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3) - share_conv_channel (int, optional): Output channels for share_conv - layer. Default: 64. - num_heatmap_convs (int, optional): Number of conv layers for heatmap - conv layer. Default: 2. - conv_cfg (dict, optional): Config of conv layer. - Default: dict(type='Conv2d') - norm_cfg (dict, optional): Config of norm layer. - Default: dict(type='BN2d'). - bias (str, optional): Type of bias. Default: 'auto'. - """ - - def __init__(self, - in_channels=[128], - tasks=None, - train_cfg=None, - test_cfg=None, - bbox_coder=None, - common_heads=dict(), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict( - type='L1Loss', reduction='none', loss_weight=0.25), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - share_conv_channel=64, - num_heatmap_convs=2, - conv_cfg=dict(type='Conv2d'), - norm_cfg=dict(type='BN2d'), - bias='auto', - norm_bbox=True, - init_cfg=None, - task_specific=True): - assert init_cfg is None, 'To prevent abnormal initialization ' \ - 'behavior, init_cfg is not allowed to be set' - super(BEV_CenterHead, self).__init__(init_cfg=init_cfg) - - num_classes = [len(t['class_names']) for t in tasks] # 记录不同task(SeparateHead)负责检测的类别数. - self.class_names = [t['class_names'] for t in tasks] # 记录不同task(SeparateHead)负责检测的类别名. - self.train_cfg = train_cfg - self.test_cfg = test_cfg - self.in_channels = in_channels - self.num_classes = num_classes - self.norm_bbox = norm_bbox - - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - self.bbox_coder = build_bbox_coder(bbox_coder) - self.num_anchor_per_locs = [n for n in num_classes] - self.fp16_enabled = False - - # a shared convolution - self.shared_conv = ConvModule( - in_channels, - share_conv_channel, - kernel_size=3, - padding=1, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - bias=bias) - - # 每个task建立对应的head. - self.task_heads = nn.ModuleList() - for num_cls in num_classes: - # common_heads = dict( - # reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - heads = copy.deepcopy(common_heads) - heads.update(dict(heatmap=(num_cls, num_heatmap_convs))) - separate_head.update( - in_channels=share_conv_channel, heads=heads, num_cls=num_cls) - self.task_heads.append(builder.build_head(separate_head)) - - self.with_velocity = 'vel' in common_heads.keys() - self.task_specific = task_specific - - def forward_single(self, x): - """Forward function for CenterPoint. - - Args: - x (torch.Tensor): Input feature map with the shape of - [B, 512, 128, 128]. - - Returns: - list[dict]: Output results for tasks. - """ - ret_dicts = [] - - x = self.shared_conv(x) # (B, C'=share_conv_channel, H, W) - - # 运行不同task_head, - for task in self.task_heads: - ret_dicts.append(task(x)) - - # ret_dicts: [dict0, dict1, ...] len = SeparateHead的数量 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - - return ret_dicts - - def forward(self, feats): - """Forward pass. - - Args: - feats (list[torch.Tensor]): Multi-level features, e.g., - features produced by FPN. - - Returns: - results: Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - """ - return multi_apply(self.forward_single, feats) - - def _gather_feat(self, feat, ind, mask=None): - """Gather feature map. - - Given feature map and index, return indexed feature map. - - Args: - feat (torch.tensor): Feature map with the shape of [B, H*W, 10]. - ind (torch.Tensor): Index of the ground truth boxes with the - shape of [B, max_obj]. - mask (torch.Tensor, optional): Mask of the feature map with the - shape of [B, max_obj]. Default: None. - - Returns: - torch.Tensor: Feature map after gathering with the shape - of [B, max_obj, 10]. - """ - dim = feat.size(2) - ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim) - feat = feat.gather(1, ind) - if mask is not None: - mask = mask.unsqueeze(2).expand_as(feat) - feat = feat[mask] - feat = feat.view(-1, dim) - return feat - - def get_targets(self, gt_bboxes_3d, gt_labels_3d): - """Generate targets. - - How each output is transformed: - - Each nested list is transposed so that all same-index elements in - each sub-list (1, ..., N) become the new sub-lists. - [ [a0, a1, a2, ... ], [b0, b1, b2, ... ], ... ] - ==> [ [a0, b0, ... ], [a1, b1, ... ], [a2, b2, ... ] ] - - The new transposed nested list is converted into a list of N - tensors generated by concatenating tensors in the new sub-lists. - [ tensor0, tensor1, tensor2, ... ] - - Args: - gt_bboxes_3d (list[:obj:`LiDARInstance3DBoxes`]): Ground - truth gt boxes. # List[(N_gt0, 7/9), (N_gt1, 7/9), ...] - gt_labels_3d (list[torch.Tensor]): Labels of boxes. # List[(N_gt0, ), (N_gt1, ), ...] - - Returns: - Returns: - tuple[list[torch.Tensor]]: ( - heatmaps: List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - anno_boxes: - inds: - masks: - ) - """ - heatmaps, anno_boxes, inds, masks = multi_apply( - self.get_targets_single, gt_bboxes_3d, gt_labels_3d) - # heatmaps: # Tuple(List[(N_cls0, H, W), (N_cls1, H, W), ...], ...) len = batch_size - # anno_boxes: # Tuple(List[(max_objs, 10), (max_objs, 10), ...], ...) len = batch_size - # inds: # Tuple(List[(max_objs, ), (max_objs, ), ...], ...) - # masks: # Tuple(List[(max_objs, ), (max_objs, ), ...], ...) - - # Transpose heatmaps - # List[List[(N_cls0, H, W), (N_cls0, H, W), ...], List[(N_cls1, H, W), (N_cls1, H, W), ...], ...] len = num of SeparateHead - heatmaps = list(map(list, zip(*heatmaps))) - heatmaps = [torch.stack(hms_) for hms_ in heatmaps] # List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - # Transpose anno_boxes - anno_boxes = list(map(list, zip(*anno_boxes))) - anno_boxes = [torch.stack(anno_boxes_) for anno_boxes_ in anno_boxes] # List[(B, max_objs, 10), (B, max_objs, 10), ...] len = num of SeparateHead - # Transpose inds - inds = list(map(list, zip(*inds))) - inds = [torch.stack(inds_) for inds_ in inds] # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - # Transpose inds - masks = list(map(list, zip(*masks))) - masks = [torch.stack(masks_) for masks_ in masks] # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - return heatmaps, anno_boxes, inds, masks - - def get_targets_single(self, gt_bboxes_3d, gt_labels_3d): - """Generate training targets for a single sample. - - Args: - gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`): Ground truth gt boxes. # (N_gt, 7/9) - gt_labels_3d (torch.Tensor): Labels of boxes. # (N_gt, ) - - Returns: - tuple[list[torch.Tensor]]: Tuple of target including - the following results in order. - - heatmaps: list[torch.Tensor]: Heatmap scores. # List[(N_cls0, H, W), (N_cls1, H, W), ...] - len = num of tasks - - anno_boxes: list[torch.Tensor]: Ground truth boxes. # List[(max_objs, 10), (max_objs, 10), ...] - - inds: list[torch.Tensor]: Indexes indicating the position - of the valid boxes. # List[(max_objs, ), (max_objs, ), ...] - - masks: list[torch.Tensor]: Masks indicating which boxes - are valid. # List[(max_objs, ), (max_objs, ), ...] - """ - device = gt_labels_3d.device - gt_bboxes_3d = torch.cat( - (gt_bboxes_3d.gravity_center, gt_bboxes_3d.tensor[:, 3:]), - dim=1).to(device) # (N_gt, 7/9) - max_objs = self.train_cfg['max_objs'] * self.train_cfg['dense_reg'] - grid_size = torch.tensor(self.train_cfg['grid_size']) # (Dx, Dy, Dz) - pc_range = torch.tensor(self.train_cfg['point_cloud_range']) - voxel_size = torch.tensor(self.train_cfg['voxel_size']) - - feature_map_size = grid_size[:2] // self.train_cfg['out_size_factor'] # (W, H) - - # reorganize the gt_dict by tasks - task_masks = [] - flag = 0 - for class_name in self.class_names: - # class_name: 不同task(SeparateHead)负责检测的类别名. - task_masks.append([ - torch.where(gt_labels_3d == class_name.index(i) + flag) - for i in class_name - ]) - flag += len(class_name) - # task_masks: List[task_mask0, task_mask1, ...] len = number of SeparateHeads - # task_mask: List[((N_gt0, ), ), ((N_gt1, ), ), ...] len = number of class - - task_boxes = [] - task_classes = [] - flag2 = 0 - for idx, mask in enumerate(task_masks): - # mask: 不同task(SeparateHead)的mask, 每个task负责检测一组不同类别的目标. - # List[((N_gt0, ), ), ((N_gt1, ), ), ...], # N_gt_task=N_gt0+N_gt1+..., 表示当前task负责检测的gt_boxes的数量. - task_box = [] - task_class = [] - for m in mask: - task_box.append(gt_bboxes_3d[m]) - # 0 is background for each task, so we need to add 1 here. - task_class.append(gt_labels_3d[m] + 1 - flag2) - task_boxes.append(torch.cat(task_box, axis=0).to(device)) - task_classes.append(torch.cat(task_class).long().to(device)) - flag2 += len(mask) - # 记录不同task负责检测的gt_boxes和gt_classes: - # task_boxes: List[(N_gt_task0, 7/9), (N_gt_task1, 7/9), ...] - # task_classes: List[(N_gt_task0, ), (N_gt_task1, ), ...] - - draw_gaussian = draw_heatmap_gaussian - heatmaps, anno_boxes, inds, masks = [], [], [], [] - - for idx, task_head in enumerate(self.task_heads): - heatmap = gt_bboxes_3d.new_zeros( - (len(self.class_names[idx]), feature_map_size[1], - feature_map_size[0])) # (N_cls, H, W) N_cls表示当前task_head负责检测的类别数目. - - if self.with_velocity: - anno_box = gt_bboxes_3d.new_zeros((max_objs, 10), - dtype=torch.float32) # (max_objs, 10) - else: - anno_box = gt_bboxes_3d.new_zeros((max_objs, 8), - dtype=torch.float32) - - ind = gt_labels_3d.new_zeros((max_objs, ), dtype=torch.int64) # (max_objs, ) - mask = gt_bboxes_3d.new_zeros((max_objs, ), dtype=torch.uint8) # (max_objs, ) - - num_objs = min(task_boxes[idx].shape[0], max_objs) # 当前task_head负责检测的目标. - - for k in range(num_objs): - cls_id = task_classes[idx][k] - 1 # 当前目标的cls_id, cls_id是相对task group内的. - - width = task_boxes[idx][k][3] # dx - length = task_boxes[idx][k][4] # dy - # 当前目标在feature map上的width和length - width = width / voxel_size[0] / self.train_cfg[ - 'out_size_factor'] - length = length / voxel_size[1] / self.train_cfg[ - 'out_size_factor'] - - if width > 0 and length > 0: - # 计算gaussian半径 - radius = gaussian_radius( - (length, width), - min_overlap=self.train_cfg['gaussian_overlap']) - radius = max(self.train_cfg['min_radius'], int(radius)) - - # be really careful for the coordinate system of - # your box annotation. - x, y, z = task_boxes[idx][k][0], task_boxes[idx][k][ - 1], task_boxes[idx][k][2] # 当前目标的中心坐标. - - # 计算gt_box中心点在feature map中对应的位置. - coor_x = ( - x - pc_range[0] - ) / voxel_size[0] / self.train_cfg['out_size_factor'] - coor_y = ( - y - pc_range[1] - ) / voxel_size[1] / self.train_cfg['out_size_factor'] - - center = torch.tensor([coor_x, coor_y], - dtype=torch.float32, - device=device) - center_int = center.to(torch.int32) - - # throw out not in range objects to avoid out of array - # area when creating the heatmap - if not (0 <= center_int[0] < feature_map_size[0] - and 0 <= center_int[1] < feature_map_size[1]): - continue - - # 根据目标中心点在feature map中对应的位置、高斯半径来设置heatmap. - draw_gaussian(heatmap[cls_id], center_int, radius) - - new_idx = k - x, y = center_int[0], center_int[1] - - assert (y * feature_map_size[0] + x < - feature_map_size[0] * feature_map_size[1]) - - # 记录正样本在feature map中的位置. - ind[new_idx] = y * feature_map_size[0] + x - mask[new_idx] = 1 - # TODO: support other outdoor dataset - rot = task_boxes[idx][k][6] - box_dim = task_boxes[idx][k][3:6] - if self.norm_bbox: - box_dim = box_dim.log() - if self.with_velocity: - vx, vy = task_boxes[idx][k][7:] - anno_box[new_idx] = torch.cat([ - center - torch.tensor([x, y], device=device), # tx, ty - z.unsqueeze(0), box_dim, # z, log(dx), log(dy), log(dz) - torch.sin(rot).unsqueeze(0), # sin(rot) - torch.cos(rot).unsqueeze(0), # cos(rot) - vx.unsqueeze(0), # vx - vy.unsqueeze(0) # vy - ]) # [tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy] - else: - anno_box[new_idx] = torch.cat([ - center - torch.tensor([x, y], device=device), - z.unsqueeze(0), box_dim, - torch.sin(rot).unsqueeze(0), - torch.cos(rot).unsqueeze(0) - ]) - - heatmaps.append(heatmap) # append (N_cls, H, W) - anno_boxes.append(anno_box) # append (max_objs, 10) - masks.append(mask) # append (max_objs, ) - inds.append(ind) # append (max_objs, ) - return heatmaps, anno_boxes, inds, masks - - def loss(self, gt_bboxes_3d, gt_labels_3d, preds_dicts, **kwargs): - """Loss function for CenterHead. - - Args: - gt_bboxes_3d (list[:obj:`LiDARInstance3DBoxes`]): Ground - truth gt boxes. # List[(N_gt0, 7/9), (N_gt1, 7/9), ...] - gt_labels_3d (list[torch.Tensor]): Labels of boxes. # List[(N_gt0, ), (N_gt1, ), ...] - preds_dicts (dict): Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - Returns: - dict[str:torch.Tensor]: Loss of heatmap and bbox of each task. - """ - heatmaps, anno_boxes, inds, masks = self.get_targets( - gt_bboxes_3d, gt_labels_3d) - # heatmaps: # List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - # anno_boxes: # List[(B, max_objs, 10), (B, max_objs, 10), ...] len = num of SeparateHead - # inds: # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - # masks: # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - - loss_dict = dict() - if not self.task_specific: - loss_dict['loss'] = 0 - for task_id, preds_dict in enumerate(preds_dicts): - # task_id: SeparateHead idx - # preds_dict: List[dict0, ...] len = num levels, 对于center_point len = 1 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - - # heatmap focal loss - preds_dict[0]['heatmap'] = clip_sigmoid(preds_dict[0]['heatmap']) - num_pos = heatmaps[task_id].eq(1).float().sum().item() - cls_avg_factor = torch.clamp( - reduce_mean(heatmaps[task_id].new_tensor(num_pos)), - min=1).item() - loss_heatmap = self.loss_cls( - preds_dict[0]['heatmap'], # (B, cur_N_cls, H, W) - heatmaps[task_id], # (B, cur_N_cls, H, W) - avg_factor=cls_avg_factor - ) - - # (B, max_objs, 10) 10: (tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy) - target_box = anno_boxes[task_id] - # reconstruct the anno_box from multiple reg heads - preds_dict[0]['anno_box'] = torch.cat( - ( - preds_dict[0]['reg'], - preds_dict[0]['height'], - preds_dict[0]['dim'], - preds_dict[0]['rot'], - preds_dict[0]['vel'], - ), - dim=1, - ) # (B, 10, H, W) 10: (tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy) - - # Regression loss for dimension, offset, height, rotation - num = masks[task_id].float().sum() # 正样本的数量 - ind = inds[task_id] # (B, max_objs) - pred = preds_dict[0]['anno_box'].permute(0, 2, 3, 1).contiguous() # (B, H, W, 10) - pred = pred.view(pred.size(0), -1, pred.size(3)) # (B, H*W, 10) - pred = self._gather_feat(pred, ind) # (B, max_objs, 10) - # (B, max_objs) --> (B, max_objs, 1) --> (B, max_objs, 10) - mask = masks[task_id].unsqueeze(2).expand_as(target_box).float() - num = torch.clamp( - reduce_mean(target_box.new_tensor(num)), min=1e-4).item() - isnotnan = (~torch.isnan(target_box)).float() - mask *= isnotnan # 只监督mask指定的reg预测. - code_weights = self.train_cfg['code_weights'] - bbox_weights = mask * mask.new_tensor(code_weights) # 在mask基础上,设置box不同属性的权重. (B, max_objs, 10) - if self.task_specific: - name_list = ['xy', 'z', 'whl', 'yaw', 'vel'] - clip_index = [0, 2, 3, 6, 8, 10] - for reg_task_id in range(len(name_list)): - pred_tmp = pred[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - target_box_tmp = target_box[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - bbox_weights_tmp = bbox_weights[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - loss_bbox_tmp = self.loss_bbox( - pred_tmp, - target_box_tmp, - bbox_weights_tmp, - avg_factor=(num + 1e-4)) - loss_dict[f'task{task_id}.loss_%s' % - (name_list[reg_task_id])] = loss_bbox_tmp - loss_dict[f'task{task_id}.loss_heatmap'] = loss_heatmap - else: - loss_bbox = self.loss_bbox( - pred, target_box, bbox_weights, avg_factor=num) - loss_dict['loss'] += loss_bbox - loss_dict['loss'] += loss_heatmap - - return loss_dict - - def get_bboxes(self, preds_dicts, img_metas, img=None, rescale=False): - """Generate bboxes from bbox head predictions. - - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - img_metas (list[dict]): Point cloud and image's meta info. - - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - ret_list: List[p_list0, p_list1, ...] - p_list: List[(N, 9), (N, ), (N, )] - """ - rets = [] - for task_id, preds_dict in enumerate(preds_dicts): - # task_id: SeparateHead idx - # preds_dict: List[dict0, ...] len = num levels, 对于center_point len = 1 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - batch_size = preds_dict[0]['heatmap'].shape[0] - batch_heatmap = preds_dict[0]['heatmap'].sigmoid() # (B, n_cls, H, W) - - batch_reg = preds_dict[0]['reg'] # (B, 2, H, W) - batch_hei = preds_dict[0]['height'] # (B, 1, H, W) - - if self.norm_bbox: - batch_dim = torch.exp(preds_dict[0]['dim']) # (B, 3, H, W) - else: - batch_dim = preds_dict[0]['dim'] - - batch_rots = preds_dict[0]['rot'][:, 0].unsqueeze(1) # (B, 1, H, W) - batch_rotc = preds_dict[0]['rot'][:, 1].unsqueeze(1) # (B, 1, H, W) - - if 'vel' in preds_dict[0]: - batch_vel = preds_dict[0]['vel'] # (B, 2, H, W) - else: - batch_vel = None - - temp = self.bbox_coder.decode( - batch_heatmap, - batch_rots, - batch_rotc, - batch_hei, - batch_dim, - batch_vel, - reg=batch_reg, - task_id=task_id) - # temp: List[p_dict0, p_dict1, ...] len=bs - # p_dict = { - # 'bboxes': boxes3d, # (K', 9) - # 'scores': scores, # (K', ) - # 'labels': labels # (K', ) - # } - batch_reg_preds = [box['bboxes'] for box in temp] # List[(K0, 9), (K1, 9), ...] len = bs - batch_cls_preds = [box['scores'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - batch_cls_labels = [box['labels'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - nms_type = self.test_cfg.get('nms_type') - if isinstance(nms_type, list): - nms_type = nms_type[task_id] - if nms_type == 'circle': - ret_task = [] - for i in range(batch_size): - boxes3d = temp[i]['bboxes'] - scores = temp[i]['scores'] - labels = temp[i]['labels'] - centers = boxes3d[:, [0, 1]] - boxes = torch.cat([centers, scores.view(-1, 1)], dim=1) - keep = torch.tensor( - circle_nms( - boxes.detach().cpu().numpy(), - self.test_cfg['min_radius'][task_id], - post_max_size=self.test_cfg['post_max_size']), - dtype=torch.long, - device=boxes.device) - - boxes3d = boxes3d[keep] - scores = scores[keep] - labels = labels[keep] - ret = dict(bboxes=boxes3d, scores=scores, labels=labels) - ret_task.append(ret) - rets.append(ret_task) - else: - rets.append( - self.get_task_detections(batch_cls_preds, batch_reg_preds, - batch_cls_labels, img_metas, - task_id)) - - # rets: List[ret_task0, ret_task1, ...], len = num_tasks - # ret_task: List[p_dict0, p_dict1, ...], len = batch_size - # p_dict: dict{ - # bboxes: (K', 9) - # scores: (K', ) - # labels: (K', ) - # } - - # Merge branches results - num_samples = len(rets[0]) # bs - - ret_list = [] - # 遍历batch, 然后汇总所有task的预测. - for i in range(num_samples): - for k in rets[0][i].keys(): - if k == 'bboxes': - bboxes = torch.cat([ret[i][k] for ret in rets]) # 对于bboxes, 直接拼接即可. - bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - bboxes = img_metas[i]['box_type_3d']( - bboxes, self.bbox_coder.code_size) - elif k == 'scores': - scores = torch.cat([ret[i][k] for ret in rets]) # 对于scores, 直接拼接即可. - elif k == 'labels': - flag = 0 - for j, num_class in enumerate(self.num_classes): # 对于labels, 要进行调整, 因为预测的label是task组内的. - rets[j][i][k] += flag - flag += num_class - labels = torch.cat([ret[i][k].int() for ret in rets]) - ret_list.append([bboxes, scores, labels]) - - # ret_list: List[p_list0, p_list1, ...] - # p_list: List[(N, 9), (N, ), (N, )] - return ret_list - - def get_task_detections(self, batch_cls_preds, - batch_reg_preds, batch_cls_labels, img_metas, - task_id): - """Rotate nms for each task. - - Args: - batch_cls_preds (list[torch.Tensor]): Prediction score with the - shape of [N]. # List[(K0, ), (K1, ), ...] len = bs - batch_reg_preds (list[torch.Tensor]): Prediction bbox with the - shape of [N, 9]. # List[(K0, 9), (K1, 9), ...] len = bs - batch_cls_labels (list[torch.Tensor]): Prediction label with the - shape of [N]. # List[(K0, ), (K1, ), ...] len = bs - img_metas (list[dict]): Meta information of each sample. - - Returns: - list[dict[str: torch.Tensor]]: contains the following keys: - -bboxes (torch.Tensor): Prediction bboxes after nms with the - shape of [N, 9]. - -scores (torch.Tensor): Prediction scores after nms with the - shape of [N]. - -labels (torch.Tensor): Prediction labels after nms with the - shape of [N]. - - List[p_dict0, p_dict1, ...] len = batch_size - p_dict: dict{ - bboxes: (K', 9) - scores: (K', ) - labels: (K', ) - } - """ - predictions_dicts = [] - # 遍历不同batch的topK预测输出. - for i, (box_preds, cls_preds, cls_labels) in enumerate( - zip(batch_reg_preds, batch_cls_preds, batch_cls_labels)): - # box_preds: (K, 9) - # cls_preds: (K, ) - # cls_labels: (K, ) - default_val = [1.0 for _ in range(len(self.task_heads))] - factor = self.test_cfg.get('nms_rescale_factor', - default_val)[task_id] - if isinstance(factor, list): - # List[float, float, ..] len = 当前task负责预测的类别数. - # 对于box_preds, 使用其对应的factor进行缩放, 一般是放大小目标,缩小大目标. - for cid in range(len(factor)): - box_preds[cls_labels == cid, 3:6] = \ - box_preds[cls_labels == cid, 3:6] * factor[cid] - else: - box_preds[:, 3:6] = box_preds[:, 3:6] * factor - - # Apply NMS in birdeye view - top_labels = cls_labels.long() # (K, ) - top_scores = cls_preds.squeeze(-1) if cls_preds.shape[0] > 1 \ - else cls_preds # (K, ) - - if top_scores.shape[0] != 0: - boxes_for_nms = img_metas[i]['box_type_3d']( - box_preds[:, :], self.bbox_coder.code_size).bev # (K, 5) (x, y, dx, dy, yaw) - # the nms in 3d detection just remove overlap boxes. - if isinstance(self.test_cfg['nms_thr'], list): - nms_thresh = self.test_cfg['nms_thr'][task_id] - else: - nms_thresh = self.test_cfg['nms_thr'] - - selected = nms_bev( - boxes_for_nms, - top_scores, - thresh=nms_thresh, - pre_max_size=self.test_cfg['pre_max_size'], - post_max_size=self.test_cfg['post_max_size'], - xyxyr2xywhr=False, - ) - else: - selected = [] - - # NMS后再根据factor缩放回原来的尺寸. - if isinstance(factor, list): - for cid in range(len(factor)): - box_preds[top_labels == cid, 3:6] = \ - box_preds[top_labels == cid, 3:6] / factor[cid] - else: - box_preds[:, 3:6] = box_preds[:, 3:6] / factor - - # if selected is not None: - selected_boxes = box_preds[selected] # (K', 9) - selected_labels = top_labels[selected] # (K', ) - selected_scores = top_scores[selected] # (K', ) - - # finally generate predictions. - if selected_boxes.shape[0] != 0: - predictions_dict = dict( - bboxes=selected_boxes, - scores=selected_scores, - labels=selected_labels) - else: - dtype = batch_reg_preds[0].dtype - device = batch_reg_preds[0].device - predictions_dict = dict( - bboxes=torch.zeros([0, self.bbox_coder.code_size], - dtype=dtype, - device=device), - scores=torch.zeros([0], dtype=dtype, device=device), - labels=torch.zeros([0], - dtype=top_labels.dtype, - device=device)) - - predictions_dicts.append(predictions_dict) - return predictions_dicts - - -@HEADS.register_module() -class Centerness_Head(BaseModule): - """CenterHead for CenterPoint. - - Args: - in_channels (list[int] | int, optional): Channels of the input - feature map. Default: [128]. - tasks (list[dict], optional): Task information including class number - and class names. Default: None. - train_cfg (dict, optional): Train-time configs. Default: None. - test_cfg (dict, optional): Test-time configs. Default: None. - bbox_coder (dict, optional): Bbox coder configs. Default: None. - common_heads (dict, optional): Conv information for common heads. - Default: dict(). - loss_cls (dict, optional): Config of classification loss function. - Default: dict(type='GaussianFocalLoss', reduction='mean'). - loss_bbox (dict, optional): Config of regression loss function. - Default: dict(type='L1Loss', reduction='none'). - separate_head (dict, optional): Config of separate head. Default: dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3) - share_conv_channel (int, optional): Output channels for share_conv - layer. Default: 64. - num_heatmap_convs (int, optional): Number of conv layers for heatmap - conv layer. Default: 2. - conv_cfg (dict, optional): Config of conv layer. - Default: dict(type='Conv2d') - norm_cfg (dict, optional): Config of norm layer. - Default: dict(type='BN2d'). - bias (str, optional): Type of bias. Default: 'auto'. - """ - - def __init__(self, - in_channels=[128], - tasks=None, - train_cfg=None, - test_cfg=None, - bbox_coder=None, - common_heads=dict(), - loss_cls=dict(type='GaussianFocalLoss', reduction='mean'), - loss_bbox=dict( - type='L1Loss', reduction='none', loss_weight=0.25), - separate_head=dict( - type='SeparateHead', init_bias=-2.19, final_kernel=3), - share_conv_channel=64, - num_heatmap_convs=2, - conv_cfg=dict(type='Conv2d'), - norm_cfg=dict(type='BN2d'), - bias='auto', - norm_bbox=True, - init_cfg=None, - task_specific=True, - task_specific_weight=[1, 1, 1, 1, 1]): - assert init_cfg is None, 'To prevent abnormal initialization ' \ - 'behavior, init_cfg is not allowed to be set' - super(Centerness_Head, self).__init__(init_cfg=init_cfg) - - num_classes = [len(t['class_names']) for t in tasks] # 记录不同task(SeparateHead)负责检测的类别数. - self.class_names = [t['class_names'] for t in tasks] # 记录不同task(SeparateHead)负责检测的类别名. - self.train_cfg = train_cfg - self.test_cfg = test_cfg - self.in_channels = in_channels - self.num_classes = num_classes - self.norm_bbox = norm_bbox - - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - self.bbox_coder = build_bbox_coder(bbox_coder) - self.num_anchor_per_locs = [n for n in num_classes] - self.fp16_enabled = False - - # a shared convolution - self.shared_conv = ConvModule( - in_channels, - share_conv_channel, - kernel_size=3, - padding=1, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - bias=bias) - - # 每个task建立对应的head. - self.task_heads = nn.ModuleList() - for num_cls in num_classes: - # common_heads = dict( - # reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), vel=(2, 2)), - heads = copy.deepcopy(common_heads) - heads.update(dict(heatmap=(num_cls, num_heatmap_convs))) - separate_head.update( - in_channels=share_conv_channel, heads=heads, num_cls=num_cls) - self.task_heads.append(builder.build_head(separate_head)) - - self.with_velocity = 'vel' in common_heads.keys() - self.task_specific = task_specific - - self.task_specific_weight = task_specific_weight # [1, 1, 0, 0, 0] # 'xy', 'z', 'whl', 'yaw', 'vel' - - def forward_single(self, x): - """Forward function for CenterPoint. - - Args: - x (torch.Tensor): Input feature map with the shape of - [B, 512, 128, 128]. - - Returns: - list[dict]: Output results for tasks. - """ - ret_dicts = [] - - x = self.shared_conv(x) # (B, C'=share_conv_channel, H, W) - - # 运行不同task_head, - for task in self.task_heads: - ret_dicts.append(task(x)) - - # ret_dicts: [dict0, dict1, ...] len = SeparateHead的数量 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - - return ret_dicts - - def forward(self, feats): - """Forward pass. - - Args: - feats (list[torch.Tensor]): Multi-level features, e.g., - features produced by FPN. - - Returns: - results: Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - """ - return multi_apply(self.forward_single, feats) - - def _gather_feat(self, feat, ind, mask=None): - """Gather feature map. - - Given feature map and index, return indexed feature map. - - Args: - feat (torch.tensor): Feature map with the shape of [B, H*W, 10]. - ind (torch.Tensor): Index of the ground truth boxes with the - shape of [B, max_obj]. - mask (torch.Tensor, optional): Mask of the feature map with the - shape of [B, max_obj]. Default: None. - - Returns: - torch.Tensor: Feature map after gathering with the shape - of [B, max_obj, 10]. - """ - dim = feat.size(2) - ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim) - feat = feat.gather(1, ind) - if mask is not None: - mask = mask.unsqueeze(2).expand_as(feat) - feat = feat[mask] - feat = feat.view(-1, dim) - return feat - - def get_targets(self, gt_bboxes_3d, gt_labels_3d): - """Generate targets. - - How each output is transformed: - - Each nested list is transposed so that all same-index elements in - each sub-list (1, ..., N) become the new sub-lists. - [ [a0, a1, a2, ... ], [b0, b1, b2, ... ], ... ] - ==> [ [a0, b0, ... ], [a1, b1, ... ], [a2, b2, ... ] ] - - The new transposed nested list is converted into a list of N - tensors generated by concatenating tensors in the new sub-lists. - [ tensor0, tensor1, tensor2, ... ] - - Args: - gt_bboxes_3d (list[:obj:`LiDARInstance3DBoxes`]): Ground - truth gt boxes. # List[(N_gt0, 7/9), (N_gt1, 7/9), ...] - gt_labels_3d (list[torch.Tensor]): Labels of boxes. # List[(N_gt0, ), (N_gt1, ), ...] - - Returns: - Returns: - tuple[list[torch.Tensor]]: ( - heatmaps: List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - anno_boxes: - inds: - masks: - ) - """ - heatmaps, anno_boxes, inds, masks = multi_apply( - self.get_targets_single, gt_bboxes_3d, gt_labels_3d) - # heatmaps: # Tuple(List[(N_cls0, H, W), (N_cls1, H, W), ...], ...) len = batch_size - # anno_boxes: # Tuple(List[(max_objs, 10), (max_objs, 10), ...], ...) len = batch_size - # inds: # Tuple(List[(max_objs, ), (max_objs, ), ...], ...) - # masks: # Tuple(List[(max_objs, ), (max_objs, ), ...], ...) - - # Transpose heatmaps - # List[List[(N_cls0, H, W), (N_cls0, H, W), ...], List[(N_cls1, H, W), (N_cls1, H, W), ...], ...] len = num of SeparateHead - heatmaps = list(map(list, zip(*heatmaps))) - heatmaps = [torch.stack(hms_) for hms_ in heatmaps] # List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - # Transpose anno_boxes - anno_boxes = list(map(list, zip(*anno_boxes))) - anno_boxes = [torch.stack(anno_boxes_) for anno_boxes_ in anno_boxes] # List[(B, max_objs, 10), (B, max_objs, 10), ...] len = num of SeparateHead - # Transpose inds - inds = list(map(list, zip(*inds))) - inds = [torch.stack(inds_) for inds_ in inds] # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - # Transpose inds - masks = list(map(list, zip(*masks))) - masks = [torch.stack(masks_) for masks_ in masks] # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - return heatmaps, anno_boxes, inds, masks - - def get_targets_single(self, gt_bboxes_3d, gt_labels_3d): - """Generate training targets for a single sample. - - Args: - gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`): Ground truth gt boxes. # (N_gt, 7/9) - gt_labels_3d (torch.Tensor): Labels of boxes. # (N_gt, ) - - Returns: - tuple[list[torch.Tensor]]: Tuple of target including - the following results in order. - - heatmaps: list[torch.Tensor]: Heatmap scores. # List[(N_cls0, H, W), (N_cls1, H, W), ...] - len = num of tasks - - anno_boxes: list[torch.Tensor]: Ground truth boxes. # List[(max_objs, 10), (max_objs, 10), ...] - - inds: list[torch.Tensor]: Indexes indicating the position - of the valid boxes. # List[(max_objs, ), (max_objs, ), ...] - - masks: list[torch.Tensor]: Masks indicating which boxes - are valid. # List[(max_objs, ), (max_objs, ), ...] - """ - device = gt_labels_3d.device - gt_bboxes_3d = torch.cat( - (gt_bboxes_3d.gravity_center, gt_bboxes_3d.tensor[:, 3:]), - dim=1).to(device) # (N_gt, 7/9) - max_objs = self.train_cfg['max_objs'] * self.train_cfg['dense_reg'] - grid_size = torch.tensor(self.train_cfg['grid_size']) # (Dx, Dy, Dz) - pc_range = torch.tensor(self.train_cfg['point_cloud_range']) - voxel_size = torch.tensor(self.train_cfg['voxel_size']) - - feature_map_size = grid_size[:2] // self.train_cfg['out_size_factor'] # (W, H) - - # reorganize the gt_dict by tasks - task_masks = [] - flag = 0 - for class_name in self.class_names: - # class_name: 不同task(SeparateHead)负责检测的类别名. - task_masks.append([ - torch.where(gt_labels_3d == class_name.index(i) + flag) - for i in class_name - ]) - flag += len(class_name) - # task_masks: List[task_mask0, task_mask1, ...] len = number of SeparateHeads - # task_mask: List[((N_gt0, ), ), ((N_gt1, ), ), ...] len = number of class - - task_boxes = [] - task_classes = [] - flag2 = 0 - for idx, mask in enumerate(task_masks): - # mask: 不同task(SeparateHead)的mask, 每个task负责检测一组不同类别的目标. - # List[((N_gt0, ), ), ((N_gt1, ), ), ...], # N_gt_task=N_gt0+N_gt1+..., 表示当前task负责检测的gt_boxes的数量. - task_box = [] - task_class = [] - for m in mask: - task_box.append(gt_bboxes_3d[m]) - # 0 is background for each task, so we need to add 1 here. - task_class.append(gt_labels_3d[m] + 1 - flag2) - task_boxes.append(torch.cat(task_box, axis=0).to(device)) - task_classes.append(torch.cat(task_class).long().to(device)) - flag2 += len(mask) - # 记录不同task负责检测的gt_boxes和gt_classes: - # task_boxes: List[(N_gt_task0, 7/9), (N_gt_task1, 7/9), ...] - # task_classes: List[(N_gt_task0, ), (N_gt_task1, ), ...] - - draw_gaussian = draw_heatmap_gaussian - heatmaps, anno_boxes, inds, masks = [], [], [], [] - - for idx, task_head in enumerate(self.task_heads): - heatmap = gt_bboxes_3d.new_zeros( - (len(self.class_names[idx]), feature_map_size[1], - feature_map_size[0])) # (N_cls, H, W) N_cls表示当前task_head负责检测的类别数目. - - if self.with_velocity: - anno_box = gt_bboxes_3d.new_zeros((max_objs, 10), - dtype=torch.float32) # (max_objs, 10) - else: - anno_box = gt_bboxes_3d.new_zeros((max_objs, 8), - dtype=torch.float32) - - ind = gt_labels_3d.new_zeros((max_objs, ), dtype=torch.int64) # (max_objs, ) - mask = gt_bboxes_3d.new_zeros((max_objs, ), dtype=torch.uint8) # (max_objs, ) - - num_objs = min(task_boxes[idx].shape[0], max_objs) # 当前task_head负责检测的目标. - - for k in range(num_objs): - cls_id = task_classes[idx][k] - 1 # 当前目标的cls_id, cls_id是相对task group内的. - - width = task_boxes[idx][k][3] # dx - length = task_boxes[idx][k][4] # dy - # 当前目标在feature map上的width和length - width = width / voxel_size[0] / self.train_cfg[ - 'out_size_factor'] - length = length / voxel_size[1] / self.train_cfg[ - 'out_size_factor'] - - if width > 0 and length > 0: - # 计算gaussian半径 - radius = gaussian_radius( - (length, width), - min_overlap=self.train_cfg['gaussian_overlap']) - radius = max(self.train_cfg['min_radius'], int(radius)) - - # be really careful for the coordinate system of - # your box annotation. - x, y, z = task_boxes[idx][k][0], task_boxes[idx][k][ - 1], task_boxes[idx][k][2] # 当前目标的中心坐标. - - # 计算gt_box中心点在feature map中对应的位置. - coor_x = ( - x - pc_range[0] - ) / voxel_size[0] / self.train_cfg['out_size_factor'] - coor_y = ( - y - pc_range[1] - ) / voxel_size[1] / self.train_cfg['out_size_factor'] - - center = torch.tensor([coor_x, coor_y], - dtype=torch.float32, - device=device) - center_int = center.to(torch.int32) - - # throw out not in range objects to avoid out of array - # area when creating the heatmap - if not (0 <= center_int[0] < feature_map_size[0] - and 0 <= center_int[1] < feature_map_size[1]): - continue - - # 根据目标中心点在feature map中对应的位置、高斯半径来设置heatmap. - draw_gaussian(heatmap[cls_id], center_int, radius) - - new_idx = k - x, y = center_int[0], center_int[1] - - assert (y * feature_map_size[0] + x < - feature_map_size[0] * feature_map_size[1]) - - # 记录正样本在feature map中的位置. - ind[new_idx] = y * feature_map_size[0] + x - mask[new_idx] = 1 - # TODO: support other outdoor dataset - rot = task_boxes[idx][k][6] - box_dim = task_boxes[idx][k][3:6] - if self.norm_bbox: - box_dim = box_dim.log() - if self.with_velocity: - vx, vy = task_boxes[idx][k][7:] - anno_box[new_idx] = torch.cat([ - center - torch.tensor([x, y], device=device), # tx, ty - z.unsqueeze(0), box_dim, # z, log(dx), log(dy), log(dz) - torch.sin(rot).unsqueeze(0), # sin(rot) - torch.cos(rot).unsqueeze(0), # cos(rot) - vx.unsqueeze(0), # vx - vy.unsqueeze(0) # vy - ]) # [tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy] - else: - anno_box[new_idx] = torch.cat([ - center - torch.tensor([x, y], device=device), - z.unsqueeze(0), box_dim, - torch.sin(rot).unsqueeze(0), - torch.cos(rot).unsqueeze(0) - ]) - - heatmaps.append(heatmap) # append (N_cls, H, W) - anno_boxes.append(anno_box) # append (max_objs, 10) - masks.append(mask) # append (max_objs, ) - inds.append(ind) # append (max_objs, ) - return heatmaps, anno_boxes, inds, masks - - def loss(self, gt_bboxes_3d, gt_labels_3d, preds_dicts, **kwargs): - """Loss function for CenterHead. - - Args: - gt_bboxes_3d (list[:obj:`LiDARInstance3DBoxes`]): Ground - truth gt boxes. # List[(N_gt0, 7/9), (N_gt1, 7/9), ...] - gt_labels_3d (list[torch.Tensor]): Labels of boxes. # List[(N_gt0, ), (N_gt1, ), ...] - preds_dicts (dict): Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - Returns: - dict[str:torch.Tensor]: Loss of heatmap and bbox of each task. - """ - heatmaps, anno_boxes, inds, masks = self.get_targets( - gt_bboxes_3d, gt_labels_3d) - # heatmaps: # List[(B, N_cls0, H, W), (B, N_cls1, H, W), ...] len = num of SeparateHead - # anno_boxes: # List[(B, max_objs, 10), (B, max_objs, 10), ...] len = num of SeparateHead - # inds: # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - # masks: # List[(B, max_objs), (B, max_objs), ...] len = num of SeparateHead - - loss_dict = dict() - if not self.task_specific: - loss_dict['loss'] = 0 - for task_id, preds_dict in enumerate(preds_dicts): - # task_id: SeparateHead idx - # preds_dict: List[dict0, ...] len = num levels, 对于center_point len = 1 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - - # heatmap focal loss - preds_dict[0]['heatmap'] = clip_sigmoid(preds_dict[0]['heatmap']) - num_pos = heatmaps[task_id].eq(1).float().sum().item() - cls_avg_factor = torch.clamp( - reduce_mean(heatmaps[task_id].new_tensor(num_pos)), - min=1).item() - loss_heatmap = self.loss_cls( - preds_dict[0]['heatmap'], # (B, cur_N_cls, H, W) - heatmaps[task_id], # (B, cur_N_cls, H, W) - avg_factor=cls_avg_factor - ) - - # (B, max_objs, 10) 10: (tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy) - target_box = anno_boxes[task_id] - # reconstruct the anno_box from multiple reg heads - preds_dict[0]['anno_box'] = torch.cat( - ( - preds_dict[0]['reg'], - preds_dict[0]['height'], - preds_dict[0]['dim'], - preds_dict[0]['rot'], - preds_dict[0]['vel'], - ), - dim=1, - ) # (B, 10, H, W) 10: (tx, ty, z, log(dx), log(dy), log(dz), sin(rot), cos(rot), vx, vy) - - # Regression loss for dimension, offset, height, rotation - num = masks[task_id].float().sum() # 正样本的数量 - ind = inds[task_id] # (B, max_objs) - pred = preds_dict[0]['anno_box'].permute(0, 2, 3, 1).contiguous() # (B, H, W, 10) - pred = pred.view(pred.size(0), -1, pred.size(3)) # (B, H*W, 10) - pred = self._gather_feat(pred, ind) # (B, max_objs, 10) - # (B, max_objs) --> (B, max_objs, 1) --> (B, max_objs, 10) - mask = masks[task_id].unsqueeze(2).expand_as(target_box).float() - num = torch.clamp( - reduce_mean(target_box.new_tensor(num)), min=1e-4).item() - isnotnan = (~torch.isnan(target_box)).float() - mask *= isnotnan # 只监督mask指定的reg预测. - code_weights = self.train_cfg['code_weights'] - bbox_weights = mask * mask.new_tensor(code_weights) # 在mask基础上,设置box不同属性的权重. (B, max_objs, 10) - if self.task_specific: - name_list = ['xy', 'z', 'whl', 'yaw', 'vel'] - clip_index = [0, 2, 3, 6, 8, 10] - for reg_task_id in range(len(name_list)): - pred_tmp = pred[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - target_box_tmp = target_box[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - bbox_weights_tmp = bbox_weights[..., clip_index[reg_task_id]:clip_index[reg_task_id + 1]] # (B, max_objs, K) - loss_bbox_tmp = self.loss_bbox( - pred_tmp, - target_box_tmp, - bbox_weights_tmp, - avg_factor=(num + 1e-4)) - loss_dict[f'task{task_id}.loss_%s' % - (name_list[reg_task_id])] = loss_bbox_tmp * self.task_specific_weight[reg_task_id] - loss_dict[f'task{task_id}.loss_heatmap'] = loss_heatmap - else: - loss_bbox = self.loss_bbox( - pred, target_box, bbox_weights, avg_factor=num) - loss_dict['loss'] += loss_bbox - loss_dict['loss'] += loss_heatmap - - return loss_dict - - def get_bboxes(self, preds_dicts, img_metas, img=None, rescale=False): - """Generate bboxes from bbox head predictions. - - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - Tuple( - List[ret_dict_task0_level0, ...], len = num_levels = 1 - List[ret_dict_task1_level0, ...], - ... - ), len = SeparateHead的数量, 负责预测指定类别的目标. - - ret_dict: { - reg: (B, 2, H, W) - height: (B, 1, H, W) - dim: (B, 3, H, W) - rot: (B, 2, H, W) - vel: (B, 2, H, W) - heatmap: (B, n_cls, H, W) - } - img_metas (list[dict]): Point cloud and image's meta info. - - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - ret_list: List[p_list0, p_list1, ...] - p_list: List[(N, 9), (N, ), (N, )] - """ - rets = [] - for task_id, preds_dict in enumerate(preds_dicts): - # task_id: SeparateHead idx - # preds_dict: List[dict0, ...] len = num levels, 对于center_point len = 1 - # dict: { - # reg: (B, 2, H, W) - # height: (B, 1, H, W) - # dim: (B, 3, H, W) - # rot: (B, 2, H, W) - # vel: (B, 2, H, W) - # heatmap: (B, n_cls, H, W) - # } - batch_size = preds_dict[0]['heatmap'].shape[0] - batch_heatmap = preds_dict[0]['heatmap'].sigmoid() # (B, n_cls, H, W) - - batch_reg = preds_dict[0]['reg'] # (B, 2, H, W) - batch_hei = preds_dict[0]['height'] # (B, 1, H, W) - - if self.norm_bbox: - batch_dim = torch.exp(preds_dict[0]['dim']) # (B, 3, H, W) - else: - batch_dim = preds_dict[0]['dim'] - - batch_rots = preds_dict[0]['rot'][:, 0].unsqueeze(1) # (B, 1, H, W) - batch_rotc = preds_dict[0]['rot'][:, 1].unsqueeze(1) # (B, 1, H, W) - - if 'vel' in preds_dict[0]: - batch_vel = preds_dict[0]['vel'] # (B, 2, H, W) - else: - batch_vel = None - - temp = self.bbox_coder.decode( - batch_heatmap, - batch_rots, - batch_rotc, - batch_hei, - batch_dim, - batch_vel, - reg=batch_reg, - task_id=task_id) - # temp: List[p_dict0, p_dict1, ...] len=bs - # p_dict = { - # 'bboxes': boxes3d, # (K', 9) - # 'scores': scores, # (K', ) - # 'labels': labels # (K', ) - # } - batch_reg_preds = [box['bboxes'] for box in temp] # List[(K0, 9), (K1, 9), ...] len = bs - batch_cls_preds = [box['scores'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - batch_cls_labels = [box['labels'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - nms_type = self.test_cfg.get('nms_type') - if isinstance(nms_type, list): - nms_type = nms_type[task_id] - if nms_type == 'circle': - ret_task = [] - for i in range(batch_size): - boxes3d = temp[i]['bboxes'] - scores = temp[i]['scores'] - labels = temp[i]['labels'] - centers = boxes3d[:, [0, 1]] - boxes = torch.cat([centers, scores.view(-1, 1)], dim=1) - keep = torch.tensor( - circle_nms( - boxes.detach().cpu().numpy(), - self.test_cfg['min_radius'][task_id], - post_max_size=self.test_cfg['post_max_size']), - dtype=torch.long, - device=boxes.device) - - boxes3d = boxes3d[keep] - scores = scores[keep] - labels = labels[keep] - ret = dict(bboxes=boxes3d, scores=scores, labels=labels) - ret_task.append(ret) - rets.append(ret_task) - else: - rets.append( - self.get_task_detections(batch_cls_preds, batch_reg_preds, - batch_cls_labels, img_metas, - task_id)) - - # rets: List[ret_task0, ret_task1, ...], len = num_tasks - # ret_task: List[p_dict0, p_dict1, ...], len = batch_size - # p_dict: dict{ - # bboxes: (K', 9) - # scores: (K', ) - # labels: (K', ) - # } - - # Merge branches results - num_samples = len(rets[0]) # bs - - ret_list = [] - # 遍历batch, 然后汇总所有task的预测. - for i in range(num_samples): - for k in rets[0][i].keys(): - if k == 'bboxes': - bboxes = torch.cat([ret[i][k] for ret in rets]) # 对于bboxes, 直接拼接即可. - bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - bboxes = img_metas[i]['box_type_3d']( - bboxes, self.bbox_coder.code_size) - elif k == 'scores': - scores = torch.cat([ret[i][k] for ret in rets]) # 对于scores, 直接拼接即可. - elif k == 'labels': - flag = 0 - for j, num_class in enumerate(self.num_classes): # 对于labels, 要进行调整, 因为预测的label是task组内的. - rets[j][i][k] += flag - flag += num_class - labels = torch.cat([ret[i][k].int() for ret in rets]) - ret_list.append([bboxes, scores, labels]) - - # ret_list: List[p_list0, p_list1, ...] - # p_list: List[(N, 9), (N, ), (N, )] - return ret_list - - def _nms(self, heat, kernel=3): - pad = (kernel - 1) // 2 - - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=pad) - keep = (hmax == heat).float() - return heat * keep - - def get_centers(self, preds_dicts, img_metas, img=None, rescale=False): - rets = [] - for task_id, preds_dict in enumerate(preds_dicts): - batch_size = preds_dict[0]['heatmap'].shape[0] - batch_heatmap = preds_dict[0]['heatmap'].sigmoid() # (B, n_cls, H, W) - - batch_reg = preds_dict[0]['reg'] # (B, 2, H, W) - batch_hei = preds_dict[0]['height'] # (B, 1, H, W) - - batch_heatmap = self._nms(batch_heatmap) - temp = self.bbox_coder.center_decode( - batch_heatmap, - batch_hei, - reg=batch_reg, - task_id=task_id) - - batch_reg_preds = [box['centers'] for box in temp] # List[(K0, 9), (K1, 9), ...] len = bs - batch_cls_preds = [box['scores'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - batch_cls_labels = [box['labels'] for box in temp] # List[(K0, ), (K1, ), ...] len = bs - - ret_list = [batch_reg_preds, batch_cls_preds, batch_cls_labels] - return ret_list - - def get_task_detections(self, batch_cls_preds, - batch_reg_preds, batch_cls_labels, img_metas, - task_id): - """Rotate nms for each task. - - Args: - batch_cls_preds (list[torch.Tensor]): Prediction score with the - shape of [N]. # List[(K0, ), (K1, ), ...] len = bs - batch_reg_preds (list[torch.Tensor]): Prediction bbox with the - shape of [N, 9]. # List[(K0, 9), (K1, 9), ...] len = bs - batch_cls_labels (list[torch.Tensor]): Prediction label with the - shape of [N]. # List[(K0, ), (K1, ), ...] len = bs - img_metas (list[dict]): Meta information of each sample. - - Returns: - list[dict[str: torch.Tensor]]: contains the following keys: - -bboxes (torch.Tensor): Prediction bboxes after nms with the - shape of [N, 9]. - -scores (torch.Tensor): Prediction scores after nms with the - shape of [N]. - -labels (torch.Tensor): Prediction labels after nms with the - shape of [N]. - - List[p_dict0, p_dict1, ...] len = batch_size - p_dict: dict{ - bboxes: (K', 9) - scores: (K', ) - labels: (K', ) - } - """ - predictions_dicts = [] - # 遍历不同batch的topK预测输出. - for i, (box_preds, cls_preds, cls_labels) in enumerate( - zip(batch_reg_preds, batch_cls_preds, batch_cls_labels)): - # box_preds: (K, 9) - # cls_preds: (K, ) - # cls_labels: (K, ) - default_val = [1.0 for _ in range(len(self.task_heads))] - factor = self.test_cfg.get('nms_rescale_factor', - default_val)[task_id] - if isinstance(factor, list): - # List[float, float, ..] len = 当前task负责预测的类别数. - # 对于box_preds, 使用其对应的factor进行缩放, 一般是放大小目标,缩小大目标. - for cid in range(len(factor)): - box_preds[cls_labels == cid, 3:6] = \ - box_preds[cls_labels == cid, 3:6] * factor[cid] - else: - box_preds[:, 3:6] = box_preds[:, 3:6] * factor - - # Apply NMS in birdeye view - top_labels = cls_labels.long() # (K, ) - top_scores = cls_preds.squeeze(-1) if cls_preds.shape[0] > 1 \ - else cls_preds # (K, ) - - if top_scores.shape[0] != 0: - boxes_for_nms = img_metas[i]['box_type_3d']( - box_preds[:, :], self.bbox_coder.code_size).bev # (K, 5) (x, y, dx, dy, yaw) - # the nms in 3d detection just remove overlap boxes. - if isinstance(self.test_cfg['nms_thr'], list): - nms_thresh = self.test_cfg['nms_thr'][task_id] - else: - nms_thresh = self.test_cfg['nms_thr'] - - selected = nms_bev( - boxes_for_nms, - top_scores, - thresh=nms_thresh, - pre_max_size=self.test_cfg['pre_max_size'], - post_max_size=self.test_cfg['post_max_size'], - xyxyr2xywhr=False, - ) - else: - selected = [] - - # NMS后再根据factor缩放回原来的尺寸. - if isinstance(factor, list): - for cid in range(len(factor)): - box_preds[top_labels == cid, 3:6] = \ - box_preds[top_labels == cid, 3:6] / factor[cid] - else: - box_preds[:, 3:6] = box_preds[:, 3:6] / factor - - # if selected is not None: - selected_boxes = box_preds[selected] # (K', 9) - selected_labels = top_labels[selected] # (K', ) - selected_scores = top_scores[selected] # (K', ) - - # finally generate predictions. - if selected_boxes.shape[0] != 0: - predictions_dict = dict( - bboxes=selected_boxes, - scores=selected_scores, - labels=selected_labels) - else: - dtype = batch_reg_preds[0].dtype - device = batch_reg_preds[0].device - predictions_dict = dict( - bboxes=torch.zeros([0, self.bbox_coder.code_size], - dtype=dtype, - device=device), - scores=torch.zeros([0], dtype=dtype, device=device), - labels=torch.zeros([0], - dtype=top_labels.dtype, - device=device)) - - predictions_dicts.append(predictions_dict) - return predictions_dicts - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_occ_head.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_occ_head.py deleted file mode 100644 index 7da3fd4c52ad438cd9f8b0fcd0cd72beaf90a8b4..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/dense_heads/bev_occ_head.py +++ /dev/null @@ -1,404 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import torch -from torch import nn -from mmcv.cnn import ConvModule -from mmcv.runner import BaseModule -import numpy as np -from mmdet3d.models.builder import HEADS, build_loss -from ..losses.semkitti_loss import sem_scal_loss, geo_scal_loss -from ..losses.lovasz_softmax import lovasz_softmax - - -nusc_class_frequencies = np.array([ - 944004, - 1897170, - 152386, - 2391677, - 16957802, - 724139, - 189027, - 2074468, - 413451, - 2384460, - 5916653, - 175883646, - 4275424, - 51393615, - 61411620, - 105975596, - 116424404, - 1892500630 -]) - - -@HEADS.register_module() -class BEVOCCHead3D(BaseModule): - def __init__(self, - in_dim=32, - out_dim=32, - use_mask=True, - num_classes=18, - use_predicter=True, - class_balance=False, - loss_occ=None - ): - super(BEVOCCHead3D, self).__init__() - self.out_dim = 32 - out_channels = out_dim if use_predicter else num_classes - self.final_conv = ConvModule( - in_dim, - out_channels, - kernel_size=3, - stride=1, - padding=1, - bias=True, - conv_cfg=dict(type='Conv3d') - ) - self.use_predicter = use_predicter - if use_predicter: - self.predicter = nn.Sequential( - nn.Linear(self.out_dim, self.out_dim*2), - nn.Softplus(), - nn.Linear(self.out_dim*2, num_classes), - ) - - self.num_classes = num_classes - self.use_mask = use_mask - self.class_balance = class_balance - if self.class_balance: - class_weights = torch.from_numpy(1 / np.log(nusc_class_frequencies[:num_classes] + 0.001)) - self.cls_weights = class_weights - loss_occ['class_weight'] = class_weights - - self.loss_occ = build_loss(loss_occ) - - def forward(self, img_feats): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) - - Returns: - - """ - # (B, C, Dz, Dy, Dx) --> (B, C, Dz, Dy, Dx) --> (B, Dx, Dy, Dz, C) - occ_pred = self.final_conv(img_feats).permute(0, 4, 3, 2, 1) - if self.use_predicter: - # (B, Dx, Dy, Dz, C) --> (B, Dx, Dy, Dz, 2*C) --> (B, Dx, Dy, Dz, n_cls) - occ_pred = self.predicter(occ_pred) - - return occ_pred - - def loss(self, occ_pred, voxel_semantics, mask_camera): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, n_cls) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - - """ - loss = dict() - voxel_semantics = voxel_semantics.long() - if self.use_mask: - mask_camera = mask_camera.to(torch.int32) # (B, Dx, Dy, Dz) - # (B, Dx, Dy, Dz) --> (B*Dx*Dy*Dz, ) - voxel_semantics = voxel_semantics.reshape(-1) - # (B, Dx, Dy, Dz, n_cls) --> (B*Dx*Dy*Dz, n_cls) - preds = occ_pred.reshape(-1, self.num_classes) - # (B, Dx, Dy, Dz) --> (B*Dx*Dy*Dz, ) - mask_camera = mask_camera.reshape(-1) - - if self.class_balance: - valid_voxels = voxel_semantics[mask_camera.bool()] - num_total_samples = 0 - for i in range(self.num_classes): - num_total_samples += (valid_voxels == i).sum() * self.cls_weights[i] - else: - num_total_samples = mask_camera.sum() - - loss_occ = self.loss_occ( - preds, # (B*Dx*Dy*Dz, n_cls) - voxel_semantics, # (B*Dx*Dy*Dz, ) - mask_camera, # (B*Dx*Dy*Dz, ) - avg_factor=num_total_samples - ) - else: - voxel_semantics = voxel_semantics.reshape(-1) - preds = occ_pred.reshape(-1, self.num_classes) - - if self.class_balance: - num_total_samples = 0 - for i in range(self.num_classes): - num_total_samples += (voxel_semantics == i).sum() * self.cls_weights[i] - else: - num_total_samples = len(voxel_semantics) - - loss_occ = self.loss_occ( - preds, - voxel_semantics, - avg_factor=num_total_samples - ) - - loss['loss_occ'] = loss_occ - return loss - - def get_occ(self, occ_pred, img_metas=None): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, C) - img_metas: - - Returns: - List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - occ_score = occ_pred.softmax(-1) # (B, Dx, Dy, Dz, C) - occ_res = occ_score.argmax(-1) # (B, Dx, Dy, Dz) - occ_res = occ_res.cpu().numpy().astype(np.uint8) # (B, Dx, Dy, Dz) - return list(occ_res) - - -@HEADS.register_module() -class BEVOCCHead2D(BaseModule): - def __init__(self, - in_dim=256, - out_dim=256, - Dz=16, - use_mask=True, - num_classes=18, - use_predicter=True, - class_balance=False, - loss_occ=None, - ): - super(BEVOCCHead2D, self).__init__() - self.in_dim = in_dim - self.out_dim = out_dim - self.Dz = Dz - out_channels = out_dim if use_predicter else num_classes * Dz - self.final_conv = ConvModule( - self.in_dim, - out_channels, - kernel_size=3, - stride=1, - padding=1, - bias=True, - conv_cfg=dict(type='Conv2d') - ) - self.use_predicter = use_predicter - if use_predicter: - self.predicter = nn.Sequential( - nn.Linear(self.out_dim, self.out_dim * 2), - nn.Softplus(), - nn.Linear(self.out_dim * 2, num_classes * Dz), - ) - - self.use_mask = use_mask - self.num_classes = num_classes - - self.class_balance = class_balance - if self.class_balance: - class_weights = torch.from_numpy(1 / np.log(nusc_class_frequencies[:num_classes] + 0.001)) - self.cls_weights = class_weights - loss_occ['class_weight'] = class_weights # ce loss - self.loss_occ = build_loss(loss_occ) - - def forward(self, img_feats): - """ - Args: - img_feats: (B, C, Dy, Dx) - - Returns: - - """ - # (B, C, Dy, Dx) --> (B, C, Dy, Dx) --> (B, Dx, Dy, C) - occ_pred = self.final_conv(img_feats).permute(0, 3, 2, 1) - bs, Dx, Dy = occ_pred.shape[:3] - if self.use_predicter: - # (B, Dx, Dy, C) --> (B, Dx, Dy, 2*C) --> (B, Dx, Dy, Dz*n_cls) - occ_pred = self.predicter(occ_pred) - occ_pred = occ_pred.view(bs, Dx, Dy, self.Dz, self.num_classes) - - return occ_pred - - def loss(self, occ_pred, voxel_semantics, mask_camera): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, n_cls) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - - """ - loss = dict() - voxel_semantics = voxel_semantics.long() - if self.use_mask: - mask_camera = mask_camera.to(torch.int32) # (B, Dx, Dy, Dz) - # (B, Dx, Dy, Dz) --> (B*Dx*Dy*Dz, ) - voxel_semantics = voxel_semantics.reshape(-1) - # (B, Dx, Dy, Dz, n_cls) --> (B*Dx*Dy*Dz, n_cls) - preds = occ_pred.reshape(-1, self.num_classes) - # (B, Dx, Dy, Dz) --> (B*Dx*Dy*Dz, ) - mask_camera = mask_camera.reshape(-1) - - if self.class_balance: - valid_voxels = voxel_semantics[mask_camera.bool()] - num_total_samples = 0 - for i in range(self.num_classes): - num_total_samples += (valid_voxels == i).sum() * self.cls_weights[i] - else: - num_total_samples = mask_camera.sum() - - loss_occ = self.loss_occ( - preds, # (B*Dx*Dy*Dz, n_cls) - voxel_semantics, # (B*Dx*Dy*Dz, ) - mask_camera, # (B*Dx*Dy*Dz, ) - avg_factor=num_total_samples - ) - loss['loss_occ'] = loss_occ - else: - voxel_semantics = voxel_semantics.reshape(-1) - preds = occ_pred.reshape(-1, self.num_classes) - - if self.class_balance: - num_total_samples = 0 - for i in range(self.num_classes): - num_total_samples += (voxel_semantics == i).sum() * self.cls_weights[i] - else: - num_total_samples = len(voxel_semantics) - - loss_occ = self.loss_occ( - preds, - voxel_semantics, - avg_factor=num_total_samples - ) - - loss['loss_occ'] = loss_occ - return loss - - def get_occ(self, occ_pred, img_metas=None): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, C) - img_metas: - - Returns: - List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - occ_score = occ_pred.softmax(-1) # (B, Dx, Dy, Dz, C) - occ_res = occ_score.argmax(-1) # (B, Dx, Dy, Dz) - occ_res = occ_res.cpu().numpy().astype(np.uint8) # (B, Dx, Dy, Dz) - return list(occ_res) - - -@HEADS.register_module() -class BEVOCCHead2D_V2(BaseModule): # Use stronger loss setting - def __init__(self, - in_dim=256, - out_dim=256, - Dz=16, - use_mask=True, - num_classes=18, - use_predicter=True, - class_balance=False, - loss_occ=None, - ): - super(BEVOCCHead2D_V2, self).__init__() - self.in_dim = in_dim - self.out_dim = out_dim - self.Dz = Dz - - # voxel-level prediction - self.occ_convs = nn.ModuleList() - self.final_conv = ConvModule( - in_dim, - self.out_dim, - kernel_size=3, - stride=1, - padding=1, - bias=True, - conv_cfg=dict(type='Conv2d') - ) - self.use_predicter = use_predicter - if use_predicter: - self.predicter = nn.Sequential( - nn.Linear(self.out_dim, self.out_dim * 2), - nn.Softplus(), - nn.Linear(self.out_dim * 2, num_classes * Dz), - ) - - self.use_mask = use_mask - self.num_classes = num_classes - - self.class_balance = class_balance - if self.class_balance: - class_weights = torch.from_numpy(1 / np.log(nusc_class_frequencies[:num_classes] + 0.001)) - self.cls_weights = class_weights - self.loss_occ = build_loss(loss_occ) - - def forward(self, img_feats): - """ - Args: - img_feats: (B, C, Dy=200, Dx=200) - img_feats: [(B, C, 100, 100), (B, C, 50, 50), (B, C, 25, 25)] if ms - Returns: - - """ - # (B, C, Dy, Dx) --> (B, C, Dy, Dx) --> (B, Dx, Dy, C) - occ_pred = self.final_conv(img_feats).permute(0, 3, 2, 1) - bs, Dx, Dy = occ_pred.shape[:3] - if self.use_predicter: - # (B, Dx, Dy, C) --> (B, Dx, Dy, 2*C) --> (B, Dx, Dy, Dz*n_cls) - occ_pred = self.predicter(occ_pred) - occ_pred = occ_pred.view(bs, Dx, Dy, self.Dz, self.num_classes) - - return occ_pred - - def loss(self, occ_pred, voxel_semantics, mask_camera): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, n_cls) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - - """ - loss = dict() - voxel_semantics = voxel_semantics.long() # (B, Dx, Dy, Dz) - preds = occ_pred.permute(0, 4, 1, 2, 3).contiguous() # (B, n_cls, Dx, Dy, Dz) - loss_occ = self.loss_occ( - preds, - voxel_semantics, - weight=self.cls_weights.to(preds), - ) * 100.0 - loss['loss_occ'] = loss_occ - loss['loss_voxel_sem_scal'] = sem_scal_loss(preds, voxel_semantics) - loss['loss_voxel_geo_scal'] = geo_scal_loss(preds, voxel_semantics, non_empty_idx=17) - loss['loss_voxel_lovasz'] = lovasz_softmax(torch.softmax(preds, dim=1), voxel_semantics) - - return loss - - def get_occ(self, occ_pred, img_metas=None): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, C) - img_metas: - - Returns: - List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - occ_score = occ_pred.softmax(-1) # (B, Dx, Dy, Dz, C) - occ_res = occ_score.argmax(-1) # (B, Dx, Dy, Dz) - occ_res = occ_res.cpu().numpy().astype(np.uint8) # (B, Dx, Dy, Dz) - return list(occ_res) - - def get_occ_gpu(self, occ_pred, img_metas=None): - """ - Args: - occ_pred: (B, Dx, Dy, Dz, C) - img_metas: - - Returns: - List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - occ_score = occ_pred.softmax(-1) # (B, Dx, Dy, Dz, C) - occ_res = occ_score.argmax(-1).int() # (B, Dx, Dy, Dz) - return list(occ_res) \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__init__.py deleted file mode 100644 index 4a67b22f9cbe4ac6e802cfa3c4580d0f81a93037..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from .bevdet import BEVDet -from .bevdepth import BEVDepth -from .bevdet4d import BEVDet4D -from .bevdepth4d import BEVDepth4D -from .bevstereo4d import BEVStereo4D - -from .bevdet_occ import BEVDetOCC, BEVDepthOCC, BEVDepth4DOCC, BEVStereo4DOCC, BEVDepth4DPano, BEVDepthPano, BEVDepthPanoTRT - - -__all__ = ['BEVDet', 'BEVDepth', 'BEVDet4D', 'BEVDepth4D', 'BEVStereo4D', 'BEVDetOCC', 'BEVDepthOCC', - 'BEVDepth4DOCC', 'BEVStereo4DOCC', 'BEVDepthPano', 'BEVDepth4DPano', 'BEVDepthPanoTRT'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 685ac0c64fcc114712bff29e0d1b6ef9289b89c5..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth.cpython-310.pyc deleted file mode 100644 index b430244aae6932dca6e766f1882b152a43ae02b3..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth4d.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth4d.cpython-310.pyc deleted file mode 100644 index e5ac2b095e1e97881966f88c103e498409721ba6..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdepth4d.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet.cpython-310.pyc deleted file mode 100644 index 613bb4ff07bbc570c54ac086a0722fcc319de2d5..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet4d.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet4d.cpython-310.pyc deleted file mode 100644 index 3bc54f46450e3b9a5822542f976880a14db00574..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet4d.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet_occ.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet_occ.cpython-310.pyc deleted file mode 100644 index d7c9e2f3e046d85868e0858e4b305554f797391b..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevdet_occ.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevstereo4d.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevstereo4d.cpython-310.pyc deleted file mode 100644 index f30ad61a6c5bfb65f27df5cb76a87b8e09e71e9e..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/__pycache__/bevstereo4d.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth.py deleted file mode 100644 index 6c5fab2dd7496c059267985e05c0cfd9a2c43848..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth.py +++ /dev/null @@ -1,258 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn.functional as F -from mmcv.runner import force_fp32 - -from mmdet3d.models import DETECTORS -from .bevdet import BEVDet -from mmdet3d.models import builder - - -@DETECTORS.register_module() -class BEVDepth(BEVDet): - def __init__(self, img_backbone, img_neck, img_view_transformer, img_bev_encoder_backbone, img_bev_encoder_neck, - pts_bbox_head=None, **kwargs): - super(BEVDepth, self).__init__(img_backbone=img_backbone, - img_neck=img_neck, - img_view_transformer=img_view_transformer, - img_bev_encoder_backbone=img_bev_encoder_backbone, - img_bev_encoder_neck=img_bev_encoder_neck, - pts_bbox_head=pts_bbox_head - ) - - def image_encoder(self, img, stereo=False): - """ - Args: - img: (B, N, 3, H, W) - stereo: bool - Returns: - x: (B, N, C, fH, fW) - stereo_feat: (B*N, C_stereo, fH_stereo, fW_stereo) / None - """ - imgs = img - B, N, C, imH, imW = imgs.shape - imgs = imgs.view(B * N, C, imH, imW) - x = self.img_backbone(imgs) - stereo_feat = None - if stereo: - stereo_feat = x[0] - x = x[1:] - if self.with_img_neck: - x = self.img_neck(x) - if type(x) in [list, tuple]: - x = x[0] - _, output_dim, ouput_H, output_W = x.shape - x = x.view(B, N, output_dim, ouput_H, output_W) - return x, stereo_feat - - @force_fp32() - def bev_encoder(self, x): - """ - Args: - x: (B, C, Dy, Dx) - Returns: - x: (B, C', 2*Dy, 2*Dx) - """ - x = self.img_bev_encoder_backbone(x) - x = self.img_bev_encoder_neck(x) - if type(x) in [list, tuple]: - x = x[0] - return x - - def prepare_inputs(self, inputs): - # split the inputs into each frame - assert len(inputs) == 7 - B, N, C, H, W = inputs[0].shape - imgs, sensor2egos, ego2globals, intrins, post_rots, post_trans, bda = \ - inputs - - sensor2egos = sensor2egos.view(B, N, 4, 4) - ego2globals = ego2globals.view(B, N, 4, 4) - - # calculate the transformation from adj sensor to key ego - keyego2global = ego2globals[:, 0, ...].unsqueeze(1) # (B, 1, 4, 4) - global2keyego = torch.inverse(keyego2global.double()) # (B, 1, 4, 4) - sensor2keyegos = \ - global2keyego @ ego2globals.double() @ sensor2egos.double() # (B, N_views, 4, 4) - sensor2keyegos = sensor2keyegos.float() - - return [imgs, sensor2keyegos, ego2globals, intrins, - post_rots, post_trans, bda] - - def extract_img_feat(self, img_inputs, img_metas, **kwargs): - """ Extract features of images. - img_inputs: - imgs: (B, N_views, 3, H, W) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - Returns: - x: [(B, C', H', W'), ] - depth: (B*N, D, fH, fW) - """ - imgs, sensor2keyegos, ego2globals, intrins, post_rots, post_trans, bda = self.prepare_inputs(img_inputs) - x, _ = self.image_encoder(imgs) # x: (B, N, C, fH, fW) - mlp_input = self.img_view_transformer.get_mlp_input( - sensor2keyegos, ego2globals, intrins, post_rots, post_trans, bda) # (B, N_views, 27) - - x, depth = self.img_view_transformer([x, sensor2keyegos, ego2globals, intrins, post_rots, - post_trans, bda, mlp_input]) - # x: (B, C, Dy, Dx) - # depth: (B*N, D, fH, fW) - x = self.bev_encoder(x) - return [x], depth - - def extract_feat(self, points, img_inputs, img_metas, **kwargs): - """Extract features from images and points.""" - """ - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_inputs: - imgs: (B, N_views, 3, H, W) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - """ - img_feats, depth = self.extract_img_feat(img_inputs, img_metas, **kwargs) - pts_feats = None - return img_feats, pts_feats, depth - - def forward_train(self, - points=None, - img_inputs=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - img_metas=None, - gt_bboxes=None, - gt_labels=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_inputs: - imgs: (B, N_views, 3, H, W) # N_views = 6 * (N_history + 1) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses = dict(loss_depth=loss_depth) - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore) - losses.update(losses_pts) - return losses - - def forward_test(self, - points=None, - img_inputs=None, - img_metas=None, - **kwargs): - """ - Args: - points (list[torch.Tensor]): the outer list indicates test-time - augmentations and inner torch.Tensor should have a shape NxC, - which contains all points in the batch. - img_metas (list[list[dict]]): the outer list indicates test-time - augs (multiscale, flip, etc.) and the inner list indicates - images in a batch - img (list[torch.Tensor], optional): the outer - list indicates test-time augmentations and inner - torch.Tensor should have a shape NxCxHxW, which contains - all images in the batch. Defaults to None. - """ - for var, name in [(img_inputs, 'img_inputs'), - (img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - - num_augs = len(img_inputs) - if num_augs != len(img_metas): - raise ValueError( - 'num of augmentations ({}) != num of image meta ({})'.format( - len(img_inputs), len(img_metas))) - - if not isinstance(img_inputs[0][0], list): - img_inputs = [img_inputs] if img_inputs is None else img_inputs - points = [points] if points is None else points - return self.simple_test(points[0], img_metas[0], img_inputs[0], - **kwargs) - else: - return self.aug_test(None, img_metas[0], img_inputs[0], **kwargs) - - def aug_test(self, points, img_metas, img=None, rescale=False): - """Test function without augmentaiton.""" - assert False - - def simple_test(self, - points, - img_metas, - img_inputs=None, - rescale=False, - **kwargs): - """Test function without augmentaiton. - Returns: - bbox_list: List[dict0, dict1, ...] len = bs - dict: { - 'pts_bbox': dict: { - 'boxes_3d': (N, 9) - 'scores_3d': (N, ) - 'labels_3d': (N, ) - } - } - """ - img_feats, _, _ = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - bbox_list = [dict() for _ in range(len(img_metas))] - bbox_pts = self.simple_test_pts(img_feats, img_metas, rescale=rescale) - # bbox_pts: List[dict0, dict1, ...], len = batch_size - # dict: { - # 'boxes_3d': (N, 9) - # 'scores_3d': (N, ) - # 'labels_3d': (N, ) - # } - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return bbox_list - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - img_feats, _, _ = self.extract_feat( - points, img=img_inputs, img_metas=img_metas, **kwargs) - assert self.with_pts_bbox - outs = self.pts_bbox_head(img_feats) - return outs \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth4d.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth4d.py deleted file mode 100644 index 3c34adfe002d037bd61fb630fcebdc314c3447d7..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdepth4d.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn.functional as F -from mmcv.runner import force_fp32 - -from mmdet3d.models import DETECTORS -from mmdet3d.models import builder -from .bevdet4d import BEVDet4D - - -@DETECTORS.register_module() -class BEVDepth4D(BEVDet4D): - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses = dict(loss_depth=loss_depth) - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore) - losses.update(losses_pts) - return losses \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet.py deleted file mode 100644 index 56b66c99ad694acd21f97f65be19bd767695ca8b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet.py +++ /dev/null @@ -1,250 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn.functional as F -from mmcv.runner import force_fp32 - -from mmdet3d.models import DETECTORS -from mmdet3d.models import CenterPoint -from mmdet3d.models import builder - - -@DETECTORS.register_module() -class BEVDet(CenterPoint): - def __init__(self, img_backbone, img_neck, img_view_transformer, img_bev_encoder_backbone, img_bev_encoder_neck, - pts_bbox_head=None, **kwargs): - super(BEVDet, self).__init__(img_backbone=img_backbone, img_neck=img_neck, pts_bbox_head=pts_bbox_head, - **kwargs) - self.img_view_transformer = builder.build_neck(img_view_transformer) - self.img_bev_encoder_backbone = builder.build_backbone(img_bev_encoder_backbone) - self.img_bev_encoder_neck = builder.build_neck(img_bev_encoder_neck) - @torch.compile - def image_encoder(self, img, stereo=False): - """ - Args: - img: (B, N, 3, H, W) - stereo: bool - Returns: - x: (B, N, C, fH, fW) - stereo_feat: (B*N, C_stereo, fH_stereo, fW_stereo) / None - """ - imgs = img - B, N, C, imH, imW = imgs.shape - imgs = imgs.view(B * N, C, imH, imW) - x = self.img_backbone(imgs) - stereo_feat = None - if stereo: - stereo_feat = x[0] - x = x[1:] - if self.with_img_neck: - x = self.img_neck(x) - if type(x) in [list, tuple]: - x = x[0] - _, output_dim, ouput_H, output_W = x.shape - x = x.view(B, N, output_dim, ouput_H, output_W) - return x, stereo_feat - @torch.compile - @force_fp32() - def bev_encoder(self, x): - """ - Args: - x: (B, C, Dy, Dx) - Returns: - x: (B, C', 2*Dy, 2*Dx) - """ - x = self.img_bev_encoder_backbone(x) - x = self.img_bev_encoder_neck(x) - if type(x) in [list, tuple]: - x = x[0] - return x - @torch.compile - def prepare_inputs(self, inputs): - # split the inputs into each frame - assert len(inputs) == 7 - B, N, C, H, W = inputs[0].shape - imgs, sensor2egos, ego2globals, intrins, post_rots, post_trans, bda = \ - inputs - - sensor2egos = sensor2egos.view(B, N, 4, 4) - ego2globals = ego2globals.view(B, N, 4, 4) - - # calculate the transformation from adj sensor to key ego - keyego2global = ego2globals[:, 0, ...].unsqueeze(1) # (B, 1, 4, 4) - global2keyego = torch.inverse(keyego2global.double()) # (B, 1, 4, 4) - sensor2keyegos = \ - global2keyego @ ego2globals.double() @ sensor2egos.double() # (B, N_views, 4, 4) - sensor2keyegos = sensor2keyegos.float() - - return [imgs, sensor2keyegos, ego2globals, intrins, - post_rots, post_trans, bda] - - def extract_img_feat(self, img_inputs, img_metas, **kwargs): - """ Extract features of images. - img_inputs: - imgs: (B, N_views, 3, H, W) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - Returns: - x: [(B, C', H', W'), ] - depth: (B*N, D, fH, fW) - """ - img_inputs = self.prepare_inputs(img_inputs) - x, _ = self.image_encoder(img_inputs[0]) # x: (B, N, C, fH, fW) - x, depth = self.img_view_transformer([x] + img_inputs[1:7]) - # x: (B, C, Dy, Dx) - # depth: (B*N, D, fH, fW) - x = self.bev_encoder(x) - return [x], depth - - def extract_feat(self, points, img_inputs, img_metas, **kwargs): - """Extract features from images and points.""" - """ - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_inputs: - imgs: (B, N_views, 3, H, W) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - """ - img_feats, depth = self.extract_img_feat(img_inputs, img_metas, **kwargs) - pts_feats = None - return img_feats, pts_feats, depth - - def forward_train(self, - points=None, - img_inputs=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - img_metas=None, - gt_bboxes=None, - gt_labels=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_inputs: - imgs: (B, N_views, 3, H, W) # N_views = 6 * (N_history + 1) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - img_feats, pts_feats, _ = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - losses = dict() - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore) - losses.update(losses_pts) - return losses - - def forward_test(self, - points=None, - img_inputs=None, - img_metas=None, - **kwargs): - """ - Args: - points (list[torch.Tensor]): the outer list indicates test-time - augmentations and inner torch.Tensor should have a shape NxC, - which contains all points in the batch. - img_metas (list[list[dict]]): the outer list indicates test-time - augs (multiscale, flip, etc.) and the inner list indicates - images in a batch - img (list[torch.Tensor], optional): the outer - list indicates test-time augmentations and inner - torch.Tensor should have a shape NxCxHxW, which contains - all images in the batch. Defaults to None. - """ - for var, name in [(img_inputs, 'img_inputs'), - (img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - - num_augs = len(img_inputs) - if num_augs != len(img_metas): - raise ValueError( - 'num of augmentations ({}) != num of image meta ({})'.format( - len(img_inputs), len(img_metas))) - - if not isinstance(img_inputs[0][0], list): - img_inputs = [img_inputs] if img_inputs is None else img_inputs - points = [points] if points is None else points - return self.simple_test(points[0], img_metas[0], img_inputs[0], - **kwargs) - else: - return self.aug_test(None, img_metas[0], img_inputs[0], **kwargs) - - def aug_test(self, points, img_metas, img=None, rescale=False): - """Test function without augmentaiton.""" - assert False - - def simple_test(self, - points, - img_metas, - img_inputs=None, - rescale=False, - **kwargs): - """Test function without augmentaiton. - Returns: - bbox_list: List[dict0, dict1, ...] len = bs - dict: { - 'pts_bbox': dict: { - 'boxes_3d': (N, 9) - 'scores_3d': (N, ) - 'labels_3d': (N, ) - } - } - """ - img_feats, _, _ = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - bbox_list = [dict() for _ in range(len(img_metas))] - bbox_pts = self.simple_test_pts(img_feats, img_metas, rescale=rescale) - # bbox_pts: List[dict0, dict1, ...], len = batch_size - # dict: { - # 'boxes_3d': (N, 9) - # 'scores_3d': (N, ) - # 'labels_3d': (N, ) - # } - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return bbox_list - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - img_feats, _, _ = self.extract_feat( - points, img=img_inputs, img_metas=img_metas, **kwargs) - assert self.with_pts_bbox - outs = self.pts_bbox_head(img_feats) - return outs diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet4d.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet4d.py deleted file mode 100644 index 9d3139c1adb39825f25151ff76c5945adb8e1712..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet4d.py +++ /dev/null @@ -1,387 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn.functional as F -from mmcv.runner import force_fp32 - -from mmdet3d.models import DETECTORS -from mmdet3d.models import builder -from .bevdet import BEVDet - - -@DETECTORS.register_module() -class BEVDet4D(BEVDet): - r"""BEVDet4D paradigm for multi-camera 3D object detection. - - Please refer to the `paper `_ - - Args: - pre_process (dict | None): Configuration dict of BEV pre-process net. - align_after_view_transfromation (bool): Whether to align the BEV - Feature after view transformation. By default, the BEV feature of - the previous frame is aligned during the view transformation. - num_adj (int): Number of adjacent frames. - with_prev (bool): Whether to set the BEV feature of previous frame as - all zero. By default, False. - """ - def __init__(self, - pre_process=None, - align_after_view_transfromation=False, - num_adj=1, - with_prev=True, - **kwargs): - super(BEVDet4D, self).__init__(**kwargs) - self.pre_process = pre_process is not None - if self.pre_process: - self.pre_process_net = builder.build_backbone(pre_process) - - self.align_after_view_transfromation = align_after_view_transfromation - self.num_frame = num_adj + 1 - - self.with_prev = with_prev - self.grid = None - - def gen_grid(self, input, sensor2keyegos, bda, bda_adj=None): - """ - Args: - input: (B, C, Dy, Dx) bev_feat - sensor2keyegos: List[ - curr_sensor-->key_ego: (B, N_views, 4, 4) - prev_sensor-->key_ego: (B, N_views, 4, 4) - ] - bda: (B, 3, 3) - bda_adj: None - Returns: - grid: (B, Dy, Dx, 2) - """ - B, C, H, W = input.shape - v = sensor2keyegos[0].shape[0] # N_views - if self.grid is None: - # generate grid - xs = torch.linspace( - 0, W - 1, W, dtype=input.dtype, - device=input.device).view(1, W).expand(H, W) # (Dy, Dx) - ys = torch.linspace( - 0, H - 1, H, dtype=input.dtype, - device=input.device).view(H, 1).expand(H, W) # (Dy, Dx) - grid = torch.stack((xs, ys, torch.ones_like(xs)), -1) # (Dy, Dx, 3) 3: (x, y, 1) - self.grid = grid - else: - grid = self.grid - # (Dy, Dx, 3) --> (1, Dy, Dx, 3) --> (B, Dy, Dx, 3) --> (B, Dy, Dx, 3, 1)) 3: (grid_x, grid_y, 1) - grid = grid.view(1, H, W, 3).expand(B, H, W, 3).view(B, H, W, 3, 1) - - curr_sensor2keyego = sensor2keyegos[0][:, 0:1, :, :] # (B, 1, 4, 4) - prev_sensor2keyego = sensor2keyegos[1][:, 0:1, :, :] # (B, 1, 4, 4) - - # add bev data augmentation - bda_ = torch.zeros((B, 1, 4, 4), dtype=grid.dtype).to(grid) # (B, 1, 4, 4) - bda_[:, :, :3, :3] = bda.unsqueeze(1) - bda_[:, :, 3, 3] = 1 - curr_sensor2keyego = bda_.matmul(curr_sensor2keyego) # (B, 1, 4, 4) - if bda_adj is not None: - bda_ = torch.zeros((B, 1, 4, 4), dtype=grid.dtype).to(grid) - bda_[:, :, :3, :3] = bda_adj.unsqueeze(1) - bda_[:, :, 3, 3] = 1 - prev_sensor2keyego = bda_.matmul(prev_sensor2keyego) # (B, 1, 4, 4) - - # transformation from current ego frame to adjacent ego frame - # key_ego --> prev_cam_front --> prev_ego - keyego2adjego = curr_sensor2keyego.matmul(torch.inverse(prev_sensor2keyego)) - keyego2adjego = keyego2adjego.unsqueeze(dim=1) # (B, 1, 1, 4, 4) - - # (B, 1, 1, 3, 3) - keyego2adjego = keyego2adjego[..., [True, True, False, True], :][..., [True, True, False, True]] - - # x = grid_x * vx + x_min; y = grid_y * vy + y_min; - # feat2bev: - # [[vx, 0, x_min], - # [0, vy, y_min], - # [0, 0, 1 ]] - feat2bev = torch.zeros((3, 3), dtype=grid.dtype).to(grid) - feat2bev[0, 0] = self.img_view_transformer.grid_interval[0] - feat2bev[1, 1] = self.img_view_transformer.grid_interval[1] - feat2bev[0, 2] = self.img_view_transformer.grid_lower_bound[0] - feat2bev[1, 2] = self.img_view_transformer.grid_lower_bound[1] - feat2bev[2, 2] = 1 - feat2bev = feat2bev.view(1, 3, 3) # (1, 3, 3) - - # curr_feat_grid --> key ego --> prev_cam --> prev_ego --> prev_feat_grid - tf = torch.inverse(feat2bev).matmul(keyego2adjego).matmul(feat2bev) # (B, 1, 1, 3, 3) - grid = tf.matmul(grid) # (B, Dy, Dx, 3, 1) 3: (grid_x, grid_y, 1) - normalize_factor = torch.tensor([W - 1.0, H - 1.0], - dtype=input.dtype, - device=input.device) # (2, ) - # (B, Dy, Dx, 2) - grid = grid[:, :, :, :2, 0] / normalize_factor.view(1, 1, 1, 2) * 2.0 - 1.0 - return grid - - @force_fp32() - def shift_feature(self, input, sensor2keyegos, bda, bda_adj=None): - """ - Args: - input: (B, C, Dy, Dx) bev_feat - sensor2keyegos: List[ - curr_sensor-->key_ego: (B, N_views, 4, 4) - prev_sensor-->key_ego: (B, N_views, 4, 4) - ] - bda: (B, 3, 3) - bda_adj: None - Returns: - output: aligned bev feat (B, C, Dy, Dx). - """ - grid = self.gen_grid(input, sensor2keyegos, bda, bda_adj=bda_adj) # grid: (B, Dy, Dx, 2), 介于(-1, 1) - output = F.grid_sample(input, grid.to(input.dtype), align_corners=True) # (B, C, Dy, Dx) - return output - - def prepare_bev_feat(self, img, sensor2egos, ego2globals, intrin, post_rot, post_tran, - bda, mlp_input): - """ - Args: - imgs: (B, N_views, 3, H, W) - sensor2egos: (B, N_views, 4, 4) - ego2globals: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - bda_rot: (B, 3, 3) - mlp_input: - Returns: - bev_feat: (B, C, Dy, Dx) - depth: (B*N, D, fH, fW) - """ - x, _ = self.image_encoder(img) # x: (B, N, C, fH, fW) - # bev_feat: (B, C * Dz(=1), Dy, Dx) - # depth: (B * N, D, fH, fW) - bev_feat, depth = self.img_view_transformer( - [x, sensor2egos, ego2globals, intrin, post_rot, post_tran, bda, mlp_input]) - - if self.pre_process: - bev_feat = self.pre_process_net(bev_feat)[0] # (B, C, Dy, Dx) - return bev_feat, depth - - def extract_img_feat_sequential(self, inputs, feat_prev): - """ - Args: - inputs: - curr_img: (1, N_views, 3, H, W) - sensor2keyegos_curr: (N_prev, N_views, 4, 4) - ego2globals_curr: (N_prev, N_views, 4, 4) - intrins: (1, N_views, 3, 3) - sensor2keyegos_prev: (N_prev, N_views, 4, 4) - ego2globals_prev: (N_prev, N_views, 4, 4) - post_rots: (1, N_views, 3, 3) - post_trans: (1, N_views, 3, ) - bda_curr: (N_prev, 3, 3) - feat_prev: (N_prev, C, Dy, Dx) - Returns: - - """ - imgs, sensor2keyegos_curr, ego2globals_curr, intrins = inputs[:4] - sensor2keyegos_prev, _, post_rots, post_trans, bda = inputs[4:] - bev_feat_list = [] - mlp_input = self.img_view_transformer.get_mlp_input( - sensor2keyegos_curr[0:1, ...], ego2globals_curr[0:1, ...], - intrins, post_rots, post_trans, bda[0:1, ...]) - inputs_curr = (imgs, sensor2keyegos_curr[0:1, ...], - ego2globals_curr[0:1, ...], intrins, post_rots, - post_trans, bda[0:1, ...], mlp_input) - - # (1, C, Dx, Dy), (1*N, D, fH, fW) - bev_feat, depth = self.prepare_bev_feat(*inputs_curr) - bev_feat_list.append(bev_feat) - - # align the feat_prev - _, C, H, W = feat_prev.shape - # feat_prev: (N_prev, C, Dy, Dx) - feat_prev = \ - self.shift_feature(feat_prev, # (N_prev, C, Dy, Dx) - [sensor2keyegos_curr, # (N_prev, N_views, 4, 4) - sensor2keyegos_prev], # (N_prev, N_views, 4, 4) - bda # (N_prev, 3, 3) - ) - bev_feat_list.append(feat_prev.view(1, (self.num_frame - 1) * C, H, W)) # (1, N_prev*C, Dy, Dx) - - bev_feat = torch.cat(bev_feat_list, dim=1) # (1, N_frames*C, Dy, Dx) - x = self.bev_encoder(bev_feat) - return [x], depth - - def prepare_inputs(self, img_inputs, stereo=False): - """ - Args: - img_inputs: - imgs: (B, N, 3, H, W) # N = 6 * (N_history + 1) - sensor2egos: (B, N, 4, 4) - ego2globals: (B, N, 4, 4) - intrins: (B, N, 3, 3) - post_rots: (B, N, 3, 3) - post_trans: (B, N, 3) - bda_rot: (B, 3, 3) - stereo: bool - - Returns: - imgs: List[(B, N_views, C, H, W), (B, N_views, C, H, W), ...] len = N_frames - sensor2keyegos: List[(B, N_views, 4, 4), (B, N_views, 4, 4), ...] - ego2globals: List[(B, N_views, 4, 4), (B, N_views, 4, 4), ...] - intrins: List[(B, N_views, 3, 3), (B, N_views, 3, 3), ...] - post_rots: List[(B, N_views, 3, 3), (B, N_views, 3, 3), ...] - post_trans: List[(B, N_views, 3), (B, N_views, 3), ...] - bda: (B, 3, 3) - """ - B, N, C, H, W = img_inputs[0].shape - N = N // self.num_frame # N_views = 6 - imgs = img_inputs[0].view(B, N, self.num_frame, C, H, W) # (B, N_views, N_frames, C, H, W) - imgs = torch.split(imgs, 1, 2) - imgs = [t.squeeze(2) for t in imgs] # List[(B, N_views, C, H, W), (B, N_views, C, H, W), ...] - sensor2egos, ego2globals, intrins, post_rots, post_trans, bda = \ - img_inputs[1:7] - - sensor2egos = sensor2egos.view(B, self.num_frame, N, 4, 4) - ego2globals = ego2globals.view(B, self.num_frame, N, 4, 4) - - # calculate the transformation from sensor to key ego - # key_ego --> global (B, 1, 1, 4, 4) - keyego2global = ego2globals[:, 0, 0, ...].unsqueeze(1).unsqueeze(1) - # global --> key_ego (B, 1, 1, 4, 4) - global2keyego = torch.inverse(keyego2global.double()) - # sensor --> ego --> global --> key_ego - sensor2keyegos = \ - global2keyego @ ego2globals.double() @ sensor2egos.double() # (B, N_frames, N_views, 4, 4) - sensor2keyegos = sensor2keyegos.float() - - # -------------------- for stereo -------------------------- - curr2adjsensor = None - if stereo: - # (B, N_frames, N_views, 4, 4), (B, N_frames, N_views, 4, 4) - sensor2egos_cv, ego2globals_cv = sensor2egos, ego2globals - sensor2egos_curr = \ - sensor2egos_cv[:, :self.temporal_frame, ...].double() # (B, N_temporal=2, N_views, 4, 4) - ego2globals_curr = \ - ego2globals_cv[:, :self.temporal_frame, ...].double() # (B, N_temporal=2, N_views, 4, 4) - sensor2egos_adj = \ - sensor2egos_cv[:, 1:self.temporal_frame + 1, ...].double() # (B, N_temporal=2, N_views, 4, 4) - ego2globals_adj = \ - ego2globals_cv[:, 1:self.temporal_frame + 1, ...].double() # (B, N_temporal=2, N_views, 4, 4) - - # curr_sensor --> curr_ego --> global --> prev_ego --> prev_sensor - curr2adjsensor = \ - torch.inverse(ego2globals_adj @ sensor2egos_adj) \ - @ ego2globals_curr @ sensor2egos_curr # (B, N_temporal=2, N_views, 4, 4) - curr2adjsensor = curr2adjsensor.float() # (B, N_temporal=2, N_views, 4, 4) - curr2adjsensor = torch.split(curr2adjsensor, 1, 1) - curr2adjsensor = [p.squeeze(1) for p in curr2adjsensor] - curr2adjsensor.extend([None for _ in range(self.extra_ref_frames)]) - # curr2adjsensor: List[(B, N_views, 4, 4), (B, N_views, 4, 4), None] - assert len(curr2adjsensor) == self.num_frame - # -------------------- for stereo -------------------------- - - extra = [ - sensor2keyegos, # (B, N_frames, N_views, 4, 4) - ego2globals, # (B, N_frames, N_views, 4, 4) - intrins.view(B, self.num_frame, N, 3, 3), # (B, N_frames, N_views, 3, 3) - post_rots.view(B, self.num_frame, N, 3, 3), # (B, N_frames, N_views, 3, 3) - post_trans.view(B, self.num_frame, N, 3) # (B, N_frames, N_views, 3) - ] - extra = [torch.split(t, 1, 1) for t in extra] - extra = [[p.squeeze(1) for p in t] for t in extra] - sensor2keyegos, ego2globals, intrins, post_rots, post_trans = extra - return imgs, sensor2keyegos, ego2globals, intrins, post_rots, post_trans, \ - bda, curr2adjsensor - - def extract_img_feat(self, - img_inputs, - img_metas, - pred_prev=False, - sequential=False, - **kwargs): - """ - Args: - img_inputs: - imgs: (B, N, 3, H, W) # N = 6 * (N_history + 1) - sensor2egos: (B, N, 4, 4) - ego2globals: (B, N, 4, 4) - intrins: (B, N, 3, 3) - post_rots: (B, N, 3, 3) - post_trans: (B, N, 3) - bda_rot: (B, 3, 3) - img_metas: - **kwargs: - Returns: - x: [(B, C', H', W'), ] - depth: (B*N_views, D, fH, fW) - """ - if sequential: - return self.extract_img_feat_sequential(img_inputs, kwargs['feat_prev']) - imgs, sensor2keyegos, ego2globals, intrins, post_rots, post_trans, \ - bda, _ = self.prepare_inputs(img_inputs) - - """Extract features of images.""" - bev_feat_list = [] - depth_list = [] - key_frame = True # back propagation for key frame only - for img, sensor2keyego, ego2global, intrin, post_rot, post_tran in zip( - imgs, sensor2keyegos, ego2globals, intrins, post_rots, post_trans): - if key_frame or self.with_prev: - if self.align_after_view_transfromation: - sensor2keyego, ego2global = sensor2keyegos[0], ego2globals[0] - - mlp_input = self.img_view_transformer.get_mlp_input( - sensor2keyegos[0], ego2globals[0], intrin, post_rot, post_tran, bda) # (B, N_views, 27) - - inputs_curr = (img, sensor2keyego, ego2global, intrin, post_rot, - post_tran, bda, mlp_input) - if key_frame: - # bev_feat: (B, C, Dy, Dx) - # depth: (B*N_views, D, fH, fW) - bev_feat, depth = self.prepare_bev_feat(*inputs_curr) - else: - with torch.no_grad(): - bev_feat, depth = self.prepare_bev_feat(*inputs_curr) - else: - # https://github.com/HuangJunJie2017/BEVDet/issues/275 - bev_feat = torch.zeros_like(bev_feat_list[0]) - depth = None - bev_feat_list.append(bev_feat) - depth_list.append(depth) - key_frame = False - - # bev_feat_list: List[(B, C, Dy, Dx), (B, C, Dy, Dx), ...] - # depth_list: List[(B*N_views, D, fH, fW), (B*N_views, D, fH, fW), ...] - - if pred_prev: - assert self.align_after_view_transfromation - assert sensor2keyegos[0].shape[0] == 1 # batch_size = 1 - feat_prev = torch.cat(bev_feat_list[1:], dim=0) - # (1, N_views, 4, 4) --> (N_prev, N_views, 4, 4) - ego2globals_curr = \ - ego2globals[0].repeat(self.num_frame - 1, 1, 1, 1) - # (1, N_views, 4, 4) --> (N_prev, N_views, 4, 4) - sensor2keyegos_curr = \ - sensor2keyegos[0].repeat(self.num_frame - 1, 1, 1, 1) - ego2globals_prev = torch.cat(ego2globals[1:], dim=0) # (N_prev, N_views, 4, 4) - sensor2keyegos_prev = torch.cat(sensor2keyegos[1:], dim=0) # (N_prev, N_views, 4, 4) - bda_curr = bda.repeat(self.num_frame - 1, 1, 1) # (N_prev, 3, 3) - return feat_prev, [imgs[0], # (1, N_views, 3, H, W) - sensor2keyegos_curr, # (N_prev, N_views, 4, 4) - ego2globals_curr, # (N_prev, N_views, 4, 4) - intrins[0], # (1, N_views, 3, 3) - sensor2keyegos_prev, # (N_prev, N_views, 4, 4) - ego2globals_prev, # (N_prev, N_views, 4, 4) - post_rots[0], # (1, N_views, 3, 3) - post_trans[0], # (1, N_views, 3, ) - bda_curr] # (N_prev, 3, 3) - - if self.align_after_view_transfromation: - for adj_id in range(1, self.num_frame): - bev_feat_list[adj_id] = self.shift_feature( - bev_feat_list[adj_id], # (B, C, Dy, Dx) - [sensor2keyegos[0], # (B, N_views, 4, 4) - sensor2keyegos[adj_id] # (B, N_views, 4, 4) - ], - bda # (B, 3, 3) - ) # (B, C, Dy, Dx) - - bev_feat = torch.cat(bev_feat_list, dim=1) # (B, N_frames*C, Dy, Dx) - x = self.bev_encoder(bev_feat) - return [x], depth_list[0] - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet_occ.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet_occ.py deleted file mode 100644 index a90b977279fba68041481a5505cb23d91908e3da..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevdet_occ.py +++ /dev/null @@ -1,1480 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -from ...ops import TRTBEVPoolv2 -from .bevdet import BEVDet -from .bevdepth import BEVDepth -from .bevdepth4d import BEVDepth4D -from .bevstereo4d import BEVStereo4D -from mmdet3d.models import DETECTORS -from mmdet3d.models.builder import build_head -import torch.nn.functional as F -from mmdet3d.core import bbox3d2result -import numpy as np -from multiprocessing.dummy import Pool as ThreadPool -from ...ops import nearest_assign -# pool = ThreadPool(processes=4) # ̳߳ - -# for pano -grid_config_occ = { - 'x': [-40, 40, 0.4], - 'y': [-40, 40, 0.4], - 'z': [-1, 5.4, 6.4], - 'depth': [1.0, 45.0, 1.0], -} -# det -det_class_name = ['car', 'truck', 'trailer', 'bus', 'construction_vehicle', - 'bicycle', 'motorcycle', 'pedestrian', 'traffic_cone', - 'barrier'] - -# occ -occ_class_names = [ - 'others', 'barrier', 'bicycle', 'bus', 'car', 'construction_vehicle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'trailer', 'truck', - 'driveable_surface', 'other_flat', 'sidewalk', - 'terrain', 'manmade', 'vegetation', 'free' -] - -det_ind = [2, 3, 4, 5, 6, 7, 9, 10] -occ_ind = [5, 3, 0, 4, 6, 7, 2, 1] -detind2occind = { - 0:4, - 1:10, - 2:9, - 3:3, - 4:5, - 5:2, - 6:6, - 7:7, - 8:8, - 9:1, -} -occind2detind = { - 4:0, - 10:1, - 9:2, - 3:3, - 5:4, - 2:5, - 6:6, - 7:7, - 8:8, - 1:9, -} -occind2detind_cuda = [-1, -1, 5, 3, 0, 4, 6, 7, -1, 2, 1] - -inst_occ = np.ones([200, 200, 16])*0 - -import torch -X1, Y1, Z1 = 200, 200, 16 -coords_x = torch.arange(X1).float() -coords_y = torch.arange(Y1).float() -coords_z = torch.arange(Z1).float() -coords = torch.stack(torch.meshgrid([coords_x, coords_y, coords_z])).permute(1, 2, 3, 0) # W, H, D, 3 -# coords = coords.cpu().numpy() -st = [grid_config_occ['x'][0], grid_config_occ['y'][0], grid_config_occ['z'][0]] -sx = [grid_config_occ['x'][2], grid_config_occ['y'][2], 0.4] - -@DETECTORS.register_module() -class BEVDetOCC(BEVDet): - def __init__(self, - occ_head=None, - upsample=False, - **kwargs): - super(BEVDetOCC, self).__init__(**kwargs) - self.occ_head = build_head(occ_head) - self.pts_bbox_head = None - self.upsample = upsample - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - losses = dict() - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - loss_occ = self.forward_occ_train(occ_bev_feature, voxel_semantics, mask_camera) - losses.update(loss_occ) - return losses - @torch.compile(mode="reduce-overhead") - def forward_occ_train(self, img_feats, voxel_semantics, mask_camera): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - """ - outs = self.occ_head(img_feats) - # assert voxel_semantics.min() >= 0 and voxel_semantics.max() <= 17 - loss_occ = self.occ_head.loss( - outs, # (B, Dx, Dy, Dz, n_cls) - voxel_semantics, # (B, Dx, Dy, Dz) - mask_camera, # (B, Dx, Dy, Dz) - ) - return loss_occ - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - occ_list = self.simple_test_occ(occ_bev_feature, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_list - - def simple_test_occ(self, img_feats, img_metas=None): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - img_metas: - - Returns: - occ_preds: List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - outs = self.occ_head(img_feats) - if not hasattr(self.occ_head, "get_occ_gpu"): - occ_preds = self.occ_head.get_occ(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - else: - occ_preds = self.occ_head.get_occ_gpu(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_preds - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs = self.occ_head(occ_bev_feature) - return outs - - -@DETECTORS.register_module() -class BEVDepthOCC(BEVDepth): - def __init__(self, - occ_head=None, - upsample=False, - **kwargs): - super(BEVDepthOCC, self).__init__(**kwargs) - self.occ_head = build_head(occ_head) - self.pts_bbox_head = None - self.upsample = upsample - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - losses = dict() - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses['loss_depth'] = loss_depth - - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - loss_occ = self.forward_occ_train(occ_bev_feature, voxel_semantics, mask_camera) - losses.update(loss_occ) - return losses - - def forward_occ_train(self, img_feats, voxel_semantics, mask_camera): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - """ - outs = self.occ_head(img_feats) - # assert voxel_semantics.min() >= 0 and voxel_semantics.max() <= 17 - loss_occ = self.occ_head.loss( - outs, # (B, Dx, Dy, Dz, n_cls) - voxel_semantics, # (B, Dx, Dy, Dz) - mask_camera, # (B, Dx, Dy, Dz) - ) - return loss_occ - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - occ_list = self.simple_test_occ(occ_bev_feature, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_list - - def simple_test_occ(self, img_feats, img_metas=None): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - img_metas: - - Returns: - occ_preds: List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - outs = self.occ_head(img_feats) - # occ_preds = self.occ_head.get_occ(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - occ_preds = self.occ_head.get_occ_gpu(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_preds - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs = self.occ_head(occ_bev_feature) - return outs - - -@DETECTORS.register_module() -class BEVDepthPano(BEVDepthOCC): - def __init__(self, - aux_centerness_head=None, - **kwargs): - super(BEVDepthPano, self).__init__(**kwargs) - self.aux_centerness_head = None - if aux_centerness_head: - train_cfg = kwargs['train_cfg'] - test_cfg = kwargs['test_cfg'] - pts_train_cfg = train_cfg.pts if train_cfg else None - aux_centerness_head.update(train_cfg=pts_train_cfg) - pts_test_cfg = test_cfg.pts if test_cfg else None - aux_centerness_head.update(test_cfg=pts_test_cfg) - self.aux_centerness_head = build_head(aux_centerness_head) - if 'inst_class_ids' in kwargs: - self.inst_class_ids = kwargs['inst_class_ids'] - else: - self.inst_class_ids = [2, 3, 4, 5, 6, 7, 9, 10] - - X1, Y1, Z1 = 200, 200, 16 - coords_x = torch.arange(X1).float() - coords_y = torch.arange(Y1).float() - coords_z = torch.arange(Z1).float() - self.coords = torch.stack(torch.meshgrid([coords_x, coords_y, coords_z])).permute(1, 2, 3, 0) # W, H, D, 3 - self.st = torch.tensor([grid_config_occ['x'][0], grid_config_occ['y'][0], grid_config_occ['z'][0]]) - self.sx = torch.tensor([grid_config_occ['x'][2], grid_config_occ['y'][2], 0.4]) - self.is_to_d = False - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - losses = dict() - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses['loss_depth'] = loss_depth - - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - loss_occ = self.forward_occ_train(occ_bev_feature, voxel_semantics, mask_camera) - losses.update(loss_occ) - - losses_aux_centerness = self.forward_aux_centerness_train([occ_bev_feature], gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore) - losses.update(losses_aux_centerness) - return losses - - def forward_aux_centerness_train(self, - pts_feats, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None): - outs = self.aux_centerness_head(pts_feats) - loss_inputs = [gt_bboxes_3d, gt_labels_3d, outs] - losses = self.aux_centerness_head.loss(*loss_inputs) - return losses - - def simple_test_aux_centerness(self, x, img_metas, rescale=False, **kwargs): - """Test function of point cloud branch.""" - # outs = self.aux_centerness_head(x) - tx = self.aux_centerness_head.shared_conv(x[0]) # (B, C'=share_conv_channel, H, W) - outs_inst_center_reg = self.aux_centerness_head.task_heads[0].reg(tx) - outs_inst_center_height = self.aux_centerness_head.task_heads[0].height(tx) - outs_inst_center_heatmap = self.aux_centerness_head.task_heads[0].heatmap(tx) - outs = ([{ - "reg" : outs_inst_center_reg, - "height" : outs_inst_center_height, - "heatmap" : outs_inst_center_heatmap, - }],) - - # # bbox_list = self.aux_centerness_head.get_bboxes( - # # outs, img_metas, rescale=rescale) - # # bbox_results = [ - # # bbox3d2result(bboxes, scores, labels) - # # for bboxes, scores, labels in bbox_list - # # ] - ins_cen_list = self.aux_centerness_head.get_centers( - outs, img_metas, rescale=rescale) - # return bbox_results, ins_cen_list - return None, ins_cen_list - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - result_list = [dict() for _ in range(len(img_metas))] - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - w_pano = kwargs['w_pano'] if 'w_pano' in kwargs else True - if w_pano == True: - bbox_pts, ins_cen_list = self.simple_test_aux_centerness([occ_bev_feature], img_metas, rescale=rescale, **kwargs) - - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - - occ_list = self.simple_test_occ(occ_bev_feature, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - for result_dict, occ_pred in zip(result_list, occ_list): - result_dict['pred_occ'] = occ_pred - - w_panoproc = kwargs['w_panoproc'] if 'w_panoproc' in kwargs else True # 37.53 ms - if w_panoproc == True: - # # for pano - inst_xyz = ins_cen_list[0][0] - if self.is_to_d == False: - self.st = self.st.to(inst_xyz) - self.sx = self.sx.to(inst_xyz) - self.coords = self.coords.to(inst_xyz) - self.is_to_d = True - - inst_xyz = ((inst_xyz - self.st) / self.sx).int() - - inst_cls = ins_cen_list[2][0].int() - - inst_num = 18 # 37.62 ms - # inst_occ = torch.tensor(occ_pred).to(inst_cls) - # inst_occ = occ_pred.clone().detach() - inst_occ = occ_pred.clone().detach() # 37.61 ms - if len(inst_cls) > 0: - cls_sort, indices = inst_cls.sort() - l2s = {} - if len(inst_cls) == 1: - l2s[cls_sort[0].item()] = 0 - l2s[cls_sort[0].item()] = 0 - # # tind_list = cls_sort[1:] - cls_sort[:-1]!=0 - # # for tind in range(len(tind_list)): - # # if tind_list[tind] == True: - # # l2s[cls_sort[1+tind].item()] = tind + 1 - tind_list = (cls_sort[1:] - cls_sort[:-1])!=0 - if tind_list.__len__() > 0: - for tind in torch.range(0,len(tind_list)-1)[tind_list]: - l2s[cls_sort[1+int(tind.item())].item()] = int(tind.item()) + 1 - - is_cuda = True - # is_cuda = False - if is_cuda == True: - inst_id_list = indices + inst_num - l2s_key = indices.new_tensor([detind2occind[k] for k in l2s.keys()]).to(torch.int) - inst_occ = nearest_assign( - occ_pred.to(torch.int), - l2s_key.to(torch.int), - indices.new_tensor(occind2detind_cuda).to(torch.int), - inst_cls.to(torch.int), - inst_xyz.to(torch.int), - inst_id_list.to(torch.int) - ) - else: - for cls_label_num_in_occ in self.inst_class_ids: - mask = occ_pred == cls_label_num_in_occ - if mask.sum() == 0: - continue - else: - cls_label_num_in_inst = occind2detind[cls_label_num_in_occ] - select_mask = inst_cls==cls_label_num_in_inst - if sum(select_mask) > 0: - indices = self.coords[mask] - inst_index_same_cls = inst_xyz[select_mask] - select_ind = ((indices[:,None,:] - inst_index_same_cls[None,:,:])**2).sum(-1).argmin(axis=1).int() - inst_occ[mask] = select_ind + inst_num + l2s[cls_label_num_in_inst] - - result_list[0]['pano_inst'] = inst_occ #.cpu().numpy() - - return result_list - -@DETECTORS.register_module() -class BEVDepth4DOCC(BEVDepth4D): - def __init__(self, - occ_head=None, - upsample=False, - **kwargs): - super(BEVDepth4DOCC, self).__init__(**kwargs) - self.occ_head = build_head(occ_head) - self.pts_bbox_head = None - self.upsample = upsample - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - losses = dict() - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses['loss_depth'] = loss_depth - - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - loss_occ = self.forward_occ_train(img_feats[0], voxel_semantics, mask_camera) - losses.update(loss_occ) - return losses - - def forward_occ_train(self, img_feats, voxel_semantics, mask_camera): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - """ - outs = self.occ_head(img_feats) - assert voxel_semantics.min() >= 0 and voxel_semantics.max() <= 17 - loss_occ = self.occ_head.loss( - outs, # (B, Dx, Dy, Dz, n_cls) - voxel_semantics, # (B, Dx, Dy, Dz) - mask_camera, # (B, Dx, Dy, Dz) - ) - return loss_occ - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - - occ_list = self.simple_test_occ(img_feats[0], img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_list - - def simple_test_occ(self, img_feats, img_metas=None): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - img_metas: - - Returns: - occ_preds: List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - outs = self.occ_head(img_feats) - # occ_preds = self.occ_head.get_occ(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - occ_preds = self.occ_head.get_occ_gpu(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_preds - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs = self.occ_head(occ_bev_feature) - return outs - -@DETECTORS.register_module() -class BEVDepth4DPano(BEVDepth4DOCC): - def __init__(self, - aux_centerness_head=None, - **kwargs): - super(BEVDepth4DPano, self).__init__(**kwargs) - self.aux_centerness_head = None - if aux_centerness_head: - train_cfg = kwargs['train_cfg'] - test_cfg = kwargs['test_cfg'] - pts_train_cfg = train_cfg.pts if train_cfg else None - aux_centerness_head.update(train_cfg=pts_train_cfg) - pts_test_cfg = test_cfg.pts if test_cfg else None - aux_centerness_head.update(test_cfg=pts_test_cfg) - self.aux_centerness_head = build_head(aux_centerness_head) - if 'inst_class_ids' in kwargs: - self.inst_class_ids = kwargs['inst_class_ids'] - else: - self.inst_class_ids = [2, 3, 4, 5, 6, 7, 9, 10] - - X1, Y1, Z1 = 200, 200, 16 - coords_x = torch.arange(X1).float() - coords_y = torch.arange(Y1).float() - coords_z = torch.arange(Z1).float() - self.coords = torch.stack(torch.meshgrid([coords_x, coords_y, coords_z])).permute(1, 2, 3, 0) # W, H, D, 3 - self.st = torch.tensor([grid_config_occ['x'][0], grid_config_occ['y'][0], grid_config_occ['z'][0]]) - self.sx = torch.tensor([grid_config_occ['x'][2], grid_config_occ['y'][2], 0.4]) - self.is_to_d = False - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - losses = dict() - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses['loss_depth'] = loss_depth - - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - loss_occ = self.forward_occ_train(img_feats[0], voxel_semantics, mask_camera) - losses.update(loss_occ) - - losses_aux_centerness = self.forward_aux_centerness_train([img_feats[0]], gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore) - losses.update(losses_aux_centerness) - return losses - - def forward_aux_centerness_train(self, - pts_feats, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None): - outs = self.aux_centerness_head(pts_feats) - loss_inputs = [gt_bboxes_3d, gt_labels_3d, outs] - losses = self.aux_centerness_head.loss(*loss_inputs) - return losses - - def simple_test_aux_centerness(self, x, img_metas, rescale=False, **kwargs): - """Test function of point cloud branch.""" - outs = self.aux_centerness_head(x) - bbox_list = self.aux_centerness_head.get_bboxes( - outs, img_metas, rescale=rescale) - bbox_results = [ - bbox3d2result(bboxes, scores, labels) - for bboxes, scores, labels in bbox_list - ] - ins_cen_list = self.aux_centerness_head.get_centers( - outs, img_metas, rescale=rescale) - return bbox_results, ins_cen_list - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - result_list = [dict() for _ in range(len(img_metas))] - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - w_pano = kwargs['w_pano'] if 'w_pano' in kwargs else True - if w_pano == True: - bbox_pts, ins_cen_list = self.simple_test_aux_centerness([occ_bev_feature], img_metas, rescale=rescale, **kwargs) - - occ_list = self.simple_test_occ(occ_bev_feature, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - for result_dict, occ_pred in zip(result_list, occ_list): - result_dict['pred_occ'] = occ_pred - - w_panoproc = kwargs['w_panoproc'] if 'w_panoproc' in kwargs else True - if w_panoproc == True: - # # for pano - inst_xyz = ins_cen_list[0][0] - if self.is_to_d == False: - self.st = self.st.to(inst_xyz) - self.sx = self.sx.to(inst_xyz) - self.coords = self.coords.to(inst_xyz) - self.is_to_d = True - - inst_xyz = ((inst_xyz - self.st) / self.sx).int() - - inst_cls = ins_cen_list[2][0].int() - - inst_num = 18 # 37.62 ms - # inst_occ = torch.tensor(occ_pred).to(inst_cls) - # inst_occ = occ_pred.clone().detach() - inst_occ = occ_pred.clone().detach() # 37.61 ms - if len(inst_cls) > 0: - cls_sort, indices = inst_cls.sort() - l2s = {} - if len(inst_cls) == 1: - l2s[cls_sort[0].item()] = 0 - l2s[cls_sort[0].item()] = 0 - # # tind_list = cls_sort[1:] - cls_sort[:-1]!=0 - # # for tind in range(len(tind_list)): - # # if tind_list[tind] == True: - # # l2s[cls_sort[1+tind].item()] = tind + 1 - tind_list = (cls_sort[1:] - cls_sort[:-1])!=0 - if tind_list.__len__() > 0: - for tind in torch.range(0,len(tind_list)-1)[tind_list]: - l2s[cls_sort[1+int(tind.item())].item()] = int(tind.item()) + 1 - - is_cuda = True - # is_cuda = False - if is_cuda == True: - inst_id_list = indices + inst_num - l2s_key = indices.new_tensor([detind2occind[k] for k in l2s.keys()]).to(torch.int) - inst_occ = nearest_assign( - occ_pred.to(torch.int), - l2s_key.to(torch.int), - indices.new_tensor(occind2detind_cuda).to(torch.int), - inst_cls.to(torch.int), - inst_xyz.to(torch.int), - inst_id_list.to(torch.int) - ) - else: - for cls_label_num_in_occ in self.inst_class_ids: - mask = occ_pred == cls_label_num_in_occ - if mask.sum() == 0: - continue - else: - cls_label_num_in_inst = occind2detind[cls_label_num_in_occ] - select_mask = inst_cls==cls_label_num_in_inst - if sum(select_mask) > 0: - indices = self.coords[mask] - inst_index_same_cls = inst_xyz[select_mask] - select_ind = ((indices[:,None,:] - inst_index_same_cls[None,:,:])**2).sum(-1).argmin(axis=1).int() - inst_occ[mask] = select_ind + inst_num + l2s[cls_label_num_in_inst] - - result_list[0]['pano_inst'] = inst_occ #.cpu().numpy() - - return result_list - -@DETECTORS.register_module() -class BEVStereo4DOCC(BEVStereo4D): - def __init__(self, - occ_head=None, - upsample=False, - **kwargs): - super(BEVStereo4DOCC, self).__init__(**kwargs) - self.occ_head = build_head(occ_head) - self.pts_bbox_head = None - self.upsample = upsample - - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img_inputs=None, - proposals=None, - gt_bboxes_ignore=None, - **kwargs): - """Forward training function. - - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - - Returns: - dict: Losses of different branches. - """ - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - - gt_depth = kwargs['gt_depth'] # (B, N_views, img_H, img_W) - losses = dict() - loss_depth = self.img_view_transformer.get_depth_loss(gt_depth, depth) - losses['loss_depth'] = loss_depth - - voxel_semantics = kwargs['voxel_semantics'] # (B, Dx, Dy, Dz) - mask_camera = kwargs['mask_camera'] # (B, Dx, Dy, Dz) - loss_occ = self.forward_occ_train(img_feats[0], voxel_semantics, mask_camera) - losses.update(loss_occ) - return losses - - def forward_occ_train(self, img_feats, voxel_semantics, mask_camera): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - voxel_semantics: (B, Dx, Dy, Dz) - mask_camera: (B, Dx, Dy, Dz) - Returns: - """ - outs = self.occ_head(img_feats) - assert voxel_semantics.min() >= 0 and voxel_semantics.max() <= 17 - loss_occ = self.occ_head.loss( - outs, # (B, Dx, Dy, Dz, n_cls) - voxel_semantics, # (B, Dx, Dy, Dz) - mask_camera, # (B, Dx, Dy, Dz) - ) - return loss_occ - - def simple_test(self, - points, - img_metas, - img=None, - rescale=False, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, _, _ = self.extract_feat( - points, img_inputs=img, img_metas=img_metas, **kwargs) - - occ_list = self.simple_test_occ(img_feats[0], img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_list - - def simple_test_occ(self, img_feats, img_metas=None): - """ - Args: - img_feats: (B, C, Dz, Dy, Dx) / (B, C, Dy, Dx) - img_metas: - - Returns: - occ_preds: List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - """ - outs = self.occ_head(img_feats) - # occ_preds = self.occ_head.get_occ(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - occ_preds = self.occ_head.get_occ_gpu(outs, img_metas) # List[(Dx, Dy, Dz), (Dx, Dy, Dz), ...] - return occ_preds - - def forward_dummy(self, - points=None, - img_metas=None, - img_inputs=None, - **kwargs): - # img_feats: List[(B, C, Dz, Dy, Dx)/(B, C, Dy, Dx) , ] - # pts_feats: None - # depth: (B*N_views, D, fH, fW) - img_feats, pts_feats, depth = self.extract_feat( - points, img_inputs=img_inputs, img_metas=img_metas, **kwargs) - occ_bev_feature = img_feats[0] - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs = self.occ_head(occ_bev_feature) - return outs - - -@DETECTORS.register_module() -class BEVDetOCCTRT(BEVDetOCC): - def __init__(self, - wocc=True, - wdet3d=True, - uni_train=True, - **kwargs): - super(BEVDetOCCTRT, self).__init__(**kwargs) - self.wocc = wocc - self.wdet3d = wdet3d - self.uni_train = uni_train - - def result_serialize(self, outs_det3d=None, outs_occ=None): - outs_ = [] - if outs_det3d is not None: - for out in outs_det3d: - for key in ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap']: - outs_.append(out[0][key]) - if outs_occ is not None: - outs_.append(outs_occ) - return outs_ - - def result_deserialize(self, outs): - outs_ = [] - keys = ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap'] - for head_id in range(len(outs) // 6): - outs_head = [dict()] - for kid, key in enumerate(keys): - outs_head[0][key] = outs[head_id * 6 + kid] - outs_.append(outs_head) - return outs_ - - def forward_part1( - self, - img, - ): - x = self.img_backbone(img) - x = self.img_neck(x) - x = self.img_view_transformer.depth_net(x[0]) - depth = x[:, :self.img_view_transformer.D].softmax(dim=1) - tran_feat = x[:, self.img_view_transformer.D:( - self.img_view_transformer.D + - self.img_view_transformer.out_channels)] - tran_feat = tran_feat.permute(0, 2, 3, 1) - # depth = depth.reshape(-1) - # tran_feat = tran_feat.flatten(0,2) - return tran_feat.flatten(0,2), depth.reshape(-1) - - def forward_part2( - self, - tran_feat, - depth, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - ): - tran_feat = tran_feat.reshape(6, 16, 44, 64) - depth = depth.reshape(6, 16, 44, 44) - x = TRTBEVPoolv2.apply(depth.contiguous(), tran_feat.contiguous(), - ranks_depth, ranks_feat, ranks_bev, - interval_starts, interval_lengths, - int(self.img_view_transformer.grid_size[0].item()), - int(self.img_view_transformer.grid_size[1].item()), - int(self.img_view_transformer.grid_size[2].item()) - ) # -> [1, 64, 200, 200] - return x.reshape(-1) - - def forward_part3( - self, - x - ): - x = x.reshape(1, 200, 200, 64) - x = x.permute(0, 3, 1, 2).contiguous() - # return [x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x] - bev_feature = self.img_bev_encoder_backbone(x) - occ_bev_feature = self.img_bev_encoder_neck(bev_feature) - - outs_occ = None - if self.wocc == True: - if self.uni_train == True: - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs_occ = self.occ_head(occ_bev_feature) - - outs_det3d = None - if self.wdet3d == True: - outs_det3d = self.pts_bbox_head([occ_bev_feature]) - - outs = self.result_serialize(outs_det3d, outs_occ) - return outs - - def forward_ori( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - ): - x = self.img_backbone(img) - x = self.img_neck(x) - x = self.img_view_transformer.depth_net(x[0]) - depth = x[:, :self.img_view_transformer.D].softmax(dim=1) - tran_feat = x[:, self.img_view_transformer.D:( - self.img_view_transformer.D + - self.img_view_transformer.out_channels)] - tran_feat = tran_feat.permute(0, 2, 3, 1) - x = TRTBEVPoolv2.apply(depth.contiguous(), tran_feat.contiguous(), - ranks_depth, ranks_feat, ranks_bev, - interval_starts, interval_lengths, - int(self.img_view_transformer.grid_size[0].item()), - int(self.img_view_transformer.grid_size[1].item()), - int(self.img_view_transformer.grid_size[2].item()) - ) - x = x.permute(0, 3, 1, 2).contiguous() - # return [x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x] - bev_feature = self.img_bev_encoder_backbone(x) - occ_bev_feature = self.img_bev_encoder_neck(bev_feature) - - outs_occ = None - if self.wocc == True: - if self.uni_train == True: - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs_occ = self.occ_head(occ_bev_feature) - - outs_det3d = None - if self.wdet3d == True: - outs_det3d = self.pts_bbox_head([occ_bev_feature]) - - outs = self.result_serialize(outs_det3d, outs_occ) - return outs - - def forward_with_argmax( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - ): - - outs = self.forward_ori( - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - ) - pred_occ_label = outs[0].argmax(-1) - return pred_occ_label - - - def get_bev_pool_input(self, input): - input = self.prepare_inputs(input) - coor = self.img_view_transformer.get_lidar_coor(*input[1:7]) - return self.img_view_transformer.voxel_pooling_prepare_v2(coor) - - -@DETECTORS.register_module() -class BEVDepthOCCTRT(BEVDetOCC): - def __init__(self, - wocc=True, - wdet3d=True, - uni_train=True, - **kwargs): - super(BEVDepthOCCTRT, self).__init__(**kwargs) - self.wocc = wocc - self.wdet3d = wdet3d - self.uni_train = uni_train - - def result_serialize(self, outs_det3d=None, outs_occ=None): - outs_ = [] - if outs_det3d is not None: - for out in outs_det3d: - for key in ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap']: - outs_.append(out[0][key]) - if outs_occ is not None: - outs_.append(outs_occ) - return outs_ - - def result_deserialize(self, outs): - outs_ = [] - keys = ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap'] - for head_id in range(len(outs) // 6): - outs_head = [dict()] - for kid, key in enumerate(keys): - outs_head[0][key] = outs[head_id * 6 + kid] - outs_.append(outs_head) - return outs_ - - def forward_ori( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ): - x = self.img_backbone(img) - x = self.img_neck(x) - x = self.img_view_transformer.depth_net(x[0], mlp_input) - depth = x[:, :self.img_view_transformer.D].softmax(dim=1) - tran_feat = x[:, self.img_view_transformer.D:( - self.img_view_transformer.D + - self.img_view_transformer.out_channels)] - tran_feat = tran_feat.permute(0, 2, 3, 1) - x = TRTBEVPoolv2.apply(depth.contiguous(), tran_feat.contiguous(), - ranks_depth, ranks_feat, ranks_bev, - interval_starts, interval_lengths, - int(self.img_view_transformer.grid_size[0].item()), - int(self.img_view_transformer.grid_size[1].item()), - int(self.img_view_transformer.grid_size[2].item()) - ) - x = x.permute(0, 3, 1, 2).contiguous() - # return [x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x] - bev_feature = self.img_bev_encoder_backbone(x) - occ_bev_feature = self.img_bev_encoder_neck(bev_feature) - - outs_occ = None - if self.wocc == True: - if self.uni_train == True: - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs_occ = self.occ_head(occ_bev_feature) - - outs_det3d = None - if self.wdet3d == True: - outs_det3d = self.pts_bbox_head([occ_bev_feature]) - - outs = self.result_serialize(outs_det3d, outs_occ) - return outs - - def forward_with_argmax( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ): - - outs = self.forward_ori( - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ) - pred_occ_label = outs[0].argmax(-1) - return pred_occ_label - - - def get_bev_pool_input(self, input): - input = self.prepare_inputs(input) - coor = self.img_view_transformer.get_lidar_coor(*input[1:7]) - mlp_input = self.img_view_transformer.get_mlp_input(*input[1:7]) - # sensor2keyegos, ego2globals, intrins, post_rots, post_trans, bda) # (B, N_views, 27) - return self.img_view_transformer.voxel_pooling_prepare_v2(coor), mlp_input - - -@DETECTORS.register_module() -class BEVDepthPanoTRT(BEVDepthPano): - def __init__(self, - wocc=True, - wdet3d=True, - uni_train=True, - **kwargs): - super(BEVDepthPanoTRT, self).__init__(**kwargs) - self.wocc = wocc - self.wdet3d = wdet3d - self.uni_train = uni_train - - def result_serialize(self, outs_det3d=None, outs_occ=None): - outs_ = [] - if outs_det3d is not None: - for out in outs_det3d: - for key in ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap']: - outs_.append(out[0][key]) - if outs_occ is not None: - outs_.append(outs_occ) - return outs_ - - def result_deserialize(self, outs): - outs_ = [] - keys = ['reg', 'height', 'dim', 'rot', 'vel', 'heatmap'] - for head_id in range(len(outs) // 6): - outs_head = [dict()] - for kid, key in enumerate(keys): - outs_head[0][key] = outs[head_id * 6 + kid] - outs_.append(outs_head) - return outs_ - - def forward_part1( - self, - img, - mlp_input, - ): - x = self.img_backbone(img) - x = self.img_neck(x) - x = self.img_view_transformer.depth_net(x[0], mlp_input) - depth = x[:, :self.img_view_transformer.D].softmax(dim=1) - tran_feat = x[:, self.img_view_transformer.D:( - self.img_view_transformer.D + - self.img_view_transformer.out_channels)] - tran_feat = tran_feat.permute(0, 2, 3, 1) - # depth = depth.reshape(-1) - # tran_feat = tran_feat.flatten(0,2) - return tran_feat.flatten(0,2), depth.reshape(-1) - - def forward_part2( - self, - tran_feat, - depth, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - ): - tran_feat = tran_feat.reshape(6, 16, 44, 64) - depth = depth.reshape(6, 16, 44, 44) - x = TRTBEVPoolv2.apply(depth.contiguous(), tran_feat.contiguous(), - ranks_depth, ranks_feat, ranks_bev, - interval_starts, interval_lengths, - int(self.img_view_transformer.grid_size[0].item()), - int(self.img_view_transformer.grid_size[1].item()), - int(self.img_view_transformer.grid_size[2].item()) - ) # -> [1, 64, 200, 200] - return x.reshape(-1) - - def forward_part3( - self, - x - ): - x = x.reshape(1, 200, 200, 64) - x = x.permute(0, 3, 1, 2).contiguous() - # return [x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x] - bev_feature = self.img_bev_encoder_backbone(x) - occ_bev_feature = self.img_bev_encoder_neck(bev_feature) - - outs_occ = None - if self.wocc == True: - if self.uni_train == True: - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs_occ = self.occ_head(occ_bev_feature) - - outs_det3d = None - if self.wdet3d == True: - outs_det3d = self.pts_bbox_head([occ_bev_feature]) - outs = self.result_serialize(outs_det3d, outs_occ) - - # outs_inst_center = self.aux_centerness_head([occ_bev_feature]) - x = self.aux_centerness_head.shared_conv(occ_bev_feature) # (B, C'=share_conv_channel, H, W) - # вͬtask_head, - outs_inst_center_reg = self.aux_centerness_head.task_heads[0].reg(x) - outs.append(outs_inst_center_reg) - outs_inst_center_height = self.aux_centerness_head.task_heads[0].height(x) - outs.append(outs_inst_center_height) - outs_inst_center_heatmap = self.aux_centerness_head.task_heads[0].heatmap(x) - outs.append(outs_inst_center_heatmap) - - def forward_ori( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ): - x = self.img_backbone(img) - x = self.img_neck(x) - x = self.img_view_transformer.depth_net(x[0], mlp_input) - depth = x[:, :self.img_view_transformer.D].softmax(dim=1) - tran_feat = x[:, self.img_view_transformer.D:( - self.img_view_transformer.D + - self.img_view_transformer.out_channels)] - tran_feat = tran_feat.permute(0, 2, 3, 1) - x = TRTBEVPoolv2.apply(depth.contiguous(), tran_feat.contiguous(), - ranks_depth, ranks_feat, ranks_bev, - interval_starts, interval_lengths, - int(self.img_view_transformer.grid_size[0].item()), - int(self.img_view_transformer.grid_size[1].item()), - int(self.img_view_transformer.grid_size[2].item()) - ) - x = x.permute(0, 3, 1, 2).contiguous() - # return [x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x] - bev_feature = self.img_bev_encoder_backbone(x) - occ_bev_feature = self.img_bev_encoder_neck(bev_feature) - - outs_occ = None - if self.wocc == True: - if self.uni_train == True: - if self.upsample: - occ_bev_feature = F.interpolate(occ_bev_feature, scale_factor=2, - mode='bilinear', align_corners=True) - outs_occ = self.occ_head(occ_bev_feature) - - outs_det3d = None - if self.wdet3d == True: - outs_det3d = self.pts_bbox_head([occ_bev_feature]) - outs = self.result_serialize(outs_det3d, outs_occ) - - # outs_inst_center = self.aux_centerness_head([occ_bev_feature]) - x = self.aux_centerness_head.shared_conv(occ_bev_feature) # (B, C'=share_conv_channel, H, W) - # вͬtask_head, - outs_inst_center_reg = self.aux_centerness_head.task_heads[0].reg(x) - outs.append(outs_inst_center_reg) - outs_inst_center_height = self.aux_centerness_head.task_heads[0].height(x) - outs.append(outs_inst_center_height) - outs_inst_center_heatmap = self.aux_centerness_head.task_heads[0].heatmap(x) - outs.append(outs_inst_center_heatmap) - - return outs - - def forward_with_argmax( - self, - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ): - - outs = self.forward_ori( - img, - ranks_depth, - ranks_feat, - ranks_bev, - interval_starts, - interval_lengths, - mlp_input, - ) - pred_occ_label = outs[0].argmax(-1) - return pred_occ_label, *outs[1:] - - def get_bev_pool_input(self, input): - input = self.prepare_inputs(input) - coor = self.img_view_transformer.get_lidar_coor(*input[1:7]) - mlp_input = self.img_view_transformer.get_mlp_input(*input[1:7]) - # sensor2keyegos, ego2globals, intrins, post_rots, post_trans, bda) # (B, N_views, 27) - return self.img_view_transformer.voxel_pooling_prepare_v2(coor), mlp_input diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevstereo4d.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevstereo4d.py deleted file mode 100644 index 9d15dfc7a8a207190600a1328b0307a6db8ae411..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/detectors/bevstereo4d.py +++ /dev/null @@ -1,287 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn.functional as F -from mmcv.runner import force_fp32 - -from mmdet3d.models import DETECTORS -from mmdet3d.models import builder -from .bevdepth4d import BEVDepth4D -from mmdet.models.backbones.resnet import ResNet - - -@DETECTORS.register_module() -class BEVStereo4D(BEVDepth4D): - def __init__(self, **kwargs): - super(BEVStereo4D, self).__init__(**kwargs) - self.extra_ref_frames = 1 - self.temporal_frame = self.num_frame - self.num_frame += self.extra_ref_frames - - def extract_stereo_ref_feat(self, x): - """ - Args: - x: (B, N_views, 3, H, W) - Returns: - x: (B*N_views, C_stereo, fH_stereo, fW_stereo) - """ - B, N, C, imH, imW = x.shape - x = x.view(B * N, C, imH, imW) # (B*N_views, 3, H, W) - if isinstance(self.img_backbone, ResNet): - if self.img_backbone.deep_stem: - x = self.img_backbone.stem(x) - else: - x = self.img_backbone.conv1(x) - x = self.img_backbone.norm1(x) - x = self.img_backbone.relu(x) - x = self.img_backbone.maxpool(x) - for i, layer_name in enumerate(self.img_backbone.res_layers): - res_layer = getattr(self.img_backbone, layer_name) - x = res_layer(x) - return x - else: - x = self.img_backbone.patch_embed(x) - hw_shape = (self.img_backbone.patch_embed.DH, - self.img_backbone.patch_embed.DW) - if self.img_backbone.use_abs_pos_embed: - x = x + self.img_backbone.absolute_pos_embed - x = self.img_backbone.drop_after_pos(x) - - for i, stage in enumerate(self.img_backbone.stages): - x, hw_shape, out, out_hw_shape = stage(x, hw_shape) - out = out.view(-1, *out_hw_shape, - self.img_backbone.num_features[i]) - out = out.permute(0, 3, 1, 2).contiguous() - return out - - def prepare_bev_feat(self, img, sensor2keyego, ego2global, intrin, - post_rot, post_tran, bda, mlp_input, feat_prev_iv, - k2s_sensor, extra_ref_frame): - """ - Args: - img: (B, N_views, 3, H, W) - sensor2keyego: (B, N_views, 4, 4) - ego2global: (B, N_views, 4, 4) - intrin: (B, N_views, 3, 3) - post_rot: (B, N_views, 3, 3) - post_tran: (B, N_views, 3) - bda: (B, 3, 3) - mlp_input: (B, N_views, 27) - feat_prev_iv: (B*N_views, C_stereo, fH_stereo, fW_stereo) or None - k2s_sensor: (B, N_views, 4, 4) or None - extra_ref_frame: - Returns: - bev_feat: (B, C, Dy, Dx) - depth: (B*N, D, fH, fW) - stereo_feat: (B*N_views, C_stereo, fH_stereo, fW_stereo) - """ - if extra_ref_frame: - stereo_feat = self.extract_stereo_ref_feat(img) # (B*N_views, C_stereo, fH_stereo, fW_stereo) - return None, None, stereo_feat - # x: (B, N_views, C, fH, fW) - # stereo_feat: (B*N, C_stereo, fH_stereo, fW_stereo) - x, stereo_feat = self.image_encoder(img, stereo=True) - - # 建立cost volume 所需的信息. - metas = dict(k2s_sensor=k2s_sensor, # (B, N_views, 4, 4) - intrins=intrin, # (B, N_views, 3, 3) - post_rots=post_rot, # (B, N_views, 3, 3) - post_trans=post_tran, # (B, N_views, 3) - frustum=self.img_view_transformer.cv_frustum.to(x), # (D, fH_stereo, fW_stereo, 3) 3:(u, v, d) - cv_downsample=4, - downsample=self.img_view_transformer.downsample, - grid_config=self.img_view_transformer.grid_config, - cv_feat_list=[feat_prev_iv, stereo_feat] - ) - # bev_feat: (B, C * Dz(=1), Dy, Dx) - # depth: (B * N, D, fH, fW) - bev_feat, depth = self.img_view_transformer( - [x, sensor2keyego, ego2global, intrin, post_rot, post_tran, bda, - mlp_input], metas) - if self.pre_process: - bev_feat = self.pre_process_net(bev_feat)[0] # (B, C, Dy, Dx) - return bev_feat, depth, stereo_feat - - def extract_img_feat_sequential(self, inputs, feat_prev): - """ - Args: - inputs: - curr_img: (1, N_views, 3, H, W) - sensor2keyegos_curr: (N_prev, N_views, 4, 4) - ego2globals_curr: (N_prev, N_views, 4, 4) - intrins: (1, N_views, 3, 3) - sensor2keyegos_prev: (N_prev, N_views, 4, 4) - ego2globals_prev: (N_prev, N_views, 4, 4) - post_rots: (1, N_views, 3, 3) - post_trans: (1, N_views, 3, ) - bda_curr: (N_prev, 3, 3) - feat_prev_iv: - curr2adjsensor: (1, N_views, 4, 4) - feat_prev: (N_prev, C, Dy, Dx) - Returns: - - """ - imgs, sensor2keyegos_curr, ego2globals_curr, intrins = inputs[:4] - sensor2keyegos_prev, _, post_rots, post_trans, bda = inputs[4:9] - feat_prev_iv, curr2adjsensor = inputs[9:] - - bev_feat_list = [] - mlp_input = self.img_view_transformer.get_mlp_input( - sensor2keyegos_curr[0:1, ...], ego2globals_curr[0:1, ...], - intrins, post_rots, post_trans, bda[0:1, ...]) - inputs_curr = (imgs, sensor2keyegos_curr[0:1, ...], - ego2globals_curr[0:1, ...], intrins, post_rots, - post_trans, bda[0:1, ...], mlp_input, feat_prev_iv, - curr2adjsensor, False) - - # (1, C, Dx, Dy), (1*N, D, fH, fW) - bev_feat, depth, _ = self.prepare_bev_feat(*inputs_curr) - bev_feat_list.append(bev_feat) - - # align the feat_prev - _, C, H, W = feat_prev.shape - # feat_prev: (N_prev, C, Dy, Dx) - feat_prev = \ - self.shift_feature(feat_prev, # (N_prev, C, Dy, Dx) - [sensor2keyegos_curr, # (N_prev, N_views, 4, 4) - sensor2keyegos_prev], # (N_prev, N_views, 4, 4) - bda # (N_prev, 3, 3) - ) - bev_feat_list.append(feat_prev.view(1, (self.num_frame - 2) * C, H, W)) # (1, N_prev*C, Dy, Dx) - - bev_feat = torch.cat(bev_feat_list, dim=1) # (1, N_frames*C, Dy, Dx) - x = self.bev_encoder(bev_feat) - return [x], depth - - def extract_img_feat(self, - img_inputs, - img_metas, - pred_prev=False, - sequential=False, - **kwargs): - """ - Args: - img_inputs: - imgs: (B, N, 3, H, W) # N = 6 * (N_history + 1) - sensor2egos: (B, N, 4, 4) - ego2globals: (B, N, 4, 4) - intrins: (B, N, 3, 3) - post_rots: (B, N, 3, 3) - post_trans: (B, N, 3) - bda_rot: (B, 3, 3) - img_metas: - **kwargs: - Returns: - x: [(B, C', H', W'), ] - depth: (B*N_views, D, fH, fW) - """ - if sequential: - return self.extract_img_feat_sequential(img_inputs, kwargs['feat_prev']) - - imgs, sensor2keyegos, ego2globals, intrins, post_rots, post_trans, \ - bda, curr2adjsensor = self.prepare_inputs(img_inputs, stereo=True) - - """Extract features of images.""" - bev_feat_list = [] - depth_key_frame = None - feat_prev_iv = None - for fid in range(self.num_frame-1, -1, -1): - img, sensor2keyego, ego2global, intrin, post_rot, post_tran = \ - imgs[fid], sensor2keyegos[fid], ego2globals[fid], intrins[fid], \ - post_rots[fid], post_trans[fid] - key_frame = fid == 0 - extra_ref_frame = fid == self.num_frame-self.extra_ref_frames - if key_frame or self.with_prev: - if self.align_after_view_transfromation: - sensor2keyego, ego2global = sensor2keyegos[0], ego2globals[0] - mlp_input = self.img_view_transformer.get_mlp_input( - sensor2keyegos[0], ego2globals[0], intrin, - post_rot, post_tran, bda) # (B, N_views, 27) - - inputs_curr = (img, sensor2keyego, ego2global, intrin, - post_rot, post_tran, bda, mlp_input, - feat_prev_iv, curr2adjsensor[fid], - extra_ref_frame) - - if key_frame: - bev_feat, depth, feat_curr_iv = \ - self.prepare_bev_feat(*inputs_curr) - depth_key_frame = depth - else: - with torch.no_grad(): - bev_feat, depth, feat_curr_iv = \ - self.prepare_bev_feat(*inputs_curr) - - if not extra_ref_frame: - bev_feat_list.append(bev_feat) - - if not key_frame: - feat_prev_iv = feat_curr_iv - - if pred_prev: - assert self.align_after_view_transfromation - assert sensor2keyegos[0].shape[0] == 1 # batch_size = 1 - feat_prev = torch.cat(bev_feat_list[1:], dim=0) - - # (1, N_views, 4, 4) --> (N_prev, N_views, 4, 4) - ego2globals_curr = \ - ego2globals[0].repeat(self.num_frame - 2, 1, 1, 1) - # (1, N_views, 4, 4) --> (N_prev, N_views, 4, 4) - sensor2keyegos_curr = \ - sensor2keyegos[0].repeat(self.num_frame - 2, 1, 1, 1) - ego2globals_prev = torch.cat(ego2globals[1:-1], dim=0) # (N_prev, N_views, 4, 4) - sensor2keyegos_prev = torch.cat(sensor2keyegos[1:-1], dim=0) # (N_prev, N_views, 4, 4) - bda_curr = bda.repeat(self.num_frame - 2, 1, 1) # (N_prev, 3, 3) - - return feat_prev, [imgs[0], # (1, N_views, 3, H, W) - sensor2keyegos_curr, # (N_prev, N_views, 4, 4) - ego2globals_curr, # (N_prev, N_views, 4, 4) - intrins[0], # (1, N_views, 3, 3) - sensor2keyegos_prev, # (N_prev, N_views, 4, 4) - ego2globals_prev, # (N_prev, N_views, 4, 4) - post_rots[0], # (1, N_views, 3, 3) - post_trans[0], # (1, N_views, 3, ) - bda_curr, # (N_prev, 3, 3) - feat_prev_iv, - curr2adjsensor[0]] - - if not self.with_prev: - bev_feat_key = bev_feat_list[0] - if len(bev_feat_key.shape) == 4: - b, c, h, w = bev_feat_key.shape - bev_feat_list = \ - [torch.zeros([b, - c * (self.num_frame - - self.extra_ref_frames - 1), - h, w]).to(bev_feat_key), bev_feat_key] - else: - b, c, z, h, w = bev_feat_key.shape - bev_feat_list = \ - [torch.zeros([b, - c * (self.num_frame - - self.extra_ref_frames - 1), z, - h, w]).to(bev_feat_key), bev_feat_key] - - if self.align_after_view_transfromation: - for adj_id in range(self.num_frame-2): - bev_feat_list[adj_id] = self.shift_feature( - bev_feat_list[adj_id], # (B, C, Dy, Dx) - [sensor2keyegos[0], # (B, N_views, 4, 4) - sensor2keyegos[self.num_frame-2-adj_id]], # (B, N_views, 4, 4) - bda # (B, 3, 3) - ) # (B, C, Dy, Dx) - - bev_feat = torch.cat(bev_feat_list, dim=1) - x = self.bev_encoder(bev_feat) - return [x], depth_key_frame - - - - - - - - - - - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__init__.py deleted file mode 100644 index f1cd98d4dd8229cdb9b3adc413e48ac42e5ec4d5..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .cross_entropy_loss import CrossEntropyLoss -from .focal_loss import CustomFocalLoss - -__all__ = ['CrossEntropyLoss', 'CustomFocalLoss'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index cb33e4b212490b2df9a3ddb611743ad5110ae2e4..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/cross_entropy_loss.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/cross_entropy_loss.cpython-310.pyc deleted file mode 100644 index e311a004d56aaa2c4396b43875aed2d1726a8e94..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/cross_entropy_loss.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/focal_loss.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/focal_loss.cpython-310.pyc deleted file mode 100644 index fc41b0718b40689db94a5c8e27c76f71213c1ed8..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/focal_loss.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/lovasz_softmax.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/lovasz_softmax.cpython-310.pyc deleted file mode 100644 index aa929b184688e0f8072d26558a0f2d1fae774aa6..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/lovasz_softmax.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/semkitti_loss.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/semkitti_loss.cpython-310.pyc deleted file mode 100644 index 66fbed67f4835adefef5e16d480faeaa925eb517..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/__pycache__/semkitti_loss.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/semkitti_loss.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/semkitti_loss.py deleted file mode 100644 index 3dbeb4fde35fc4da8ba18c825bbae16e101a43a9..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/losses/semkitti_loss.py +++ /dev/null @@ -1,185 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -import numpy as np -# from mmcv.runner import BaseModule, force_fp32 -from torch.cuda.amp import autocast - -semantic_kitti_class_frequencies = np.array( - [ - 5.41773033e09, - 1.57835390e07, - 1.25136000e05, - 1.18809000e05, - 6.46799000e05, - 8.21951000e05, - 2.62978000e05, - 2.83696000e05, - 2.04750000e05, - 6.16887030e07, - 4.50296100e06, - 4.48836500e07, - 2.26992300e06, - 5.68402180e07, - 1.57196520e07, - 1.58442623e08, - 2.06162300e06, - 3.69705220e07, - 1.15198800e06, - 3.34146000e05, - ] -) - -kitti_class_names = [ - "empty", - "car", - "bicycle", - "motorcycle", - "truck", - "other-vehicle", - "person", - "bicyclist", - "motorcyclist", - "road", - "parking", - "sidewalk", - "other-ground", - "building", - "fence", - "vegetation", - "trunk", - "terrain", - "pole", - "traffic-sign", -] - - - -def inverse_sigmoid(x, sign='A'): - x = x.to(torch.float32) - while x >= 1-1e-5: - x = x - 1e-5 - - while x< 1e-5: - x = x + 1e-5 - - return -torch.log((1 / x) - 1) - -def KL_sep(p, target): - """ - KL divergence on nonzeros classes - """ - nonzeros = target != 0 - nonzero_p = p[nonzeros] - kl_term = F.kl_div(torch.log(nonzero_p), target[nonzeros], reduction="sum") - return kl_term - - -def geo_scal_loss(pred, ssc_target, ignore_index=255, non_empty_idx=0): - - # Get softmax probabilities - pred = F.softmax(pred, dim=1) - - # Compute empty and nonempty probabilities - empty_probs = pred[:, non_empty_idx] - nonempty_probs = 1 - empty_probs - - # Remove unknown voxels - mask = ssc_target != ignore_index - nonempty_target = ssc_target != non_empty_idx - nonempty_target = nonempty_target[mask].float() - nonempty_probs = nonempty_probs[mask] - empty_probs = empty_probs[mask] - - eps = 1e-5 - intersection = (nonempty_target * nonempty_probs).sum() - precision = intersection / (nonempty_probs.sum()+eps) - recall = intersection / (nonempty_target.sum()+eps) - spec = ((1 - nonempty_target) * (empty_probs)).sum() / ((1 - nonempty_target).sum()+eps) - with autocast(False): - return ( - F.binary_cross_entropy_with_logits(inverse_sigmoid(precision, 'A'), torch.ones_like(precision)) - + F.binary_cross_entropy_with_logits(inverse_sigmoid(recall, 'B'), torch.ones_like(recall)) - + F.binary_cross_entropy_with_logits(inverse_sigmoid(spec, 'C'), torch.ones_like(spec)) - ) - - -def sem_scal_loss(pred_, ssc_target, ignore_index=255): - # Get softmax probabilities - with autocast(False): - pred = F.softmax(pred_, dim=1) # (B, n_class, Dx, Dy, Dz) - loss = 0 - count = 0 - mask = ssc_target != ignore_index - n_classes = pred.shape[1] - begin = 0 - for i in range(begin, n_classes-1): - # Get probability of class i - p = pred[:, i] # (B, Dx, Dy, Dz) - - # Remove unknown voxels - target_ori = ssc_target # (B, Dx, Dy, Dz) - p = p[mask] - target = ssc_target[mask] - - completion_target = torch.ones_like(target) - completion_target[target != i] = 0 - completion_target_ori = torch.ones_like(target_ori).float() - completion_target_ori[target_ori != i] = 0 - if torch.sum(completion_target) > 0: - count += 1.0 - nominator = torch.sum(p * completion_target) - loss_class = 0 - if torch.sum(p) > 0: - precision = nominator / (torch.sum(p)+ 1e-5) - loss_precision = F.binary_cross_entropy_with_logits( - inverse_sigmoid(precision, 'D'), torch.ones_like(precision) - ) - loss_class += loss_precision - if torch.sum(completion_target) > 0: - recall = nominator / (torch.sum(completion_target) +1e-5) - # loss_recall = F.binary_cross_entropy(recall, torch.ones_like(recall)) - - loss_recall = F.binary_cross_entropy_with_logits(inverse_sigmoid(recall, 'E'), torch.ones_like(recall)) - loss_class += loss_recall - if torch.sum(1 - completion_target) > 0: - specificity = torch.sum((1 - p) * (1 - completion_target)) / ( - torch.sum(1 - completion_target) + 1e-5 - ) - - loss_specificity = F.binary_cross_entropy_with_logits( - inverse_sigmoid(specificity, 'F'), torch.ones_like(specificity) - ) - loss_class += loss_specificity - loss += loss_class - # print(i, loss_class, loss_recall, loss_specificity) - l = loss/count - if torch.isnan(l): - from IPython import embed - embed() - exit() - return l - - -def CE_ssc_loss(pred, target, class_weights=None, ignore_index=255): - """ - :param: prediction: the predicted tensor, must be [BS, C, ...] - """ - - criterion = nn.CrossEntropyLoss( - weight=class_weights, ignore_index=ignore_index, reduction="mean" - ) - # from IPython import embed - # embed() - # exit() - with autocast(False): - loss = criterion(pred, target.long()) - - return loss - -def vel_loss(pred, gt): - with autocast(False): - return F.l1_loss(pred, gt) - - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__init__.py deleted file mode 100644 index 8ec70711641d9441eebd3ebbc1072c80cdc84fd0..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .depthnet import DepthNet - -__all__ = ['DepthNet'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 7e72baf6331b8b5cd7390d4fb2287f3f111a011d..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/depthnet.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/depthnet.cpython-310.pyc deleted file mode 100644 index 97388f4f02534c04ec4ebd90f84614d5c7592386..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/__pycache__/depthnet.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/depthnet.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/depthnet.py deleted file mode 100644 index ea55f9e6e6389e7771d1eef03aaa1f7600a99482..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/model_utils/depthnet.py +++ /dev/null @@ -1,476 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmdet.models.backbones.resnet import BasicBlock -from mmcv.cnn import build_conv_layer -from torch.cuda.amp.autocast_mode import autocast -from torch.utils.checkpoint import checkpoint - - -class _ASPPModule(nn.Module): - def __init__(self, inplanes, planes, kernel_size, padding, dilation, - BatchNorm): - super(_ASPPModule, self).__init__() - self.atrous_conv = nn.Conv2d( - inplanes, - planes, - kernel_size=kernel_size, - stride=1, - padding=padding, - dilation=dilation, - bias=False) - self.bn = BatchNorm(planes) - self.relu = nn.ReLU() - - self._init_weight() - - def forward(self, x): - x = self.atrous_conv(x) - x = self.bn(x) - - return self.relu(x) - - def _init_weight(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - torch.nn.init.kaiming_normal_(m.weight) - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - m.bias.data.zero_() - - -class ASPP(nn.Module): - def __init__(self, inplanes, mid_channels=256, BatchNorm=nn.BatchNorm2d): - super(ASPP, self).__init__() - dilations = [1, 6, 12, 18] - self.aspp1 = _ASPPModule( - inplanes, - mid_channels, - 1, - padding=0, - dilation=dilations[0], - BatchNorm=BatchNorm) - self.aspp2 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[1], - dilation=dilations[1], - BatchNorm=BatchNorm) - self.aspp3 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[2], - dilation=dilations[2], - BatchNorm=BatchNorm) - self.aspp4 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[3], - dilation=dilations[3], - BatchNorm=BatchNorm) - - self.global_avg_pool = nn.Sequential( - nn.AdaptiveAvgPool2d((1, 1)), - nn.Conv2d(inplanes, mid_channels, 1, stride=1, bias=False), - BatchNorm(mid_channels), - nn.ReLU(), - ) - self.conv1 = nn.Conv2d( - int(mid_channels * 5), inplanes, 1, bias=False) - self.bn1 = BatchNorm(inplanes) - self.relu = nn.ReLU() - self.dropout = nn.Dropout(0.5) - self._init_weight() - - def forward(self, x): - """ - Args: - x: (B*N, C, fH, fW) - Returns: - x: (B*N, C, fH, fW) - """ - x1 = self.aspp1(x) - x2 = self.aspp2(x) - x3 = self.aspp3(x) - x4 = self.aspp4(x) - x5 = self.global_avg_pool(x) - x5 = F.interpolate( - x5, size=x4.size()[2:], mode='bilinear', align_corners=True) - x = torch.cat((x1, x2, x3, x4, x5), dim=1) # (B*N, 5*C', fH, fW) - - x = self.conv1(x) # (B*N, C, fH, fW) - x = self.bn1(x) - x = self.relu(x) - - return self.dropout(x) - - def _init_weight(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - torch.nn.init.kaiming_normal_(m.weight) - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - m.bias.data.zero_() - - -class Mlp(nn.Module): - def __init__(self, - in_features, - hidden_features=None, - out_features=None, - act_layer=nn.ReLU, - drop=0.0): - super().__init__() - out_features = out_features or in_features - hidden_features = hidden_features or in_features - self.fc1 = nn.Linear(in_features, hidden_features) - self.act = act_layer() - self.drop1 = nn.Dropout(drop) - self.fc2 = nn.Linear(hidden_features, out_features) - self.drop2 = nn.Dropout(drop) - - def forward(self, x): - """ - Args: - x: (B*N_views, 27) - Returns: - x: (B*N_views, C) - """ - x = self.fc1(x) - x = self.act(x) - x = self.drop1(x) - x = self.fc2(x) - x = self.drop2(x) - return x - - -class SELayer(nn.Module): - def __init__(self, channels, act_layer=nn.ReLU, gate_layer=nn.Sigmoid): - super().__init__() - self.conv_reduce = nn.Conv2d(channels, channels, 1, bias=True) - self.act1 = act_layer() - self.conv_expand = nn.Conv2d(channels, channels, 1, bias=True) - self.gate = gate_layer() - - def forward(self, x, x_se): - """ - Args: - x: (B*N_views, C_mid, fH, fW) - x_se: (B*N_views, C_mid, 1, 1) - Returns: - x: (B*N_views, C_mid, fH, fW) - """ - x_se = self.conv_reduce(x_se) # (B*N_views, C_mid, 1, 1) - x_se = self.act1(x_se) # (B*N_views, C_mid, 1, 1) - x_se = self.conv_expand(x_se) # (B*N_views, C_mid, 1, 1) - return x * self.gate(x_se) # (B*N_views, C_mid, fH, fW) - - -class DepthNet(nn.Module): - def __init__(self, - in_channels, - mid_channels, - context_channels, - depth_channels, - use_dcn=True, - use_aspp=True, - with_cp=False, - stereo=False, - bias=0.0, - aspp_mid_channels=-1): - super(DepthNet, self).__init__() - self.reduce_conv = nn.Sequential( - nn.Conv2d( - in_channels, mid_channels, kernel_size=3, stride=1, padding=1), - nn.BatchNorm2d(mid_channels), - nn.ReLU(inplace=True), - ) - # 生成context feature - self.context_conv = nn.Conv2d( - mid_channels, context_channels, kernel_size=1, stride=1, padding=0) - - self.bn = nn.BatchNorm1d(27) - self.depth_mlp = Mlp(in_features=27, hidden_features=mid_channels, out_features=mid_channels) - self.depth_se = SELayer(channels=mid_channels) # NOTE: add camera-aware - self.context_mlp = Mlp(in_features=27, hidden_features=mid_channels, out_features=mid_channels) - self.context_se = SELayer(channels=mid_channels) # NOTE: add camera-aware - depth_conv_input_channels = mid_channels - downsample = None - - if stereo: - depth_conv_input_channels += depth_channels - downsample = nn.Conv2d(depth_conv_input_channels, - mid_channels, 1, 1, 0) - cost_volumn_net = [] - for stage in range(int(2)): - cost_volumn_net.extend([ - nn.Conv2d(depth_channels, depth_channels, kernel_size=3, - stride=2, padding=1), - nn.BatchNorm2d(depth_channels)]) - self.cost_volumn_net = nn.Sequential(*cost_volumn_net) - self.bias = bias - - # 3个残差blocks - depth_conv_list = [BasicBlock(depth_conv_input_channels, mid_channels, - downsample=downsample), - BasicBlock(mid_channels, mid_channels), - BasicBlock(mid_channels, mid_channels)] - if use_aspp: - if aspp_mid_channels < 0: - aspp_mid_channels = mid_channels - depth_conv_list.append(ASPP(mid_channels, aspp_mid_channels)) - if use_dcn: - depth_conv_list.append( - build_conv_layer( - cfg=dict( - type='DCN', - in_channels=mid_channels, - out_channels=mid_channels, - kernel_size=3, - padding=1, - groups=4, - im2col_step=128, - ))) - depth_conv_list.append( - nn.Conv2d( - mid_channels, - depth_channels, - kernel_size=1, - stride=1, - padding=0)) - self.depth_conv = nn.Sequential(*depth_conv_list) - self.with_cp = with_cp - self.depth_channels = depth_channels - - # ----------------------------------------- 用于建立cost volume ---------------------------------- - def gen_grid(self, metas, B, N, D, H, W, hi, wi): - """ - Args: - metas: dict{ - k2s_sensor: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - frustum: (D, fH_stereo, fW_stereo, 3) 3:(u, v, d) - cv_downsample: 4, - downsample: self.img_view_transformer.downsample=16, - grid_config: self.img_view_transformer.grid_config, - cv_feat_list: [feat_prev_iv, stereo_feat] - } - B: batchsize - N: N_views - D: D - H: fH_stereo - W: fW_stereo - hi: H_img - wi: W_img - Returns: - grid: (B*N_views, D*fH_stereo, fW_stereo, 2) - """ - frustum = metas['frustum'] # (D, fH_stereo, fW_stereo, 3) 3:(u, v, d) - # 逆图像增广: - points = frustum - metas['post_trans'].view(B, N, 1, 1, 1, 3) - points = torch.inverse(metas['post_rots']).view(B, N, 1, 1, 1, 3, 3) \ - .matmul(points.unsqueeze(-1)) # (B, N_views, D, fH_stereo, fW_stereo, 3, 1) - - # (u, v, d) --> (du, dv, d) - # (B, N_views, D, fH_stereo, fW_stereo, 3, 1) - points = torch.cat( - (points[..., :2, :] * points[..., 2:3, :], points[..., 2:3, :]), 5) - - # cur_pixel --> curr_camera --> prev_camera - rots = metas['k2s_sensor'][:, :, :3, :3].contiguous() - trans = metas['k2s_sensor'][:, :, :3, 3].contiguous() - combine = rots.matmul(torch.inverse(metas['intrins'])) - points = combine.view(B, N, 1, 1, 1, 3, 3).matmul(points) - points += trans.view(B, N, 1, 1, 1, 3, 1) # (B, N_views, D, fH_stereo, fW_stereo, 3, 1) - - neg_mask = points[..., 2, 0] < 1e-3 - # prev_camera --> prev_pixel - points = metas['intrins'].view(B, N, 1, 1, 1, 3, 3).matmul(points) - # (du, dv, d) --> (u, v) (B, N_views, D, fH_stereo, fW_stereo, 2, 1) - points = points[..., :2, :] / points[..., 2:3, :] - - # 图像增广 - points = metas['post_rots'][..., :2, :2].view(B, N, 1, 1, 1, 2, 2).matmul( - points).squeeze(-1) - points += metas['post_trans'][..., :2].view(B, N, 1, 1, 1, 2) # (B, N_views, D, fH_stereo, fW_stereo, 2) - - px = points[..., 0] / (wi - 1.0) * 2.0 - 1.0 - py = points[..., 1] / (hi - 1.0) * 2.0 - 1.0 - px[neg_mask] = -2 - py[neg_mask] = -2 - grid = torch.stack([px, py], dim=-1) # (B, N_views, D, fH_stereo, fW_stereo, 2) - grid = grid.view(B * N, D * H, W, 2) # (B*N_views, D*fH_stereo, fW_stereo, 2) - return grid - - def calculate_cost_volumn(self, metas): - """ - Args: - metas: dict{ - k2s_sensor: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - frustum: (D, fH_stereo, fW_stereo, 3) 3:(u, v, d) - cv_downsample: 4, - downsample: self.img_view_transformer.downsample=16, - grid_config: self.img_view_transformer.grid_config, - cv_feat_list: [feat_prev_iv, stereo_feat] - } - Returns: - cost_volumn: (B*N_views, D, fH_stereo, fW_stereo) - """ - prev, curr = metas['cv_feat_list'] # (B*N_views, C_stereo, fH_stereo, fW_stereo) - group_size = 4 - _, c, hf, wf = curr.shape # - hi, wi = hf * 4, wf * 4 # H_img, W_img - B, N, _ = metas['post_trans'].shape - D, H, W, _ = metas['frustum'].shape - grid = self.gen_grid(metas, B, N, D, H, W, hi, wi).to(curr.dtype) # (B*N_views, D*fH_stereo, fW_stereo, 2) - - prev = prev.view(B * N, -1, H, W) # (B*N_views, C_stereo, fH_stereo, fW_stereo) - curr = curr.view(B * N, -1, H, W) # (B*N_views, C_stereo, fH_stereo, fW_stereo) - cost_volumn = 0 - # process in group wise to save memory - for fid in range(curr.shape[1] // group_size): - # (B*N_views, group_size, fH_stereo, fW_stereo) - prev_curr = prev[:, fid * group_size:(fid + 1) * group_size, ...] - wrap_prev = F.grid_sample(prev_curr, grid, - align_corners=True, - padding_mode='zeros') # (B*N_views, group_size, D*fH_stereo, fW_stereo) - # (B*N_views, group_size, fH_stereo, fW_stereo) - curr_tmp = curr[:, fid * group_size:(fid + 1) * group_size, ...] - # (B*N_views, group_size, 1, fH_stereo, fW_stereo) - (B*N_views, group_size, D, fH_stereo, fW_stereo) - # --> (B*N_views, group_size, D, fH_stereo, fW_stereo) - # https://github.com/HuangJunJie2017/BEVDet/issues/278 - cost_volumn_tmp = curr_tmp.unsqueeze(2) - \ - wrap_prev.view(B * N, -1, D, H, W) - cost_volumn_tmp = cost_volumn_tmp.abs().sum(dim=1) # (B*N_views, D, fH_stereo, fW_stereo) - cost_volumn += cost_volumn_tmp # (B*N_views, D, fH_stereo, fW_stereo) - if not self.bias == 0: - invalid = wrap_prev[:, 0, ...].view(B * N, D, H, W) == 0 - cost_volumn[invalid] = cost_volumn[invalid] + self.bias - - # matching cost --> prob - cost_volumn = - cost_volumn - cost_volumn = cost_volumn.softmax(dim=1) - return cost_volumn - # ----------------------------------------- 用于建立cost volume -------------------------------------- - - def forward(self, x, mlp_input, stereo_metas=None): - """ - Args: - x: (B*N_views, C, fH, fW) - mlp_input: (B, N_views, 27) - stereo_metas: None or dict{ - k2s_sensor: (B, N_views, 4, 4) - intrins: (B, N_views, 3, 3) - post_rots: (B, N_views, 3, 3) - post_trans: (B, N_views, 3) - frustum: (D, fH_stereo, fW_stereo, 3) 3:(u, v, d) - cv_downsample: 4, - downsample: self.img_view_transformer.downsample=16, - grid_config: self.img_view_transformer.grid_config, - cv_feat_list: [feat_prev_iv, stereo_feat] - } - Returns: - x: (B*N_views, D+C_context, fH, fW) - """ - mlp_input = self.bn(mlp_input.reshape(-1, mlp_input.shape[-1])) # (B*N_views, 27) - x = self.reduce_conv(x) # (B*N_views, C_mid, fH, fW) - - # (B*N_views, 27) --> (B*N_views, C_mid) --> (B*N_views, C_mid, 1, 1) - context_se = self.context_mlp(mlp_input)[..., None, None] - context = self.context_se(x, context_se) # (B*N_views, C_mid, fH, fW) - context = self.context_conv(context) # (B*N_views, C_context, fH, fW) - - # (B*N_views, 27) --> (B*N_views, C_mid) --> (B*N_views, C_mid, 1, 1) - depth_se = self.depth_mlp(mlp_input)[..., None, None] - depth = self.depth_se(x, depth_se) # (B*N_views, C_mid, fH, fW) - - if not stereo_metas is None: - if stereo_metas['cv_feat_list'][0] is None: - BN, _, H, W = x.shape - scale_factor = float(stereo_metas['downsample'])/\ - stereo_metas['cv_downsample'] - cost_volumn = \ - torch.zeros((BN, self.depth_channels, - int(H*scale_factor), - int(W*scale_factor))).to(x) - else: - with torch.no_grad(): - # https://github.com/HuangJunJie2017/BEVDet/issues/278 - cost_volumn = self.calculate_cost_volumn(stereo_metas) # (B*N_views, D, fH_stereo, fW_stereo) - cost_volumn = self.cost_volumn_net(cost_volumn) # (B*N_views, D, fH, fW) - depth = torch.cat([depth, cost_volumn], dim=1) # (B*N_views, C_mid+D, fH, fW) - if self.with_cp: - depth = checkpoint(self.depth_conv, depth) - else: - # 3*res blocks +ASPP/DCN + Conv(c_mid-->D) - depth = self.depth_conv(depth) # x: (B*N_views, C_mid, fH, fW) --> (B*N_views, D, fH, fW) - return torch.cat([depth, context], dim=1) - - -class DepthAggregation(nn.Module): - """pixel cloud feature extraction.""" - - def __init__(self, in_channels, mid_channels, out_channels): - super(DepthAggregation, self).__init__() - - self.reduce_conv = nn.Sequential( - nn.Conv2d( - in_channels, - mid_channels, - kernel_size=3, - stride=1, - padding=1, - bias=False), - nn.BatchNorm2d(mid_channels), - nn.ReLU(inplace=True), - ) - - self.conv = nn.Sequential( - nn.Conv2d( - mid_channels, - mid_channels, - kernel_size=3, - stride=1, - padding=1, - bias=False), - nn.BatchNorm2d(mid_channels), - nn.ReLU(inplace=True), - nn.Conv2d( - mid_channels, - mid_channels, - kernel_size=3, - stride=1, - padding=1, - bias=False), - nn.BatchNorm2d(mid_channels), - nn.ReLU(inplace=True), - ) - - self.out_conv = nn.Sequential( - nn.Conv2d( - mid_channels, - out_channels, - kernel_size=3, - stride=1, - padding=1, - bias=True), - # nn.BatchNorm3d(out_channels), - # nn.ReLU(inplace=True), - ) - - @autocast(False) - def forward(self, x): - x = checkpoint(self.reduce_conv, x) - short_cut = x - x = checkpoint(self.conv, x) - x = short_cut + x - x = self.out_conv(x) - return x \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__init__.py deleted file mode 100644 index a034bc92d9a0bc9058dea712bd911822e51f9ac6..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .fpn import CustomFPN -from .view_transformer import LSSViewTransformer, LSSViewTransformerBEVDepth, LSSViewTransformerBEVStereo -from .lss_fpn import FPN_LSS - -__all__ = ['CustomFPN', 'FPN_LSS', 'LSSViewTransformer', 'LSSViewTransformerBEVDepth', 'LSSViewTransformerBEVStereo'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index bcafa8ba7987a15e980879a86fc35c3584d1d82c..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/fpn.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/fpn.cpython-310.pyc deleted file mode 100644 index 665b094fc5b36e810d03ddc6d16c1e778bcb73c1..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/fpn.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/lss_fpn.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/lss_fpn.cpython-310.pyc deleted file mode 100644 index d0b68f5cac2c83023e75a1988f9416b0165d5497..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/lss_fpn.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/view_transformer.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/view_transformer.cpython-310.pyc deleted file mode 100644 index 3f0fab2b31a0d9505844d158eceac6f043dbd675..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/__pycache__/view_transformer.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/lss_fpn.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/lss_fpn.py deleted file mode 100644 index 01fe805182af2bc5cb8831ce915bb4a78267103b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/models/necks/lss_fpn.py +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -import torch -import torch.nn as nn -from mmcv.cnn import build_norm_layer - -from torch.utils.checkpoint import checkpoint -from mmcv.cnn.bricks import ConvModule -from mmdet.models import NECKS - - -@NECKS.register_module() -class FPN_LSS(nn.Module): - def __init__(self, - in_channels, - out_channels, - scale_factor=4, - input_feature_index=(0, 2), - norm_cfg=dict(type='BN'), - extra_upsample=2, - lateral=None, - use_input_conv=False): - super(FPN_LSS, self).__init__() - self.input_feature_index = input_feature_index - self.extra_upsample = extra_upsample is not None - self.out_channels = out_channels - # 用于上采样high-level的feature map - self.up = nn.Upsample( - scale_factor=scale_factor, mode='bilinear', align_corners=True) - - channels_factor = 2 if self.extra_upsample else 1 - self.conv = nn.Sequential( - nn.Conv2d(in_channels, out_channels * channels_factor, kernel_size=3, padding=1, bias=False), - build_norm_layer(norm_cfg, out_channels * channels_factor)[1], - nn.ReLU(inplace=True), - nn.Conv2d(out_channels * channels_factor, out_channels * channels_factor, kernel_size=3, - padding=1, bias=False), - build_norm_layer(norm_cfg, out_channels * channels_factor)[1], - nn.ReLU(inplace=True), - ) - - if self.extra_upsample: - self.up2 = nn.Sequential( - nn.Upsample(scale_factor=extra_upsample, mode='bilinear', align_corners=True), - nn.Conv2d(out_channels * channels_factor, out_channels, kernel_size=3, padding=1, bias=False), - build_norm_layer(norm_cfg, out_channels)[1], - nn.ReLU(inplace=True), - nn.Conv2d(out_channels, out_channels, kernel_size=1, padding=0) - ) - - self.lateral = lateral is not None - if self.lateral: - self.lateral_conv = nn.Sequential( - nn.Conv2d(lateral, lateral, kernel_size=1, padding=0, bias=False), - build_norm_layer(norm_cfg, lateral)[1], - nn.ReLU(inplace=True) - ) - - def forward(self, feats): - """ - Args: - feats: List[Tensor,] multi-level features - List[(B, C1, H, W), (B, C2, H/2, W/2), (B, C3, H/4, W/4)] - Returns: - x: (B, C_out, 2*H, 2*W) - """ - x2, x1 = feats[self.input_feature_index[0]], feats[self.input_feature_index[1]] - if self.lateral: - x2 = self.lateral_conv(x2) - x1 = self.up(x1) # (B, C3, H, W) - x1 = torch.cat([x2, x1], dim=1) # (B, C1+C3, H, W) - x = self.conv(x1) # (B, C', H, W) - if self.extra_upsample: - x = self.up2(x) # (B, C_out, 2*H, 2*W) - return x - - -@NECKS.register_module() -class LSSFPN3D(nn.Module): - def __init__(self, - in_channels, - out_channels, - with_cp=False): - super().__init__() - self.up1 = nn.Upsample( - scale_factor=2, mode='trilinear', align_corners=True) - self.up2 = nn.Upsample( - scale_factor=4, mode='trilinear', align_corners=True) - - self.conv = ConvModule( - in_channels, - out_channels, - kernel_size=1, - stride=1, - padding=0, - bias=False, - conv_cfg=dict(type='Conv3d'), - norm_cfg=dict(type='BN3d', ), - act_cfg=dict(type='ReLU', inplace=True)) - self.with_cp = with_cp - - def forward(self, feats): - """ - Args: - feats: List[ - (B, C, Dz, Dy, Dx), - (B, 2C, Dz/2, Dy/2, Dx/2), - (B, 4C, Dz/4, Dy/4, Dx/4) - ] - Returns: - x: (B, C, Dz, Dy, Dx) - """ - x_8, x_16, x_32 = feats - x_16 = self.up1(x_16) # (B, 2C, Dz, Dy, Dx) - x_32 = self.up2(x_32) # (B, 4C, Dz, Dy, Dx) - x = torch.cat([x_8, x_16, x_32], dim=1) # (B, 7C, Dz, Dy, Dx) - if self.with_cp: - x = checkpoint(self.conv, x) - else: - x = self.conv(x) # (B, C, Dz, Dy, Dx) - return x - - - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__init__.py deleted file mode 100644 index 53a6016f95fab956344970634163062457b1a8c6..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .bev_pool import bev_pool -from .bev_pool_v2 import bev_pool_v2, TRTBEVPoolv2 -from .nearest_assign import nearest_assign - -__all__ = ['bev_pool', 'bev_pool_v2', 'TRTBEVPoolv2', 'nearest_assign'] \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 2afd66236849e721e5f6c029206dfeb261b1e2eb..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index b49345f9d078470ea387aa8f9b490b66ebbbad69..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/bev_pool.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/bev_pool.cpython-310.pyc deleted file mode 100644 index 31168b6ffb644d59c8291b4bd01f6d1015203871..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/__pycache__/bev_pool.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/bev_pool_ext.cpython-310-x86_64-linux-gnu.so b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/bev_pool_ext.cpython-310-x86_64-linux-gnu.so deleted file mode 100755 index fd37ac9c52f077d47e84099d7d5e868c80c2fc3c..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/bev_pool_ext.cpython-310-x86_64-linux-gnu.so and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.cpp deleted file mode 100644 index fc11da1fedeb1f022657c2cafa51375493e3eecb..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include "bev_max_pool.h" - - -/* - Function: pillar pooling (forward, cuda) - Args: - geom_feats : input features, FloatTensor[N, C] - _geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - out : output features, FloatTensor[b, d, h, w, c] -*/ -at::Tensor bev_max_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_feats.size(0); - int c = _geom_feats.size(1); - int n_intervals = _interval_lengths.size(0); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_geom_feats)); - const float* geom_feats = _geom_feats.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_geom_feats.dtype()).device(_geom_feats.device()); - at::Tensor _out = torch::zeros({b, d, h, w, c}, options); // (B, D=Dz, H=Dy, W=Dx, C) - float* out = _out.data_ptr(); - bev_max_pool( - b, d, h, w, n, c, n_intervals, geom_feats, - geom_coords, interval_starts, interval_lengths, out - ); - return _out; -} - - -/* - Function: pillar pooling (backward, cuda) - Args: - out_grad : input features, FloatTensor[B, D, H, W, C] - geom_coords : input coordinates, IntTensor[N, 4] - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - x_grad : output features, FloatTensor[N, C] -*/ -at::Tensor bev_max_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_coords.size(0); - int c = _out_grad.size(4); - int n_intervals = _interval_lengths.size(0); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_out_grad)); - const float* out_grad = _out_grad.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_out_grad.dtype()).device(_out_grad.device()); - at::Tensor _x_grad = torch::zeros({n, c}, options); // (N, C) - float* x_grad = _x_grad.data_ptr(); - - bev_max_pool_grad( - b, d, h, w, n, c, n_intervals, out_grad, - geom_coords, interval_starts, interval_lengths, x_grad - ); - - return _x_grad; -} - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.h b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.h deleted file mode 100644 index f1c2d7a9189308a80831b21646a4fd9b6ca5f935..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _BEV_MAX_POOL_H -#define _BEV_MAX_POOL_H - -#include -#include - -at::Tensor bev_max_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - -at::Tensor bev_max_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - - -// CUDA function declarations -void bev_max_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* x, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* out); - -void bev_max_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* x_grad); - - -#endif \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.cu b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.cu deleted file mode 100644 index f8207924186218752129302a352cf5ee5ec6e29c..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.cu +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include "bev_max_pool.h" - -/* - Function: pillar pooling - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - geom_feats : input features, FloatTensor[n, c] - geom_coords : input coordinates, IntTensor[n, 4] 4: (x_id, y_id, z_id, batch_id) - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - out : output features, FloatTensor[b, d, h, w, c] -*/ -__global__ void bev_max_pool_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ geom_feats, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ out) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - const int* cur_geom_coords = geom_coords + interval_start * 4; // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - const float* cur_geom_feats = geom_feats + interval_start * c + cur_c; - float* cur_out = out + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - float pmax = 0; - for(int i = 0; i < interval_length; i++){ - if (cur_geom_feats[i * c] > pmax) - pmax = cur_geom_feats[i * c]; - } - *cur_out = pmax; -} - - -/* - Function: pillar pooling backward - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - out_grad : gradient of the BEV fmap from top, FloatTensor[b, d, h, w, c] - geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[n_intervals] - interval_starts : starting position for pooled point, IntTensor[n_intervals] - x_grad : gradient of the image fmap, FloatTensor -*/ -__global__ void bev_max_pool_grad_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ out_grad, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ x_grad) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - - // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - // 该pillar中所有点的梯度 与 该pillar特征的梯度相同. - const int* cur_geom_coords = geom_coords + interval_start * 4; - float* cur_x_grad = x_grad + interval_start * c + cur_c; - - const float* cur_out_grad = out_grad + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - - int max_id = 0; - float pmax = 0; - for(int i = 0; i < interval_length; i++){ - if (cur_x_grad[i * c] > pmax) - { - pmax = cur_x_grad[i * c]; - max_id = i; - } - } - cur_x_grad[max_id * c] = *cur_out_grad; -} - -void bev_max_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* geom_feats, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* out) { - bev_max_pool_kernel<<<(int)ceil(((double)n_intervals * c / 256)), 256>>>( - b, d, h, w, n, c, n_intervals, geom_feats, geom_coords, interval_starts, interval_lengths, out - ); -} - -void bev_max_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* x_grad) { - bev_max_pool_grad_kernel<<<(int)ceil(((double)n_intervals * c / 256)), 256>>>( - b, d, h, w, n, c, n_intervals, out_grad, geom_coords, interval_starts, interval_lengths, x_grad - ); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.hip b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.hip deleted file mode 100644 index d07ae7fbbb7e878da7860c038419c7a558725f65..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_cuda.hip +++ /dev/null @@ -1,112 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include "hip/hip_runtime.h" -#include -#include -#include "bev_max_pool_hip.h" - -/* - Function: pillar pooling - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - geom_feats : input features, FloatTensor[n, c] - geom_coords : input coordinates, IntTensor[n, 4] 4: (x_id, y_id, z_id, batch_id) - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - out : output features, FloatTensor[b, d, h, w, c] -*/ -__global__ void bev_max_pool_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ geom_feats, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ out) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - const int* cur_geom_coords = geom_coords + interval_start * 4; // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - const float* cur_geom_feats = geom_feats + interval_start * c + cur_c; - float* cur_out = out + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - float pmax = 0; - for(int i = 0; i < interval_length; i++){ - if (cur_geom_feats[i * c] > pmax) - pmax = cur_geom_feats[i * c]; - } - *cur_out = pmax; -} - - -/* - Function: pillar pooling backward - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - out_grad : gradient of the BEV fmap from top, FloatTensor[b, d, h, w, c] - geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[n_intervals] - interval_starts : starting position for pooled point, IntTensor[n_intervals] - x_grad : gradient of the image fmap, FloatTensor -*/ -__global__ void bev_max_pool_grad_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ out_grad, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ x_grad) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - - // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - // 该pillar中所有点的梯度 与 该pillar特征的梯度相同. - const int* cur_geom_coords = geom_coords + interval_start * 4; - float* cur_x_grad = x_grad + interval_start * c + cur_c; - - const float* cur_out_grad = out_grad + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - - int max_id = 0; - float pmax = 0; - for(int i = 0; i < interval_length; i++){ - if (cur_x_grad[i * c] > pmax) - { - pmax = cur_x_grad[i * c]; - max_id = i; - } - } - cur_x_grad[max_id * c] = *cur_out_grad; -} - -void bev_max_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* geom_feats, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* out) { - hipLaunchKernelGGL(( bev_max_pool_kernel), dim3((int)ceil(((double)n_intervals * c / 256))), dim3(256), 0, 0, - b, d, h, w, n, c, n_intervals, geom_feats, geom_coords, interval_starts, interval_lengths, out - ); -} - -void bev_max_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* x_grad) { - hipLaunchKernelGGL(( bev_max_pool_grad_kernel), dim3((int)ceil(((double)n_intervals * c / 256))), dim3(256), 0, 0, - b, d, h, w, n, c, n_intervals, out_grad, geom_coords, interval_starts, interval_lengths, x_grad - ); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.cpp deleted file mode 100644 index 30f78b7ef85838455e2ebce66ab1687ec35b27bb..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include -#include "bev_max_pool_hip.h" - - -/* - Function: pillar pooling (forward, cuda) - Args: - geom_feats : input features, FloatTensor[N, C] - _geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - out : output features, FloatTensor[b, d, h, w, c] -*/ -at::Tensor bev_max_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_feats.size(0); - int c = _geom_feats.size(1); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_geom_feats)); - const float* geom_feats = _geom_feats.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_geom_feats.dtype()).device(_geom_feats.device()); - at::Tensor _out = torch::zeros({b, d, h, w, c}, options); // (B, D=Dz, H=Dy, W=Dx, C) - float* out = _out.data_ptr(); - bev_max_pool( - b, d, h, w, n, c, n_intervals, geom_feats, - geom_coords, interval_starts, interval_lengths, out - ); - return _out; -} - - -/* - Function: pillar pooling (backward, cuda) - Args: - out_grad : input features, FloatTensor[B, D, H, W, C] - geom_coords : input coordinates, IntTensor[N, 4] - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - x_grad : output features, FloatTensor[N, C] -*/ -at::Tensor bev_max_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_coords.size(0); - int c = _out_grad.size(4); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_out_grad)); - const float* out_grad = _out_grad.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_out_grad.dtype()).device(_out_grad.device()); - at::Tensor _x_grad = torch::zeros({n, c}, options); // (N, C) - float* x_grad = _x_grad.data_ptr(); - - bev_max_pool_grad( - b, d, h, w, n, c, n_intervals, out_grad, - geom_coords, interval_starts, interval_lengths, x_grad - ); - - return _x_grad; -} - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.h b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.h deleted file mode 100644 index f4fd8ee645d2b1615890e41cbf9213b22fb0b06b..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_max_pool_hip.h +++ /dev/null @@ -1,34 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#ifndef _BEV_MAX_POOL_H -#define _BEV_MAX_POOL_H - -#include -#include - -at::Tensor bev_max_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - -at::Tensor bev_max_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - - -// CUDA function declarations -void bev_max_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* x, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* out); - -void bev_max_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* x_grad); - - -#endif \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling.cpp deleted file mode 100644 index 7ab0fa6b6389648da7ce8ab0c7056c678a9d9647..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include "bev_sum_pool.h" -#include "bev_max_pool.h" - - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("bev_sum_pool_forward", &bev_sum_pool_forward, - "bev_sum_pool_forward"); - m.def("bev_sum_pool_backward", &bev_sum_pool_backward, - "bev_sum_pool_backward"); - m.def("bev_max_pool_forward", &bev_max_pool_forward, - "bev_max_pool_forward"); - m.def("bev_max_pool_backward", &bev_max_pool_backward, - "bev_max_pool_backward"); -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling_hip.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling_hip.cpp deleted file mode 100644 index 9f39c4ff9fbff1c8d98f553f3850484ab69a887a..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_pooling_hip.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include - -#include "bev_sum_pool_hip.h" -#include "bev_max_pool_hip.h" - - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("bev_sum_pool_forward", &bev_sum_pool_forward, - "bev_sum_pool_forward"); - m.def("bev_sum_pool_backward", &bev_sum_pool_backward, - "bev_sum_pool_backward"); - m.def("bev_max_pool_forward", &bev_max_pool_forward, - "bev_max_pool_forward"); - m.def("bev_max_pool_backward", &bev_max_pool_backward, - "bev_max_pool_backward"); -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.cpp deleted file mode 100644 index 261db9ac43cfd422bac5f550c3795c664ef058b8..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include "bev_sum_pool.h" - -/* - Function: pillar pooling (forward, cuda) - Args: - geom_feats : input features, FloatTensor[N, C] - _geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - out : output features, FloatTensor[b, d, h, w, c] -*/ -at::Tensor bev_sum_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_feats.size(0); - int c = _geom_feats.size(1); - int n_intervals = _interval_lengths.size(0); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_geom_feats)); - const float* geom_feats = _geom_feats.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_geom_feats.dtype()).device(_geom_feats.device()); - at::Tensor _out = torch::zeros({b, d, h, w, c}, options); // (B, D=Dz, H=Dy, W=Dx, C) - float* out = _out.data_ptr(); - bev_sum_pool( - b, d, h, w, n, c, n_intervals, geom_feats, - geom_coords, interval_starts, interval_lengths, out - ); - return _out; -} - - -/* - Function: pillar pooling (backward, cuda) - Args: - out_grad : input features, FloatTensor[B, D, H, W, C] - geom_coords : input coordinates, IntTensor[N, 4] - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - x_grad : output features, FloatTensor[N, C] -*/ -at::Tensor bev_sum_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_coords.size(0); - int c = _out_grad.size(4); - int n_intervals = _interval_lengths.size(0); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_out_grad)); - const float* out_grad = _out_grad.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_out_grad.dtype()).device(_out_grad.device()); - at::Tensor _x_grad = torch::zeros({n, c}, options); // (N, C) - float* x_grad = _x_grad.data_ptr(); - - bev_sum_pool_grad( - b, d, h, w, n, c, n_intervals, out_grad, - geom_coords, interval_starts, interval_lengths, x_grad - ); - - return _x_grad; -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.h b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.h deleted file mode 100644 index 3478e11ec3627a0e00c0e0c52646c8ad9590a964..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _BEV_SUM_POOL_H -#define _BEV_SUM_POOL_H - -#include -#include - -at::Tensor bev_sum_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - -at::Tensor bev_sum_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - - -// CUDA function declarations -void bev_sum_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* x, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* out); - -void bev_sum_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* x_grad); - - -#endif \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.cu b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.cu deleted file mode 100644 index 0e5678b3457b5c8cec00dd432275ca19c9a62bc2..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.cu +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include "bev_sum_pool.h" - -/* - Function: pillar pooling - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - geom_feats : input features, FloatTensor[n, c] - geom_coords : input coordinates, IntTensor[n, 4] 4: (x_id, y_id, z_id, batch_id) - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - out : output features, FloatTensor[b, d, h, w, c] -*/ -__global__ void bev_sum_pool_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ geom_feats, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ out) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - const int* cur_geom_coords = geom_coords + interval_start * 4; // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - const float* cur_geom_feats = geom_feats + interval_start * c + cur_c; - float* cur_out = out + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - float psum = 0; - for(int i = 0; i < interval_length; i++){ - psum += cur_geom_feats[i * c]; - } - *cur_out = psum; -} - - -/* - Function: pillar pooling backward - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - out_grad : gradient of the BEV fmap from top, FloatTensor[b, d, h, w, c] - geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[n_intervals] - interval_starts : starting position for pooled point, IntTensor[n_intervals] - x_grad : gradient of the image fmap, FloatTensor -*/ -__global__ void bev_sum_pool_grad_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ out_grad, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ x_grad) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - - // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - // 该pillar中所有点的梯度 与 该pillar特征的梯度相同. - const int* cur_geom_coords = geom_coords + interval_start * 4; - float* cur_x_grad = x_grad + interval_start * c + cur_c; - - const float* cur_out_grad = out_grad + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - for(int i = 0; i < interval_length; i++){ - cur_x_grad[i * c] = *cur_out_grad; - } - -} - -void bev_sum_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* geom_feats, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* out) { - bev_sum_pool_kernel<<<(int)ceil(((double)n_intervals * c / 256)), 256>>>( - b, d, h, w, n, c, n_intervals, geom_feats, geom_coords, interval_starts, interval_lengths, out - ); -} - -void bev_sum_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* x_grad) { - bev_sum_pool_grad_kernel<<<(int)ceil(((double)n_intervals * c / 256)), 256>>>( - b, d, h, w, n, c, n_intervals, out_grad, geom_coords, interval_starts, interval_lengths, x_grad - ); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.hip b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.hip deleted file mode 100644 index bc52145f9a4606e2f362a451a000b1f5a14569ce..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_cuda.hip +++ /dev/null @@ -1,104 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include "hip/hip_runtime.h" -#include -#include -#include "bev_sum_pool_hip.h" - -/* - Function: pillar pooling - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - geom_feats : input features, FloatTensor[n, c] - geom_coords : input coordinates, IntTensor[n, 4] 4: (x_id, y_id, z_id, batch_id) - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - out : output features, FloatTensor[b, d, h, w, c] -*/ -__global__ void bev_sum_pool_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ geom_feats, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ out) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - const int* cur_geom_coords = geom_coords + interval_start * 4; // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - const float* cur_geom_feats = geom_feats + interval_start * c + cur_c; - float* cur_out = out + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - float psum = 0; - for(int i = 0; i < interval_length; i++){ - psum += cur_geom_feats[i * c]; - } - *cur_out = psum; -} - - -/* - Function: pillar pooling backward - Args: - b : batch size - d : depth of the feature map - h : height of pooled feature map - w : width of pooled feature map - n : number of input points - c : number of channels - n_intervals : number of unique points - out_grad : gradient of the BEV fmap from top, FloatTensor[b, d, h, w, c] - geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[n_intervals] - interval_starts : starting position for pooled point, IntTensor[n_intervals] - x_grad : gradient of the image fmap, FloatTensor -*/ -__global__ void bev_sum_pool_grad_kernel(int b, int d, int h, int w, int n, int c, int n_intervals, - const float *__restrict__ out_grad, - const int *__restrict__ geom_coords, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ x_grad) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - int index = idx / c; - int cur_c = idx % c; - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; - int interval_length = interval_lengths[index]; - - // 当前负责计算的pillar的坐标 4: (x_id, y_id, z_id, batch_id) - // 该pillar中所有点的梯度 与 该pillar特征的梯度相同. - const int* cur_geom_coords = geom_coords + interval_start * 4; - float* cur_x_grad = x_grad + interval_start * c + cur_c; - - const float* cur_out_grad = out_grad + cur_geom_coords[3] * d * h * w * c + - cur_geom_coords[2] * h * w * c + cur_geom_coords[1] * w * c + - cur_geom_coords[0] * c + cur_c; - for(int i = 0; i < interval_length; i++){ - cur_x_grad[i * c] = *cur_out_grad; - } - -} - -void bev_sum_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* geom_feats, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* out) { - hipLaunchKernelGGL(( bev_sum_pool_kernel), dim3((int)ceil(((double)n_intervals * c / 256))), dim3(256), 0, 0, - b, d, h, w, n, c, n_intervals, geom_feats, geom_coords, interval_starts, interval_lengths, out - ); -} - -void bev_sum_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_coords, const int* interval_starts, const int* interval_lengths, float* x_grad) { - hipLaunchKernelGGL(( bev_sum_pool_grad_kernel), dim3((int)ceil(((double)n_intervals * c / 256))), dim3(256), 0, 0, - b, d, h, w, n, c, n_intervals, out_grad, geom_coords, interval_starts, interval_lengths, x_grad - ); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.cpp deleted file mode 100644 index 9cc9aa591d6b7ba4efabd4ca3b0ba83a0fbb1c11..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include -#include "bev_sum_pool_hip.h" - -/* - Function: pillar pooling (forward, cuda) - Args: - geom_feats : input features, FloatTensor[N, C] - _geom_coords : input coordinates, IntTensor[N, 4] 4: (x_id, y_id, z_id, batch_id) - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - out : output features, FloatTensor[b, d, h, w, c] -*/ -at::Tensor bev_sum_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_feats.size(0); - int c = _geom_feats.size(1); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_geom_feats)); - const float* geom_feats = _geom_feats.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_geom_feats.dtype()).device(_geom_feats.device()); - at::Tensor _out = torch::zeros({b, d, h, w, c}, options); // (B, D=Dz, H=Dy, W=Dx, C) - float* out = _out.data_ptr(); - bev_sum_pool( - b, d, h, w, n, c, n_intervals, geom_feats, - geom_coords, interval_starts, interval_lengths, out - ); - return _out; -} - - -/* - Function: pillar pooling (backward, cuda) - Args: - out_grad : input features, FloatTensor[B, D, H, W, C] - geom_coords : input coordinates, IntTensor[N, 4] - interval_lengths : how many points in each pooled point, IntTensor[N_pillar, ] - interval_starts : starting position for pooled point, IntTensor [N_pillar, ] - Return: - x_grad : output features, FloatTensor[N, C] -*/ -at::Tensor bev_sum_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -) { - int n = _geom_coords.size(0); - int c = _out_grad.size(4); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_out_grad)); - const float* out_grad = _out_grad.data_ptr(); - const int* geom_coords = _geom_coords.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - auto options = - torch::TensorOptions().dtype(_out_grad.dtype()).device(_out_grad.device()); - at::Tensor _x_grad = torch::zeros({n, c}, options); // (N, C) - float* x_grad = _x_grad.data_ptr(); - - bev_sum_pool_grad( - b, d, h, w, n, c, n_intervals, out_grad, - geom_coords, interval_starts, interval_lengths, x_grad - ); - - return _x_grad; -} \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.h b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.h deleted file mode 100644 index c8608e5b7c80382222917f6faf993da0806fc330..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool/src/bev_sum_pool_hip.h +++ /dev/null @@ -1,34 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#ifndef _BEV_SUM_POOL_H -#define _BEV_SUM_POOL_H - -#include -#include - -at::Tensor bev_sum_pool_forward( - const at::Tensor _geom_feats, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - -at::Tensor bev_sum_pool_backward( - const at::Tensor _out_grad, - const at::Tensor _geom_coords, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts, - int b, int d, int h, int w -); - - -// CUDA function declarations -void bev_sum_pool(int b, int d, int h, int w, int n, int c, int n_intervals, const float* x, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* out); - -void bev_sum_pool_grad(int b, int d, int h, int w, int n, int c, int n_intervals, const float* out_grad, - const int* geom_feats, const int* interval_starts, const int* interval_lengths, float* x_grad); - - -#endif \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__init__.py deleted file mode 100644 index f493cbd3cbeabf34babccb1a17099909a1c80bb1..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -from .bev_pool import bev_pool_v2, TRTBEVPoolv2 \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 3a7fd639d61bf80c5a1d94040736f0df48433406..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/bev_pool.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/bev_pool.cpython-310.pyc deleted file mode 100644 index 5efbc01423fd8d3613e8c179550a7d53282daffd..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/__pycache__/bev_pool.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/bev_pool_v2_ext.cpython-310-x86_64-linux-gnu.so b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/bev_pool_v2_ext.cpython-310-x86_64-linux-gnu.so deleted file mode 100755 index f80e9e92c2ab4c3bccaa0a629a9054ddd2540842..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/bev_pool_v2_ext.cpython-310-x86_64-linux-gnu.so and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_cuda.hip b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_cuda.hip deleted file mode 100644 index a114083fbe9adfc8b43edf71e888c281fda4451c..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_cuda.hip +++ /dev/null @@ -1,145 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include "hip/hip_runtime.h" -// Copyright (c) Phigent Robotics. All rights reserved. -// Reference https://arxiv.org/abs/2211.17111 - -#include -#include - -/* - Function: pillar pooling - Args: - c : number of channels - n_intervals : number of unique points - depth : input depth, FloatTensor[b,n,d,h,w] - feat : input feat, FloatTensor[b,n,h,w,c] - ranks_depth : input index of depth, IntTensor[n] - ranks_feat : input index of feat, IntTensor[n] - ranks_bev : output index, IntTensor[n] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - out : output features, FloatTensor[b, d, h, w, c] -*/ -__global__ void bev_pool_v2_kernel(int c, int n_intervals, - const float *__restrict__ depth, - const float *__restrict__ feat, - const int *__restrict__ ranks_depth, - const int *__restrict__ ranks_feat, - const int *__restrict__ ranks_bev, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ out) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; // 该pillar的cur_c特征对应的索引. - int index = idx / c; // pillar id - int cur_c = idx % c; // channel id - if (index >= n_intervals) return; - int interval_start = interval_starts[index]; // 该pillar的起始索引. - int interval_length = interval_lengths[index]; // 该pillar的包含的点数量. - float psum = 0; - const float* cur_depth; - const float* cur_feat; - for(int i = 0; i < interval_length; i++){ - // ranks_depth[interval_start+i]: depth索引, 介于(0, B*N*D*fH*fW-1)之间. - cur_depth = depth + ranks_depth[interval_start+i]; - // ranks_feat[interval_start+i]: feature索引, 介于(0, B*N*fH*fW-1)之间. - cur_feat = feat + ranks_feat[interval_start+i] * c + cur_c; // - psum += *cur_feat * *cur_depth; // 聚合该pillar对应的cur_c特征. - } - - const int* cur_rank = ranks_bev + interval_start; // 该pillar在BEV grids中对应的索引. - float* cur_out = out + *cur_rank * c + cur_c; // 该cur_c特征对应的索引位置. - *cur_out = psum; -} - - -/* - Function: pillar pooling backward - Args: - c : number of channels - n_intervals : number of unique points - out_grad : gradient of the BEV fmap from top, FloatTensor[b, d, h, w, c] - depth : input depth, FloatTensor[b,n,d,h,w] - feat : input feat, FloatTensor[b,n,h,w,c] - ranks_depth : input index of depth, IntTensor[n] - ranks_feat : input index of feat, IntTensor[n] - ranks_bev : output index, IntTensor[n] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - depth_grad : gradient of the depth fmap, FloatTensor - feat_grad : gradient of the feature fmap, FloatTensor -*/ -__global__ void bev_pool_grad_kernel(int c, int n_intervals, - const float *__restrict__ out_grad, - const float *__restrict__ depth, - const float *__restrict__ feat, - const int *__restrict__ ranks_depth, - const int *__restrict__ ranks_feat, - const int *__restrict__ ranks_bev, - const int *__restrict__ interval_starts, - const int *__restrict__ interval_lengths, - float* __restrict__ depth_grad, - float* __restrict__ feat_grad) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; // 该pillar对应的thread - if (idx >= n_intervals) return; - int interval_start = interval_starts[idx]; // 该pillar的起始索引. - int interval_length = interval_lengths[idx]; // 该pillar的包含的点数量. - - const int* cur_rank; - const float* cur_out_grad; - const float* cur_out_grad_start; - - const float* cur_feat; - const float* cur_feat_start; - float* cur_depth_grad; - float grad_sum; - for(int i = 0; i < interval_length; i++){ - cur_rank = ranks_bev + interval_start + i; // 该pillar在BEV grids中对应的索引. - cur_out_grad_start = out_grad + * cur_rank * c; // pillar feature 的 grad. - cur_feat_start = feat + ranks_feat[interval_start+i] * c; - - grad_sum = 0; - for(int cur_c = 0; cur_c < c; cur_c++){ - cur_out_grad = cur_out_grad_start + cur_c; - cur_feat = cur_feat_start + cur_c; - grad_sum += *cur_out_grad * *cur_feat; - } - - cur_depth_grad = depth_grad + ranks_depth[interval_start+i]; - *cur_depth_grad = grad_sum; - } - - float* cur_feat_grad; - const float* cur_depth; - for(int cur_c = 0; cur_c < c; cur_c++){ - grad_sum = 0; - for(int i = 0; i < interval_length; i++){ - cur_rank = ranks_bev + interval_start + i; - cur_out_grad = out_grad + *cur_rank * c + cur_c; - - cur_depth = depth + ranks_depth[interval_start+i]; - grad_sum += *cur_out_grad * *cur_depth; - } - cur_feat_grad = feat_grad + ranks_feat[interval_start] * c + cur_c ; - * cur_feat_grad = grad_sum; - } -} - - - -void bev_pool_v2(int c, int n_intervals, const float* depth, const float* feat, const int* ranks_depth, - const int* ranks_feat, const int* ranks_bev, const int* interval_starts, const int* interval_lengths, float* out) { - hipLaunchKernelGGL(( bev_pool_v2_kernel), dim3((int)ceil(((double)n_intervals * c / 256))), dim3(256), 0, 0, - c, n_intervals, depth, feat, ranks_depth, ranks_feat, - ranks_bev, interval_starts, interval_lengths, out - ); -} - -void bev_pool_v2_grad(int c, int n_intervals, const float* out_grad, - const float* depth, const float* feat, const int* ranks_depth, const int* ranks_feat, - const int* ranks_bev, const int* interval_starts, const int* interval_lengths, float* depth_grad, float* feat_grad) { - hipLaunchKernelGGL(( bev_pool_grad_kernel), dim3((int)ceil(((double)n_intervals / 256))), dim3(256), 0, 0, - c, n_intervals, out_grad, depth, feat, ranks_depth, ranks_feat, - ranks_bev, interval_starts, interval_lengths, depth_grad, feat_grad - ); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_hip.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_hip.cpp deleted file mode 100644 index 4088563e960194d4ba4f25130e62357dd93bc931..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/bev_pool_v2/src/bev_pool_hip.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -// Copyright (c) Phigent Robotics. All rights reserved. -// Reference https://arxiv.org/abs/2211.17111 -#include -#include - -// CUDA function declarations -void bev_pool_v2(int c, int n_intervals, const float* depth, const float* feat, - const int* ranks_depth, const int* ranks_feat, const int* ranks_bev, - const int* interval_starts, const int* interval_lengths, float* out); - -void bev_pool_v2_grad(int c, int n_intervals, const float* out_grad, - const float* depth, const float* feat, const int* ranks_depth, const int* ranks_feat, - const int* ranks_bev, const int* interval_starts, const int* interval_lengths, - float* depth_grad, float* feat_grad); - - -/* - Function: pillar pooling (forward, cuda) - Args: - depth : input depth, FloatTensor[n, d, h, w] - feat : input features, FloatTensor[n, h, w, c] - out : output features, FloatTensor[b, c, h_out, w_out] - ranks_depth : depth index of points, IntTensor[n_points] - ranks_feat : feat index of points, IntTensor[n_points] - ranks_bev : output index of points, IntTensor[n_points] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - interval_starts : how many points in each pooled point, IntTensor[n_intervals] - Return: -*/ -void bev_pool_v2_forward( - const at::Tensor _depth, // (B, N, D, fH, fW) - const at::Tensor _feat, // (B, N, fH, fW, C) - at::Tensor _out, // (B, D_Z, D_Y, D_X, C) - const at::Tensor _ranks_depth, // (N_points, ), - const at::Tensor _ranks_feat, // (N_points, ), - const at::Tensor _ranks_bev, // (N_points, ), - const at::Tensor _interval_lengths, // (N_pillar, ) - const at::Tensor _interval_starts // (N_pillar, ) -) { - int c = _feat.size(4); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_depth)); - const float* depth = _depth.data_ptr(); - const float* feat = _feat.data_ptr(); - const int* ranks_depth = _ranks_depth.data_ptr(); - const int* ranks_feat = _ranks_feat.data_ptr(); - const int* ranks_bev = _ranks_bev.data_ptr(); - - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - float* out = _out.data_ptr(); - bev_pool_v2( - c, n_intervals, depth, feat, ranks_depth, ranks_feat, - ranks_bev, interval_starts, interval_lengths, out - ); -} - - -/* - Function: pillar pooling (backward, cuda) - Args: - out_grad : grad of output bev feature, FloatTensor[b, c, h_out, w_out] - depth_grad : grad of input depth, FloatTensor[n, d, h, w] - feat_grad : grad of input feature, FloatTensor[n, h, w, c] - depth : input depth, FloatTensor[n, d, h, w] - feat : input features, FloatTensor[n, h, w, c] - ranks_depth : depth index of points, IntTensor[n_points] - ranks_feat : feat index of points, IntTensor[n_points] - ranks_bev : output index of points, IntTensor[n_points] - interval_lengths : starting position for pooled point, IntTensor[n_intervals] - interval_starts : how many points in each pooled point, IntTensor[n_intervals] -*/ -void bev_pool_v2_backward( - const at::Tensor _out_grad, - at::Tensor _depth_grad, - at::Tensor _feat_grad, - const at::Tensor _depth, - const at::Tensor _feat, - const at::Tensor _ranks_depth, - const at::Tensor _ranks_feat, - const at::Tensor _ranks_bev, - const at::Tensor _interval_lengths, - const at::Tensor _interval_starts -) { - int c = _out_grad.size(4); - int n_intervals = _interval_lengths.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_out_grad)); - const float* out_grad = _out_grad.data_ptr(); - float* depth_grad = _depth_grad.data_ptr(); - float* feat_grad = _feat_grad.data_ptr(); - const float* depth = _depth.data_ptr(); - const float* feat = _feat.data_ptr(); - const int* ranks_depth = _ranks_depth.data_ptr(); - const int* ranks_feat = _ranks_feat.data_ptr(); - const int* ranks_bev = _ranks_bev.data_ptr(); - const int* interval_lengths = _interval_lengths.data_ptr(); - const int* interval_starts = _interval_starts.data_ptr(); - - bev_pool_v2_grad( - c, n_intervals, out_grad, depth, feat, ranks_depth, ranks_feat, - ranks_bev, interval_starts, interval_lengths, depth_grad, feat_grad - ); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("bev_pool_v2_forward", &bev_pool_v2_forward, - "bev_pool_v2_forward"); - m.def("bev_pool_v2_backward", &bev_pool_v2_backward, - "bev_pool_v2_backward"); -} diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__init__.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__init__.py deleted file mode 100644 index e124cc93e8c5396cbf83528a772926875f9a0383..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. -from .nearest_assign import nearest_assign \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 6df790f289e6df91b0b71e19e9b7a30ae41dd886..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/nearest_assign.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/nearest_assign.cpython-310.pyc deleted file mode 100644 index ae90e0ee42d4c262427c7ad74fd5d45a9f287ab8..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/__pycache__/nearest_assign.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign.py b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign.py deleted file mode 100644 index 9b20911a9d0ee4c9f529772ae37cf89a3675d98d..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign.py +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) Phigent Robotics. All rights reserved. - -import numpy as np -import torch - -from . import nearest_assign_ext - -__all__ = ['nearest_assign'] - - -class QuickNearestAssignCuda(torch.autograd.Function): - @staticmethod - def forward(ctx, - occ_pred, - l2s_key, - occind2detind, - inst_cls, - inst_xyz, - inst_id_list, - ): - - occ_pred = occ_pred.contiguous().int() - l2s_key = l2s_key.contiguous().int() - occind2detind = occind2detind.contiguous().int() - inst_cls = inst_cls.contiguous().int() - inst_xyz = inst_xyz.contiguous().int() - inst_id_list = inst_id_list.contiguous().int() - inst_pred = occ_pred.new_zeros(occ_pred.shape) - - nearest_assign_ext.nearest_assign_forward( - occ_pred, - l2s_key, - occind2detind, - inst_cls, - inst_xyz, - inst_id_list, - inst_pred - ) - - return inst_pred - - -def nearest_assign(occ_pred, - l2s_key, - occind2detind, - inst_cls, - inst_xyz, - inst_id_list): - inst_pred = QuickNearestAssignCuda.apply(occ_pred, - l2s_key, - occind2detind, - inst_cls, - inst_xyz, - inst_id_list - ) # (B, Dz, Dy, Dx, C) - return inst_pred - -def test_bev_pool_v2(): - depth = np.array([0.3, 0.4, 0.2, 0.1, 0.7, 0.6, 0.8, 0.9]) - depth = torch.from_numpy(depth).float().cuda() - depth = depth.view(1, 1, 2, 2, 2).requires_grad_() - feat = torch.ones( - size=[1, 1, 2, 2, 2], dtype=torch.float, - device='cuda').requires_grad_() - ranks_depth = torch.from_numpy(np.array([0, 4, 1, 6])).int().cuda() - ranks_feat = torch.from_numpy(np.array([0, 0, 1, 2])).int().cuda() - ranks_bev = torch.from_numpy(np.array([0, 0, 1, 1])).int().cuda() - - kept = torch.ones( - ranks_bev.shape[0], device=ranks_bev.device, dtype=torch.bool) - kept[1:] = ranks_bev[1:] != ranks_bev[:-1] - interval_starts = torch.where(kept)[0].int() - if len(interval_starts) == 0: - return None, None, None, None, None - interval_lengths = torch.zeros_like(interval_starts) - interval_lengths[:-1] = interval_starts[1:] - interval_starts[:-1] - interval_lengths[-1] = ranks_bev.shape[0] - interval_starts[-1] - bev_feat = bev_pool_v2(depth, feat, ranks_depth, ranks_feat, ranks_bev, - (1, 1, 2, 2, 2), interval_starts, interval_lengths) - loss = torch.sum(bev_feat) - loss.backward() - assert loss == 4.4 - grad_depth = np.array([2., 2., 0., 0., 2., 0., 2., 0.]) - grad_depth = torch.from_numpy(grad_depth).float() - grad_depth = grad_depth.cuda().view(1, 1, 2, 2, 2) - assert depth.grad.allclose(grad_depth) - grad_feat = np.array([1.0, 1.0, 0.4, 0.4, 0.8, 0.8, 0., 0.]) - grad_feat = torch.from_numpy(grad_feat).float().cuda().view(1, 1, 2, 2, 2) - assert feat.grad.allclose(grad_feat) diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign_ext.cpython-310-x86_64-linux-gnu.so b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign_ext.cpython-310-x86_64-linux-gnu.so deleted file mode 100755 index 686b4cb2858b13d0ea474a8f7b4369c67f48be42..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/nearest_assign_ext.cpython-310-x86_64-linux-gnu.so and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.cu b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.cu deleted file mode 100644 index 392a07f35805e266e43a4916ef25ab47e778a2e8..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.cu +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Phigent Robotics. All rights reserved. -// Reference https://arxiv.org/abs/2211.17111 - -#include -#include - -__global__ void nearest_assign_kernel( - const int* l2s_key, - int l2s_size, - const int* occind2detind, - const int *__restrict__ occ_pred, - const int *__restrict__ inst_xyz, - const int *__restrict__ inst_cls, - const int *__restrict__ inst_id_list, - int inst_size, - int* __restrict__ inst_pred) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - // while (idx < 200*200*16) - if (true) - { - int occ_pred_label = occ_pred[idx]; - int dist_min = 100000000; - for (int index = 0; index < l2s_size; index ++) - { - if (occ_pred_label == l2s_key[index]) - { - int x = idx/(200*16); - int y = (idx - x*200*16)/16; - int z = idx - x*200*16 - y*16; - int inst_ind = 0; - for (inst_ind = 0; inst_ind < inst_size; inst_ind ++) - { - if (inst_cls[inst_ind] == occind2detind[occ_pred_label]) - { - int dx = x - inst_xyz[inst_ind*3+0]; - int dy = y - inst_xyz[inst_ind*3+1]; - int dz = z - inst_xyz[inst_ind*3+2]; - int dist = dx*dx + dy*dy + dz*dz; - if (dist < dist_min){ - dist_min = dist; - inst_pred[idx] = inst_id_list[inst_ind]; - } - } - } - return; - } - } - inst_pred[idx] = occ_pred[idx]; - - // idx += blockDim.x * gridDim.x; - } - -} - -void nearest_assign( - const int* l2s_key, - int l2s_size, - const int *__restrict__ occind2detind, - int inst_size, - const int *__restrict__ occ_pred, - const int *__restrict__ inst_xyz, - const int *__restrict__ inst_cls, - const int *__restrict__ inst_id_list, - int* __restrict__ inst_pred) { - // nearest_assign_kernel<<<128, 256>>>( - nearest_assign_kernel<<<(int)ceil(((double)200 * 200 * 16 / 256)), 256>>>( - l2s_key, l2s_size, occind2detind, - occ_pred, inst_xyz, inst_cls, - inst_id_list, inst_size, inst_pred - ); -} - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.hip b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.hip deleted file mode 100644 index d469ed8fcb21e4d9f21f36476f44ae182cf3dabf..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_cuda.hip +++ /dev/null @@ -1,76 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include "hip/hip_runtime.h" -// Copyright (c) Phigent Robotics. All rights reserved. -// Reference https://arxiv.org/abs/2211.17111 - -#include -#include - -__global__ void nearest_assign_kernel( - const int* l2s_key, - int l2s_size, - const int* occind2detind, - const int *__restrict__ occ_pred, - const int *__restrict__ inst_xyz, - const int *__restrict__ inst_cls, - const int *__restrict__ inst_id_list, - int inst_size, - int* __restrict__ inst_pred) { - int idx = blockIdx.x * blockDim.x + threadIdx.x; - // while (idx < 200*200*16) - if (true) - { - int occ_pred_label = occ_pred[idx]; - int dist_min = 100000000; - for (int index = 0; index < l2s_size; index ++) - { - if (occ_pred_label == l2s_key[index]) - { - int x = idx/(200*16); - int y = (idx - x*200*16)/16; - int z = idx - x*200*16 - y*16; - int inst_ind = 0; - for (inst_ind = 0; inst_ind < inst_size; inst_ind ++) - { - if (inst_cls[inst_ind] == occind2detind[occ_pred_label]) - { - int dx = x - inst_xyz[inst_ind*3+0]; - int dy = y - inst_xyz[inst_ind*3+1]; - int dz = z - inst_xyz[inst_ind*3+2]; - int dist = dx*dx + dy*dy + dz*dz; - if (dist < dist_min){ - dist_min = dist; - inst_pred[idx] = inst_id_list[inst_ind]; - } - } - } - return; - } - } - inst_pred[idx] = occ_pred[idx]; - - // idx += blockDim.x * gridDim.x; - } - -} - -void nearest_assign( - const int* l2s_key, - int l2s_size, - const int *__restrict__ occind2detind, - int inst_size, - const int *__restrict__ occ_pred, - const int *__restrict__ inst_xyz, - const int *__restrict__ inst_cls, - const int *__restrict__ inst_id_list, - int* __restrict__ inst_pred) { - // nearest_assign_kernel<<<128, 256>>>( - hipLaunchKernelGGL(( nearest_assign_kernel), dim3((int)ceil(((double)200 * 200 * 16 / 256))), dim3(256), 0, 0, - l2s_key, l2s_size, occind2detind, - occ_pred, inst_xyz, inst_cls, - inst_id_list, inst_size, inst_pred - ); -} - - diff --git a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_hip.cpp b/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_hip.cpp deleted file mode 100644 index d357cda2e805770c1f5efb869e77b3f6ba0f798e..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/projects/mmdet3d_plugin/ops/nearest_assign/src/nearest_assign_hip.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -// Copyright (c) Phigent Robotics. All rights reserved. -// Reference https://arxiv.org/abs/2211.17111 -#include -#include - -// CUDA function declarations -void nearest_assign( - const int* l2s_key, - int l2s_size, - const int *__restrict__ occind2detind, - int inst_size, - const int *__restrict__ occ_pred, - const int *__restrict__ inst_xyz, - const int *__restrict__ inst_cls, - const int *__restrict__ inst_id_list, - int* __restrict__ inst_pred); - -void nearest_assign_forward( - const at::Tensor _occ_pred, // (200, 200, 16) - const at::Tensor _l2s_key, // (l2s_size, 1) - const at::Tensor _occind2detind, // (10, 1) - const at::Tensor _inst_cls, // (inst_size, 1) - const at::Tensor _inst_xyz, // (inst_size, 3) - const at::Tensor _inst_id_list, // (inst_size, 1) - at::Tensor _inst_pred // (200, 200, 16) -) { - int l2s_size = _l2s_key.size(0); - int inst_size = _inst_xyz.size(0); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_occ_pred)); - const int* occ_pred = _occ_pred.data_ptr(); - const int* inst_xyz = _inst_xyz.data_ptr(); - const int* inst_cls = _inst_cls.data_ptr(); - const int* l2s_key = _l2s_key.data_ptr(); - const int* inst_id_list = _inst_id_list.data_ptr(); - const int* occind2detind = _occind2detind.data_ptr(); - // std::map l2s; - // for (int l2s_ind = 0; l2s_ind < l2s_size; l2s_ind++){ - // l2s.insert(pair(l2s_key[l2s_ind], l2s_val[l2s_ind])); - // } - - int* inst_pred = _inst_pred.data_ptr(); - nearest_assign( - l2s_key, - l2s_size, - occind2detind, - inst_size, - occ_pred, - inst_xyz, - inst_cls, - inst_id_list, - inst_pred - ); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("nearest_assign_forward", &nearest_assign_forward, - "nearest_assign_forward"); -} diff --git a/docker-hub/FlashOCC/Flashocc/repro.py b/docker-hub/FlashOCC/Flashocc/repro.py deleted file mode 100644 index b5291dd1e05022fba6ca632b6c63bc8fd677c9e6..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/repro.py +++ /dev/null @@ -1,260 +0,0 @@ - -import torch -from torch import tensor, device -import torch.fx as fx -from torch._dynamo.testing import rand_strided -from math import inf -import torch._inductor.inductor_prims - -import torch._dynamo.config -import torch._inductor.config -import torch._functorch.config -import torch.fx.experimental._config -torch._dynamo.config.capture_scalar_outputs = True - - - - - -isolate_fails_code_str = None - - - -# torch version: 2.4.1 -# torch cuda version: None -# torch git version: 45d303c9e4f41ec2f5450b6f60031246f67189d6 - - -# CUDA Info: -# nvcc not found -# GPU Hardware Info: -# BW200 : 8 - - -from torch.nn import * -class Repro(torch.nn.Module): - def __init__(self): - super().__init__() - - - - def forward(self, primals_1, primals_2, primals_4, primals_5, primals_6, primals_7, primals_8, primals_10, convert_element_type_1, clamp_max, convert_element_type_3, clamp_max_1, clamp_max_2, clamp_max_3, cat, convolution, squeeze_1, relu, convolution_1, getitem_3, rsqrt_1, convert_element_type_5, clamp_max_4, convert_element_type_7, clamp_max_5, clamp_max_6, clamp_max_7, add_19, convolution_2, squeeze_7, relu_2, unsqueeze_14, unsqueeze_38, tangents_1): - sum_1 = torch.ops.aten.sum.dim_IntList(tangents_1, [0, 2, 3]) - convolution_backward = torch.ops.aten.convolution_backward.default(tangents_1, relu_2, primals_10, [256], [1, 1], [0, 0], [1, 1], False, [0, 0], 1, [True, True, False]); tangents_1 = primals_10 = None - getitem_6 = convolution_backward[0] - getitem_7 = convolution_backward[1]; convolution_backward = None - le = torch.ops.aten.le.Scalar(relu_2, 0); relu_2 = None - full_default = torch.ops.aten.full.default([], 0.0, dtype = torch.float32, layout = torch.strided, device = device(type='cuda', index=2), pin_memory = False) - where = torch.ops.aten.where.self(le, full_default, getitem_6); le = getitem_6 = None - sum_2 = torch.ops.aten.sum.dim_IntList(where, [0, 2, 3]) - sub_13 = torch.ops.aten.sub.Tensor(convolution_2, unsqueeze_14); convolution_2 = unsqueeze_14 = None - mul_31 = torch.ops.aten.mul.Tensor(where, sub_13) - sum_3 = torch.ops.aten.sum.dim_IntList(mul_31, [0, 2, 3]); mul_31 = None - mul_32 = torch.ops.aten.mul.Tensor(sum_2, 6.25e-06) - unsqueeze_15 = torch.ops.aten.unsqueeze.default(mul_32, 0); mul_32 = None - unsqueeze_16 = torch.ops.aten.unsqueeze.default(unsqueeze_15, 2); unsqueeze_15 = None - unsqueeze_17 = torch.ops.aten.unsqueeze.default(unsqueeze_16, 3); unsqueeze_16 = None - mul_33 = torch.ops.aten.mul.Tensor(sum_3, 6.25e-06) - mul_34 = torch.ops.aten.mul.Tensor(squeeze_7, squeeze_7) - mul_35 = torch.ops.aten.mul.Tensor(mul_33, mul_34); mul_33 = mul_34 = None - unsqueeze_18 = torch.ops.aten.unsqueeze.default(mul_35, 0); mul_35 = None - unsqueeze_19 = torch.ops.aten.unsqueeze.default(unsqueeze_18, 2); unsqueeze_18 = None - unsqueeze_20 = torch.ops.aten.unsqueeze.default(unsqueeze_19, 3); unsqueeze_19 = None - mul_36 = torch.ops.aten.mul.Tensor(squeeze_7, primals_8); primals_8 = None - unsqueeze_21 = torch.ops.aten.unsqueeze.default(mul_36, 0); mul_36 = None - unsqueeze_22 = torch.ops.aten.unsqueeze.default(unsqueeze_21, 2); unsqueeze_21 = None - unsqueeze_23 = torch.ops.aten.unsqueeze.default(unsqueeze_22, 3); unsqueeze_22 = None - mul_37 = torch.ops.aten.mul.Tensor(sub_13, unsqueeze_20); sub_13 = unsqueeze_20 = None - sub_15 = torch.ops.aten.sub.Tensor(where, mul_37); where = mul_37 = None - sub_16 = torch.ops.aten.sub.Tensor(sub_15, unsqueeze_17); sub_15 = unsqueeze_17 = None - mul_38 = torch.ops.aten.mul.Tensor(sub_16, unsqueeze_23); sub_16 = unsqueeze_23 = None - mul_39 = torch.ops.aten.mul.Tensor(sum_3, squeeze_7); sum_3 = squeeze_7 = None - convolution_backward_1 = torch.ops.aten.convolution_backward.default(mul_38, add_19, primals_7, [0], [1, 1], [1, 1], [1, 1], False, [0, 0], 1, [True, True, False]); mul_38 = add_19 = primals_7 = None - getitem_9 = convolution_backward_1[0] - getitem_10 = convolution_backward_1[1]; convolution_backward_1 = None - mul_40 = torch.ops.aten.mul.Tensor(getitem_9, clamp_max_7); clamp_max_7 = None - neg = torch.ops.aten.neg.default(mul_40) - add_25 = torch.ops.aten.add.Tensor(getitem_9, neg); getitem_9 = neg = None - mul_41 = torch.ops.aten.mul.Tensor(mul_40, clamp_max_6) - neg_1 = torch.ops.aten.neg.default(mul_41) - add_26 = torch.ops.aten.add.Tensor(mul_40, neg_1); mul_40 = neg_1 = None - mul_42 = torch.ops.aten.mul.Tensor(add_25, clamp_max_6); clamp_max_6 = None - neg_2 = torch.ops.aten.neg.default(mul_42) - add_27 = torch.ops.aten.add.Tensor(add_25, neg_2); add_25 = neg_2 = None - full_default_1 = torch.ops.aten.full.default([4, 512, 100, 100], 0, dtype = torch.float32, layout = torch.strided, device = device(type='cuda', index=2), pin_memory = False) - _unsafe_index_put = torch.ops.aten._unsafe_index_put.default(full_default_1, [None, None, clamp_max_4, clamp_max_5], mul_41, True); mul_41 = None - _unsafe_index_put_1 = torch.ops.aten._unsafe_index_put.default(full_default_1, [None, None, clamp_max_4, convert_element_type_7], add_26, True); clamp_max_4 = add_26 = None - add_28 = torch.ops.aten.add.Tensor(_unsafe_index_put, _unsafe_index_put_1); _unsafe_index_put = _unsafe_index_put_1 = None - _unsafe_index_put_2 = torch.ops.aten._unsafe_index_put.default(full_default_1, [None, None, convert_element_type_5, clamp_max_5], mul_42, True); clamp_max_5 = mul_42 = None - add_29 = torch.ops.aten.add.Tensor(add_28, _unsafe_index_put_2); add_28 = _unsafe_index_put_2 = None - _unsafe_index_put_3 = torch.ops.aten._unsafe_index_put.default(full_default_1, [None, None, convert_element_type_5, convert_element_type_7], add_27, True); full_default_1 = convert_element_type_5 = convert_element_type_7 = add_27 = None - add_30 = torch.ops.aten.add.Tensor(add_29, _unsafe_index_put_3); add_29 = _unsafe_index_put_3 = None - sub_6 = torch.ops.aten.sub.Tensor(convolution_1, getitem_3) - mul_12 = torch.ops.aten.mul.Tensor(sub_6, rsqrt_1); sub_6 = None - unsqueeze_4 = torch.ops.aten.unsqueeze.default(primals_5, -1) - unsqueeze_5 = torch.ops.aten.unsqueeze.default(unsqueeze_4, -1); unsqueeze_4 = None - mul_18 = torch.ops.aten.mul.Tensor(mul_12, unsqueeze_5); mul_12 = unsqueeze_5 = None - unsqueeze_6 = torch.ops.aten.unsqueeze.default(primals_6, -1); primals_6 = None - unsqueeze_7 = torch.ops.aten.unsqueeze.default(unsqueeze_6, -1); unsqueeze_6 = None - add_14 = torch.ops.aten.add.Tensor(mul_18, unsqueeze_7); mul_18 = unsqueeze_7 = None - relu_1 = torch.ops.aten.relu.default(add_14); add_14 = None - le_1 = torch.ops.aten.le.Scalar(relu_1, 0); relu_1 = None - where_1 = torch.ops.aten.where.self(le_1, full_default, add_30); le_1 = add_30 = None - squeeze_3 = torch.ops.aten.squeeze.dims(getitem_3, [0, 2, 3]); getitem_3 = None - unsqueeze_24 = torch.ops.aten.unsqueeze.default(squeeze_3, 0); squeeze_3 = None - unsqueeze_25 = torch.ops.aten.unsqueeze.default(unsqueeze_24, 2); unsqueeze_24 = None - unsqueeze_26 = torch.ops.aten.unsqueeze.default(unsqueeze_25, 3); unsqueeze_25 = None - sum_4 = torch.ops.aten.sum.dim_IntList(where_1, [0, 2, 3]) - sub_17 = torch.ops.aten.sub.Tensor(convolution_1, unsqueeze_26); convolution_1 = unsqueeze_26 = None - mul_43 = torch.ops.aten.mul.Tensor(where_1, sub_17) - sum_5 = torch.ops.aten.sum.dim_IntList(mul_43, [0, 2, 3]); mul_43 = None - mul_44 = torch.ops.aten.mul.Tensor(sum_4, 2.5e-05) - unsqueeze_27 = torch.ops.aten.unsqueeze.default(mul_44, 0); mul_44 = None - unsqueeze_28 = torch.ops.aten.unsqueeze.default(unsqueeze_27, 2); unsqueeze_27 = None - unsqueeze_29 = torch.ops.aten.unsqueeze.default(unsqueeze_28, 3); unsqueeze_28 = None - mul_45 = torch.ops.aten.mul.Tensor(sum_5, 2.5e-05) - squeeze_4 = torch.ops.aten.squeeze.dims(rsqrt_1, [0, 2, 3]); rsqrt_1 = None - mul_46 = torch.ops.aten.mul.Tensor(squeeze_4, squeeze_4) - mul_47 = torch.ops.aten.mul.Tensor(mul_45, mul_46); mul_45 = mul_46 = None - unsqueeze_30 = torch.ops.aten.unsqueeze.default(mul_47, 0); mul_47 = None - unsqueeze_31 = torch.ops.aten.unsqueeze.default(unsqueeze_30, 2); unsqueeze_30 = None - unsqueeze_32 = torch.ops.aten.unsqueeze.default(unsqueeze_31, 3); unsqueeze_31 = None - mul_48 = torch.ops.aten.mul.Tensor(squeeze_4, primals_5); primals_5 = None - unsqueeze_33 = torch.ops.aten.unsqueeze.default(mul_48, 0); mul_48 = None - unsqueeze_34 = torch.ops.aten.unsqueeze.default(unsqueeze_33, 2); unsqueeze_33 = None - unsqueeze_35 = torch.ops.aten.unsqueeze.default(unsqueeze_34, 3); unsqueeze_34 = None - mul_49 = torch.ops.aten.mul.Tensor(sub_17, unsqueeze_32); sub_17 = unsqueeze_32 = None - sub_19 = torch.ops.aten.sub.Tensor(where_1, mul_49); where_1 = mul_49 = None - sub_20 = torch.ops.aten.sub.Tensor(sub_19, unsqueeze_29); sub_19 = unsqueeze_29 = None - mul_50 = torch.ops.aten.mul.Tensor(sub_20, unsqueeze_35); sub_20 = unsqueeze_35 = None - mul_51 = torch.ops.aten.mul.Tensor(sum_5, squeeze_4); sum_5 = squeeze_4 = None - convolution_backward_2 = torch.ops.aten.convolution_backward.default(mul_50, relu, primals_4, [0], [1, 1], [1, 1], [1, 1], False, [0, 0], 1, [True, True, False]); mul_50 = primals_4 = None - getitem_12 = convolution_backward_2[0] - getitem_13 = convolution_backward_2[1]; convolution_backward_2 = None - le_2 = torch.ops.aten.le.Scalar(relu, 0); relu = None - where_2 = torch.ops.aten.where.self(le_2, full_default, getitem_12); le_2 = full_default = getitem_12 = None - sum_6 = torch.ops.aten.sum.dim_IntList(where_2, [0, 2, 3]) - sub_21 = torch.ops.aten.sub.Tensor(convolution, unsqueeze_38); convolution = unsqueeze_38 = None - mul_52 = torch.ops.aten.mul.Tensor(where_2, sub_21) - sum_7 = torch.ops.aten.sum.dim_IntList(mul_52, [0, 2, 3]); mul_52 = None - mul_53 = torch.ops.aten.mul.Tensor(sum_6, 2.5e-05) - unsqueeze_39 = torch.ops.aten.unsqueeze.default(mul_53, 0); mul_53 = None - unsqueeze_40 = torch.ops.aten.unsqueeze.default(unsqueeze_39, 2); unsqueeze_39 = None - unsqueeze_41 = torch.ops.aten.unsqueeze.default(unsqueeze_40, 3); unsqueeze_40 = None - mul_54 = torch.ops.aten.mul.Tensor(sum_7, 2.5e-05) - mul_55 = torch.ops.aten.mul.Tensor(squeeze_1, squeeze_1) - mul_56 = torch.ops.aten.mul.Tensor(mul_54, mul_55); mul_54 = mul_55 = None - unsqueeze_42 = torch.ops.aten.unsqueeze.default(mul_56, 0); mul_56 = None - unsqueeze_43 = torch.ops.aten.unsqueeze.default(unsqueeze_42, 2); unsqueeze_42 = None - unsqueeze_44 = torch.ops.aten.unsqueeze.default(unsqueeze_43, 3); unsqueeze_43 = None - mul_57 = torch.ops.aten.mul.Tensor(squeeze_1, primals_2); primals_2 = None - unsqueeze_45 = torch.ops.aten.unsqueeze.default(mul_57, 0); mul_57 = None - unsqueeze_46 = torch.ops.aten.unsqueeze.default(unsqueeze_45, 2); unsqueeze_45 = None - unsqueeze_47 = torch.ops.aten.unsqueeze.default(unsqueeze_46, 3); unsqueeze_46 = None - mul_58 = torch.ops.aten.mul.Tensor(sub_21, unsqueeze_44); sub_21 = unsqueeze_44 = None - sub_23 = torch.ops.aten.sub.Tensor(where_2, mul_58); where_2 = mul_58 = None - sub_24 = torch.ops.aten.sub.Tensor(sub_23, unsqueeze_41); sub_23 = unsqueeze_41 = None - mul_59 = torch.ops.aten.mul.Tensor(sub_24, unsqueeze_47); sub_24 = unsqueeze_47 = None - mul_60 = torch.ops.aten.mul.Tensor(sum_7, squeeze_1); sum_7 = squeeze_1 = None - convolution_backward_3 = torch.ops.aten.convolution_backward.default(mul_59, cat, primals_1, [0], [1, 1], [1, 1], [1, 1], False, [0, 0], 1, [True, True, False]); mul_59 = cat = primals_1 = None - getitem_15 = convolution_backward_3[0] - getitem_16 = convolution_backward_3[1]; convolution_backward_3 = None - slice_1 = torch.ops.aten.slice.Tensor(getitem_15, 1, 0, 128) - slice_2 = torch.ops.aten.slice.Tensor(getitem_15, 1, 128, 640); getitem_15 = None - mul_61 = torch.ops.aten.mul.Tensor(slice_2, clamp_max_3); clamp_max_3 = None - neg_3 = torch.ops.aten.neg.default(mul_61) - add_31 = torch.ops.aten.add.Tensor(slice_2, neg_3); slice_2 = neg_3 = None - mul_62 = torch.ops.aten.mul.Tensor(mul_61, clamp_max_2) - neg_4 = torch.ops.aten.neg.default(mul_62) - add_32 = torch.ops.aten.add.Tensor(mul_61, neg_4); mul_61 = neg_4 = None - mul_63 = torch.ops.aten.mul.Tensor(add_31, clamp_max_2); clamp_max_2 = None - neg_5 = torch.ops.aten.neg.default(mul_63) - add_33 = torch.ops.aten.add.Tensor(add_31, neg_5); add_31 = neg_5 = None - full_default_7 = torch.ops.aten.full.default([4, 512, 25, 25], 0, dtype = torch.float32, layout = torch.strided, device = device(type='cuda', index=2), pin_memory = False) - _unsafe_index_put_4 = torch.ops.aten._unsafe_index_put.default(full_default_7, [None, None, clamp_max, clamp_max_1], mul_62, True); mul_62 = None - _unsafe_index_put_5 = torch.ops.aten._unsafe_index_put.default(full_default_7, [None, None, clamp_max, convert_element_type_3], add_32, True); clamp_max = add_32 = None - add_34 = torch.ops.aten.add.Tensor(_unsafe_index_put_4, _unsafe_index_put_5); _unsafe_index_put_4 = _unsafe_index_put_5 = None - _unsafe_index_put_6 = torch.ops.aten._unsafe_index_put.default(full_default_7, [None, None, convert_element_type_1, clamp_max_1], mul_63, True); clamp_max_1 = mul_63 = None - add_35 = torch.ops.aten.add.Tensor(add_34, _unsafe_index_put_6); add_34 = _unsafe_index_put_6 = None - _unsafe_index_put_7 = torch.ops.aten._unsafe_index_put.default(full_default_7, [None, None, convert_element_type_1, convert_element_type_3], add_33, True); full_default_7 = convert_element_type_1 = convert_element_type_3 = add_33 = None - add_36 = torch.ops.aten.add.Tensor(add_35, _unsafe_index_put_7); add_35 = _unsafe_index_put_7 = None - return [getitem_16, mul_60, sum_6, getitem_13, mul_51, sum_4, getitem_10, mul_39, sum_2, getitem_7, sum_1, None, None, None, None, None, None, None, None, None, slice_1, add_36] - -def load_args(reader): - buf0 = reader.storage('934c55e4a7a69a0a29a96cd8ef9f11c9859658e1', 11796480, device=device(type='cuda', index=2)) - reader.tensor(buf0, (512, 640, 3, 3), requires_grad=True, is_leaf=True) # primals_1 - buf1 = reader.storage('f12094f433480ec90280d223057708434df38941', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf1, (512,), requires_grad=True, is_leaf=True) # primals_2 - buf2 = reader.storage('06c46ad2c91ec5c8eebc4fb0be80459bdfe007a8', 9437184, device=device(type='cuda', index=2)) - reader.tensor(buf2, (512, 512, 3, 3), requires_grad=True, is_leaf=True) # primals_4 - buf3 = reader.storage('aba0c4266c842d1845e720dc0c789942770a60b7', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf3, (512,), requires_grad=True, is_leaf=True) # primals_5 - buf4 = reader.storage('bb8471d379e03c8ccb9897ce7d3a2dfbacb44e30', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf4, (512,), requires_grad=True, is_leaf=True) # primals_6 - buf5 = reader.storage('b9484105fb5b2045fb6550a1edb77af72e639416', 4718592, device=device(type='cuda', index=2)) - reader.tensor(buf5, (256, 512, 3, 3), requires_grad=True, is_leaf=True) # primals_7 - buf6 = reader.storage('b778b8cab416c3fa6763b88e431266ae6ea28941', 1024, device=device(type='cuda', index=2)) - reader.tensor(buf6, (256,), requires_grad=True, is_leaf=True) # primals_8 - buf7 = reader.storage('c5f14ec72c73a593b47ef4aecf37f6bb25d2dec4', 262144, device=device(type='cuda', index=2)) - reader.tensor(buf7, (256, 256, 1, 1), requires_grad=True, is_leaf=True) # primals_10 - buf8 = reader.storage('99ef5c7086a924dfc5221c01ff1520de469849c8', 800, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf8, (100, 1), dtype=torch.int64, is_leaf=True) # convert_element_type_1 - buf9 = reader.storage('532b7b8fc19c48c7434e569ab96aa0670d5651ef', 800, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf9, (100, 1), dtype=torch.int64, is_leaf=True) # clamp_max - buf10 = reader.storage('99ef5c7086a924dfc5221c01ff1520de469849c8', 800, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf10, (100,), dtype=torch.int64, is_leaf=True) # convert_element_type_3 - buf11 = reader.storage('532b7b8fc19c48c7434e569ab96aa0670d5651ef', 800, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf11, (100,), dtype=torch.int64, is_leaf=True) # clamp_max_1 - buf12 = reader.storage('0538ed039b8a4706a4f85bf431e12664d8940742', 400, device=device(type='cuda', index=2)) - reader.tensor(buf12, (100,), is_leaf=True) # clamp_max_2 - buf13 = reader.storage('0538ed039b8a4706a4f85bf431e12664d8940742', 400, device=device(type='cuda', index=2)) - reader.tensor(buf13, (100, 1), is_leaf=True) # clamp_max_3 - buf14 = reader.storage('5d41e66671a283b70001fd74345d8e7e3def00bd', 102400000, device=device(type='cuda', index=2)) - reader.tensor(buf14, (4, 640, 100, 100), is_leaf=True) # cat - buf15 = reader.storage('a8fe0ed584571bb3218d663656459a36545be5e6', 81920000, device=device(type='cuda', index=2)) - reader.tensor(buf15, (4, 512, 100, 100), is_leaf=True) # convolution - buf16 = reader.storage('0af13bcf109b8ca2df7f5ce3387d51e8576fb30a', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf16, (512,), is_leaf=True) # squeeze_1 - buf17 = reader.storage('32f14d6fa07f654fbb09ef1563066303a3501eda', 81920000, device=device(type='cuda', index=2)) - reader.tensor(buf17, (4, 512, 100, 100), is_leaf=True) # relu - buf18 = reader.storage('aca23d51e723ad9b4bec2e54d6f0af4b5b85cc7d', 81920000, device=device(type='cuda', index=2)) - reader.tensor(buf18, (4, 512, 100, 100), is_leaf=True) # convolution_1 - buf19 = reader.storage('4940c79e48676c2e1359870dc770e25cd780983d', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf19, (1, 512, 1, 1), is_leaf=True) # getitem_3 - buf20 = reader.storage('d17407a9f45954a4d0d36e5b20a40ac554cc3aff', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf20, (1, 512, 1, 1), is_leaf=True) # rsqrt_1 - buf21 = reader.storage('95fbd2b85e217ab78f8f9d7900b273a1362b3112', 1600, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf21, (200, 1), dtype=torch.int64, is_leaf=True) # convert_element_type_5 - buf22 = reader.storage('d9920b87a7261c94c907bc68889b005f277cd597', 1600, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf22, (200, 1), dtype=torch.int64, is_leaf=True) # clamp_max_4 - buf23 = reader.storage('95fbd2b85e217ab78f8f9d7900b273a1362b3112', 1600, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf23, (200,), dtype=torch.int64, is_leaf=True) # convert_element_type_7 - buf24 = reader.storage('d9920b87a7261c94c907bc68889b005f277cd597', 1600, device=device(type='cuda', index=2), dtype_hint=torch.int64) - reader.tensor(buf24, (200,), dtype=torch.int64, is_leaf=True) # clamp_max_5 - buf25 = reader.storage('131d76cb798ee04745f0c7dcb67b63c74a6c00df', 800, device=device(type='cuda', index=2)) - reader.tensor(buf25, (200,), is_leaf=True) # clamp_max_6 - buf26 = reader.storage('131d76cb798ee04745f0c7dcb67b63c74a6c00df', 800, device=device(type='cuda', index=2)) - reader.tensor(buf26, (200, 1), is_leaf=True) # clamp_max_7 - buf27 = reader.storage('32194c54194bddd5f695a8d306828130629246fc', 327680000, device=device(type='cuda', index=2)) - reader.tensor(buf27, (4, 512, 200, 200), is_leaf=True) # add_19 - buf28 = reader.storage('e3a286ef8d6373c83ef30afe16eaae96ee52b965', 163840000, device=device(type='cuda', index=2)) - reader.tensor(buf28, (4, 256, 200, 200), is_leaf=True) # convolution_2 - buf29 = reader.storage('9572b289e6d5c9bdd20a79367d4005440da40795', 1024, device=device(type='cuda', index=2)) - reader.tensor(buf29, (256,), is_leaf=True) # squeeze_7 - buf30 = reader.storage('42f9ce794a05b12a40f15cbd4abb1201ccef0f72', 163840000, device=device(type='cuda', index=2)) - reader.tensor(buf30, (4, 256, 200, 200), is_leaf=True) # relu_2 - buf31 = reader.storage('61670207f087dc68f052bc03747d9ab365297b17', 1024, device=device(type='cuda', index=2)) - reader.tensor(buf31, (1, 256, 1, 1), is_leaf=True) # unsqueeze_14 - buf32 = reader.storage('ab77896e6dd76345e63586ecda30b1e4a63439cc', 2048, device=device(type='cuda', index=2)) - reader.tensor(buf32, (1, 512, 1, 1), is_leaf=True) # unsqueeze_38 - buf33 = reader.storage('f0ec623d2a44ff0f64fc264faf9128c2a6896e57', 163840000, device=device(type='cuda', index=2)) - reader.tensor(buf33, (4, 256, 200, 200), is_leaf=True) # tangents_1 -load_args._version = 0 -mod = Repro() -if __name__ == '__main__': - from torch._dynamo.repro.after_aot import run_repro - with torch.no_grad(): - run_repro(mod, load_args, accuracy=True, command='run', save_dir='/root/FlashOCC/torch_compile_debug/run_2025_08_24_19_42_28_279064-pid_182645/minifier/checkpoints', tracing_mode='real', check_str=None) - # To run it separately, do - # mod, args = run_repro(mod, load_args, accuracy=True, command='get_args', save_dir='/root/FlashOCC/torch_compile_debug/run_2025_08_24_19_42_28_279064-pid_182645/minifier/checkpoints', tracing_mode='real', check_str=None) - # mod(*args) \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/rocblas_Flashocc.log b/docker-hub/FlashOCC/Flashocc/rocblas_Flashocc.log deleted file mode 100644 index edbfe3072ee7f39177483707ef95fe9589217aaf..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/rocblas_Flashocc.log +++ /dev/null @@ -1,23 +0,0 @@ - 118 ./rocblas-bench -f gemm_ex --transposeA T --transposeB N -m 1024 -n 2048 -k 25344 --alpha 1 --a_type f32_r --lda 25344 --b_type f32_r --ldb 25344 --beta 0 --c_type f32_r --ldc 1024 --d_type f32_r --ldd 1024 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 960000 -k 512 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 512 -n 960000 -k 288 --alpha 1 --lda 512 --ldb 288 --beta 0 --ldc 512 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 512 -k 960000 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 512 -n 288 -k 960000 --alpha 1 --lda 512 --ldb 288 --beta 0 --ldc 512 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 288 -n 960000 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 1 --ldc 288 - 2 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 960000 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 512 - 948 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 11264 -n 256 -k 64 --alpha 1 --a_type f32_r --lda 11264 --stride_a 720896 --b_type f32_r --ldb 64 --stride_b 0 --beta 0 --c_type f32_r --ldc 11264 --stride_c 2883584 --d_type f32_r --ldd 11264 --stride_d 2883584 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 237 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 11264 -n 64 -k 64 --alpha 1 --a_type f32_r --lda 11264 --stride_a 720896 --b_type f32_r --ldb 64 --stride_b 0 --beta 0 --c_type f32_r --ldc 11264 --stride_c 720896 --d_type f32_r --ldd 11264 --stride_d 720896 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 948 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 2816 -n 512 -k 128 --alpha 1 --a_type f32_r --lda 2816 --stride_a 360448 --b_type f32_r --ldb 128 --stride_b 0 --beta 0 --c_type f32_r --ldc 2816 --stride_c 1441792 --d_type f32_r --ldd 2816 --stride_d 1441792 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 237 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 2816 -n 512 -k 256 --alpha 1 --a_type f32_r --lda 2816 --stride_a 720896 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 2816 --stride_c 1441792 --d_type f32_r --ldd 2816 --stride_d 1441792 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 119 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 40000 -n 256 -k 256 --alpha 1 --a_type f32_r --lda 40000 --stride_a 10240000 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 40000 --stride_c 10240000 --d_type f32_r --ldd 40000 --stride_d 10240000 --batch_count 24 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 119 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB N -m 704 -n 152 -k 256 --alpha 1 --a_type f32_r --lda 704 --stride_a 180224 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 704 --stride_c 107008 --d_type f32_r --ldd 704 --stride_d 107008 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 118 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 11264 -n 256 -k 128 --alpha 1 --a_type f32_r --lda 11264 --stride_a 1441792 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 11264 --stride_c 2883584 --d_type f32_r --ldd 11264 --stride_d 2883584 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 236 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 11264 -n 256 -k 64 --alpha 1 --a_type f32_r --lda 11264 --stride_a 720896 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 11264 --stride_c 2883584 --d_type f32_r --ldd 11264 --stride_d 2883584 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 118 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 2816 -n 256 -k 512 --alpha 1 --a_type f32_r --lda 2816 --stride_a 1441792 --b_type f32_r --ldb 256 --stride_b 0 --beta 0 --c_type f32_r --ldc 2816 --stride_c 720896 --d_type f32_r --ldd 2816 --stride_d 720896 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 118 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 704 -n 512 -k 1024 --alpha 1 --a_type f32_r --lda 704 --stride_a 720896 --b_type f32_r --ldb 512 --stride_b 0 --beta 0 --c_type f32_r --ldc 704 --stride_c 360448 --d_type f32_r --ldd 704 --stride_d 360448 --batch_count 144 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 118 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 512 -n 512 -k 9600 --alpha 1 --a_type f32_r --lda 9600 --stride_a 4915200 --b_type f32_r --ldb 9600 --stride_b 4915200 --beta 0 --c_type f32_r --ldc 512 --stride_c 262144 --d_type f32_r --ldd 512 --stride_d 262144 --batch_count 49 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 118 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 512 -n 640 -k 9600 --alpha 1 --a_type f32_r --lda 9600 --stride_a 4915200 --b_type f32_r --ldb 9600 --stride_b 6144000 --beta 0 --c_type f32_r --ldc 512 --stride_c 327680 --d_type f32_r --ldd 512 --stride_d 327680 --batch_count 49 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 2 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 3 --stride_b 3 --beta 0 --ldc 3 --stride_c 3 --batch_count 8921088 - 2 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 3 -n 3 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 4 --stride_b 16 --beta 0 --ldc 3 --stride_c 9 --batch_count 144 - 4 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 3 --beta 0 --ldc 3 --stride_c 3 --batch_count 8921088 - 238 ./rocblas-bench -f gemm_strided_batched -r f64_r --transposeA N --transposeB N -m 4 -n 4 -k 4 --alpha 1 --lda 4 --stride_a 16 --ldb 4 --stride_b 16 --beta 0 --ldc 4 --stride_c 16 --batch_count 144 diff --git a/docker-hub/FlashOCC/Flashocc/start_flashocc.sh b/docker-hub/FlashOCC/Flashocc/start_flashocc.sh deleted file mode 100755 index 998a95989e5afb33f45b4559ff8158fbedbcbb1a..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/start_flashocc.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -export NCCL_TOPO_FILE=null -export NCCL_ALGO=Ring -export NCCL_RINGS="N0 0 7 6 5 4 3 2 1 N0|N1 1 2 3 4 5 6 7 0 N1|N2 2 1 0 7 6 5 4 3 N2|N3 3 4 5 6 7 0 1 2 N3|N4 4 3 2 1 0 7 6 5 N4|N5 5 6 7 0 1 2 3 4 N5|N6 6 5 4 3 2 1 0 7 N6|N7 7 0 1 2 3 4 5 6 N7" - -export PYTORCH_MIOPEN_SUGGEST_NHWC=1 -export MIOPEN_PRECISION_FP32_FP32_FP32_TF32_FP32=1 -export MIOPEN_FIND_MODE=1 -export ROCBLAS_MATH_MODE=1 -export HSA_FORCE_FINE_GRAIN_PCIE=1 - -export TORCHINDUCTOR_LAYOUT_OPTIMIZATION=1 -export TORCHINDUCTOR_COORDINATE_DESCENT_TUNING=1 - -#export MIOPEN_ENABLE_LOGGING=1 # 打开MIOPEN LOGGING日志 default =0 -#export MIOPEN_ENABLE_LOGGING_CMD=1 # 输出日志CMD信息 default =0 -#export MIOPEN_LOG_LEVEL=6 # 设置日志打印level default=0 -#export ROCBLAS_LAYER=3 # 打开 rocblas输出日志 default=0 - - - - - -TIME=$(date "+%Y-%m-%d_%H_%M") - -MASTER_ADDR=${1:-localhost} -NNODES=${2:-1} -NODE_RANK=${3:-0} -CONFIG=${4:-projects/configs/flashocc/flashocc-r50.py} - -bash tools/dist_train_numa.sh $MASTER_ADDR $NNODES $NODE_RANK $CONFIG \ - 2>&1 | tee cvm_bw1000_flashocc_${NNODES}nodes_$TIME.log diff --git a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark.py b/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark.py deleted file mode 100644 index 9a1abbb7355e3c406f9ca559070f08b65cc0e362..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark.py +++ /dev/null @@ -1,144 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import sys -import argparse -import time -import os -import torch -from mmcv import Config -from mmcv.parallel import MMDataParallel -from mmcv.runner import load_checkpoint, wrap_fp16_model - -from mmdet3d.datasets import build_dataloader, build_dataset -from mmdet3d.models import build_detector -from tools.misc.fuse_conv_bn import fuse_module - -sys.path.insert(0, os.getcwd()) -print(sys.path) - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet benchmark a model') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--samples', default=500, help='samples to benchmark') - parser.add_argument( - '--log-interval', default=50, help='interval of logging') - parser.add_argument( - '--fuse-conv-bn', - action='store_true', - help='Whether to fuse conv and bn, this will slightly increase' - 'the inference speed') - parser.add_argument( - '--w_pano', - action='store_true') - parser.add_argument( - '--w_panoproc', - action='store_true') - parser.add_argument( - '--no-acceleration', - action='store_true', - help='Omit the pre-computation acceleration') - args = parser.parse_args() - return args - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - plg_lib = importlib.import_module(_module_path) - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - samples_per_gpu=1, - workers_per_gpu=0, - dist=False, - shuffle=False) - - # build the model and load checkpoint - if not args.no_acceleration: - cfg.model.img_view_transformer.accelerate=True - cfg.model.train_cfg = None - model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg')) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - load_checkpoint(model, args.checkpoint, map_location='cpu') - if args.fuse_conv_bn: - model = fuse_module(model) - - model = MMDataParallel(model, device_ids=[0]) - - model.eval() - - # the first several iterations may be very slow so skip them - num_warmup = 5 - pure_inf_time = 0 - - # benchmark with several samples and take the average - # for i, data_ori in enumerate(data_loader): - # if i == 0: - # break - # import copy - # for i in range(500): - # data = copy.deepcopy(data_ori) - for i, data in enumerate(data_loader): - - torch.cuda.synchronize() - start_time = time.perf_counter() - - with torch.no_grad(): - model(return_loss=False, rescale=True, - w_pano=args.w_pano, - w_panoproc=args.w_panoproc, - **data) - - torch.cuda.synchronize() - elapsed = time.perf_counter() - start_time - - if i >= num_warmup: - pure_inf_time += elapsed - if (i + 1) % args.log_interval == 0: - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Done image [{i + 1:<3}/ {args.samples}], ' - f'fps: {fps:.1f} img / s') - - if (i + 1) == args.samples: - pure_inf_time += elapsed - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Overall \nfps: {fps:.2f} img / s ' - f'\ninference time: {1000 / fps:.2f} ms') - break - - -if __name__ == '__main__': - main() diff --git a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark_sequential.py b/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark_sequential.py deleted file mode 100644 index 7a52c1e469248cf2944db002f2d6848d7dd0fd1c..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/benchmark_sequential.py +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import argparse -import time -import os -import sys -import torch -from mmcv import Config -from mmcv.parallel import MMDataParallel -from mmcv.runner import load_checkpoint, wrap_fp16_model - -from mmdet3d.datasets import build_dataloader, build_dataset -from mmdet3d.models import build_detector -from tools.misc.fuse_conv_bn import fuse_module - -sys.path.insert(0, os.getcwd()) -print(sys.path) - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet benchmark a model') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--samples', default=400, help='samples to benchmark') - parser.add_argument( - '--log-interval', default=50, help='interval of logging') - parser.add_argument( - '--fuse-conv-bn', - action='store_true', - help='Whether to fuse conv and bn, this will slightly increase' - 'the inference speed') - parser.add_argument( - '--w_pano', - action='store_true') - parser.add_argument( - '--w_panoproc', - action='store_true') - parser.add_argument( - '--no-acceleration', - action='store_true', - help='Omit the pre-computation acceleration') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - plg_lib = importlib.import_module(_module_path) - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - samples_per_gpu=1, - workers_per_gpu=0, - dist=False, - shuffle=False) - - # build the model and load checkpoint - cfg.model.train_cfg = None - cfg.model.align_after_view_transfromation=True - if not args.no_acceleration: - cfg.model.img_view_transformer.accelerate=True - model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg')) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - load_checkpoint(model, args.checkpoint, map_location='cpu') - if args.fuse_conv_bn: - model = fuse_module(model) - - model = MMDataParallel(model, device_ids=[0]) - - model.eval() - - # the first several iterations may be very slow so skip them - num_warmup = 5 - pure_inf_time = 0 - - # benchmark with several samples and take the average - for i, data in enumerate(data_loader): - inputs = [d.cuda() for d in data['img_inputs'][0]] - with torch.no_grad(): - feat_prev, inputs = model.module.extract_img_feat( - inputs, pred_prev=True, img_metas=None) - data['img_inputs'][0] = inputs - - torch.cuda.synchronize() - start_time = time.perf_counter() - - with torch.no_grad(): - model( - return_loss=False, - rescale=True, - sequential=True, - feat_prev=feat_prev, - w_pano=args.w_pano, - w_panoproc=args.w_panoproc, - **data) - - torch.cuda.synchronize() - elapsed = time.perf_counter() - start_time - - if i >= num_warmup: - pure_inf_time += elapsed - if (i + 1) % args.log_interval == 0: - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Done image [{i + 1:<3}/ {args.samples}], ' - f'fps: {fps:.1f} img / s') - - if (i + 1) == args.samples: - pure_inf_time += elapsed - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Overall \nfps: {fps:.2f} img / s ' - f'\ninference time: {1000 / fps:.2f} ms') - break - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/vis_occ.py b/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/vis_occ.py deleted file mode 100644 index 7a5b8f6e47e9c4fdd3534d9a86e01fc114934e7a..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/analysis_tools/vis_occ.py +++ /dev/null @@ -1,415 +0,0 @@ -import os - -import mmcv -import open3d as o3d -import numpy as np -import torch -import pickle -import math -from typing import Tuple, List, Dict, Iterable -import argparse -import cv2 - -NOT_OBSERVED = -1 -FREE = 0 -OCCUPIED = 1 -FREE_LABEL = 17 -BINARY_OBSERVED = 1 -BINARY_NOT_OBSERVED = 0 - -VOXEL_SIZE = [0.4, 0.4, 0.4] -POINT_CLOUD_RANGE = [-40, -40, -1, 40, 40, 5.4] -SPTIAL_SHAPE = [200, 200, 16] -TGT_VOXEL_SIZE = [0.4, 0.4, 0.4] -TGT_POINT_CLOUD_RANGE = [-40, -40, -1, 40, 40, 5.4] - - -colormap_to_colors = np.array( - [ - [0, 0, 0, 255], # 0 undefined - [112, 128, 144, 255], # 1 barrier orange - [220, 20, 60, 255], # 2 bicycle Blue - [255, 127, 80, 255], # 3 bus Darkslategrey - [255, 158, 0, 255], # 4 car Crimson - [233, 150, 70, 255], # 5 cons. Veh Orangered - [255, 61, 99, 255], # 6 motorcycle Darkorange - [0, 0, 230, 255], # 7 pedestrian Darksalmon - [47, 79, 79, 255], # 8 traffic cone Red - [255, 140, 0, 255],# 9 trailer Slategrey - [255, 99, 71, 255],# 10 truck Burlywood - [0, 207, 191, 255], # 11 drive sur Green - [175, 0, 75, 255], # 12 other lat nuTonomy green - [75, 0, 75, 255], # 13 sidewalk - [112, 180, 60, 255], # 14 terrain - [222, 184, 135, 255], # 15 manmade - [0, 175, 0, 255], # 16 vegeyation -], dtype=np.float32) - - - -def voxel2points(voxel, occ_show, voxelSize): - """ - Args: - voxel: (Dx, Dy, Dz) - occ_show: (Dx, Dy, Dz) - voxelSize: (dx, dy, dz) - - Returns: - points: (N, 3) 3: (x, y, z) - voxel: (N, ) cls_id - occIdx: (x_idx, y_idx, z_idx) - """ - occIdx = torch.where(occ_show) - points = torch.cat((occIdx[0][:, None] * voxelSize[0] + POINT_CLOUD_RANGE[0], \ - occIdx[1][:, None] * voxelSize[1] + POINT_CLOUD_RANGE[1], \ - occIdx[2][:, None] * voxelSize[2] + POINT_CLOUD_RANGE[2]), - dim=1) # (N, 3) 3: (x, y, z) - return points, voxel[occIdx], occIdx - - -def voxel_profile(voxel, voxel_size): - """ - Args: - voxel: (N, 3) 3:(x, y, z) - voxel_size: (vx, vy, vz) - - Returns: - box: (N, 7) (x, y, z - dz/2, vx, vy, vz, 0) - """ - centers = torch.cat((voxel[:, :2], voxel[:, 2][:, None] - voxel_size[2] / 2), dim=1) # (x, y, z - dz/2) - # centers = voxel - wlh = torch.cat((torch.tensor(voxel_size[0]).repeat(centers.shape[0])[:, None], - torch.tensor(voxel_size[1]).repeat(centers.shape[0])[:, None], - torch.tensor(voxel_size[2]).repeat(centers.shape[0])[:, None]), dim=1) - yaw = torch.full_like(centers[:, 0:1], 0) - return torch.cat((centers, wlh, yaw), dim=1) - - -def rotz(t): - """Rotation about the z-axis.""" - c = torch.cos(t) - s = torch.sin(t) - return torch.tensor([[c, -s, 0], - [s, c, 0], - [0, 0, 1]]) - - -def my_compute_box_3d(center, size, heading_angle): - """ - Args: - center: (N, 3) 3: (x, y, z - dz/2) - size: (N, 3) 3: (vx, vy, vz) - heading_angle: (N, 1) - Returns: - corners_3d: (N, 8, 3) - """ - h, w, l = size[:, 2], size[:, 0], size[:, 1] - center[:, 2] = center[:, 2] + h / 2 - l, w, h = (l / 2).unsqueeze(1), (w / 2).unsqueeze(1), (h / 2).unsqueeze(1) - x_corners = torch.cat([-l, l, l, -l, -l, l, l, -l], dim=1)[..., None] - y_corners = torch.cat([w, w, -w, -w, w, w, -w, -w], dim=1)[..., None] - z_corners = torch.cat([h, h, h, h, -h, -h, -h, -h], dim=1)[..., None] - corners_3d = torch.cat([x_corners, y_corners, z_corners], dim=2) - corners_3d[..., 0] += center[:, 0:1] - corners_3d[..., 1] += center[:, 1:2] - corners_3d[..., 2] += center[:, 2:3] - return corners_3d - - -def show_point_cloud(points: np.ndarray, colors=True, points_colors=None, bbox3d=None, voxelize=False, - bbox_corners=None, linesets=None, vis=None, offset=[0,0,0], large_voxel=True, voxel_size=0.4): - """ - :param points: (N, 3) 3:(x, y, z) - :param colors: false 不显示点云颜色 - :param points_colors: (N, 4) - :param bbox3d: voxel grid (N, 7) 7: (center, wlh, yaw=0) - :param voxelize: false 不显示voxel边界 - :param bbox_corners: (N, 8, 3) voxel grid 角点坐标, 用于绘制voxel grid 边界. - :param linesets: 用于绘制voxel grid 边界. - :return: - """ - if vis is None: - vis = o3d.visualization.VisualizerWithKeyCallback() - vis.create_window() - if isinstance(offset, list) or isinstance(offset, tuple): - offset = np.array(offset) - - pcd = o3d.geometry.PointCloud() - pcd.points = o3d.utility.Vector3dVector(points+offset) - if colors: - pcd.colors = o3d.utility.Vector3dVector(points_colors[:, :3]) - mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame( - size=1, origin=[0, 0, 0]) - - voxelGrid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd, voxel_size=voxel_size) - if large_voxel: - vis.add_geometry(voxelGrid) - else: - vis.add_geometry(pcd) - - if voxelize: - line_sets = o3d.geometry.LineSet() - line_sets.points = o3d.open3d.utility.Vector3dVector(bbox_corners.reshape((-1, 3))+offset) - line_sets.lines = o3d.open3d.utility.Vector2iVector(linesets.reshape((-1, 2))) - line_sets.paint_uniform_color((0, 0, 0)) - vis.add_geometry(line_sets) - - vis.add_geometry(mesh_frame) - - # ego_pcd = o3d.geometry.PointCloud() - # ego_points = generate_the_ego_car() - # ego_pcd.points = o3d.utility.Vector3dVector(ego_points) - # vis.add_geometry(ego_pcd) - - return vis - - -def show_occ(occ_state, occ_show, voxel_size, vis=None, offset=[0, 0, 0]): - """ - Args: - occ_state: (Dx, Dy, Dz), cls_id - occ_show: (Dx, Dy, Dz), bool - voxel_size: [0.4, 0.4, 0.4] - vis: Visualizer - offset: - - Returns: - - """ - colors = colormap_to_colors / 255 - pcd, labels, occIdx = voxel2points(occ_state, occ_show, voxel_size) - # pcd: (N, 3) 3: (x, y, z) - # labels: (N, ) cls_id - _labels = labels % len(colors) - pcds_colors = colors[_labels] # (N, 4) - - bboxes = voxel_profile(pcd, voxel_size) # (N, 7) 7: (x, y, z - dz/2, dx, dy, dz, 0) - bboxes_corners = my_compute_box_3d(bboxes[:, 0:3], bboxes[:, 3:6], bboxes[:, 6:7]) # (N, 8, 3) - - bases_ = torch.arange(0, bboxes_corners.shape[0] * 8, 8) - edges = torch.tensor([[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [1, 5], [2, 6], [3, 7]]) # lines along y-axis - edges = edges.reshape((1, 12, 2)).repeat(bboxes_corners.shape[0], 1, 1) # (N, 12, 2) - # (N, 12, 2) + (N, 1, 1) --> (N, 12, 2) 此时edges中记录的是bboxes_corners的整体id: (0, N*8). - edges = edges + bases_[:, None, None] - - vis = show_point_cloud( - points=pcd.numpy(), - colors=True, - points_colors=pcds_colors, - voxelize=True, - bbox3d=bboxes.numpy(), - bbox_corners=bboxes_corners.numpy(), - linesets=edges.numpy(), - vis=vis, - offset=offset, - large_voxel=True, - voxel_size=0.4 - ) - return vis - - -def generate_the_ego_car(): - ego_range = [-2, -1, 0, 2, 1, 1.5] - ego_voxel_size=[0.1, 0.1, 0.1] - ego_xdim = int((ego_range[3] - ego_range[0]) / ego_voxel_size[0]) - ego_ydim = int((ego_range[4] - ego_range[1]) / ego_voxel_size[1]) - ego_zdim = int((ego_range[5] - ego_range[2]) / ego_voxel_size[2]) - temp_x = np.arange(ego_xdim) - temp_y = np.arange(ego_ydim) - temp_z = np.arange(ego_zdim) - ego_xyz = np.stack(np.meshgrid(temp_y, temp_x, temp_z), axis=-1).reshape(-1, 3) - ego_point_x = (ego_xyz[:, 0:1] + 0.5) / ego_xdim * (ego_range[3] - ego_range[0]) + ego_range[0] - ego_point_y = (ego_xyz[:, 1:2] + 0.5) / ego_ydim * (ego_range[4] - ego_range[1]) + ego_range[1] - ego_point_z = (ego_xyz[:, 2:3] + 0.5) / ego_zdim * (ego_range[5] - ego_range[2]) + ego_range[2] - ego_point_xyz = np.concatenate((ego_point_y, ego_point_x, ego_point_z), axis=-1) - ego_points_label = (np.ones((ego_point_xyz.shape[0]))*16).astype(np.uint8) - ego_dict = {} - ego_dict['point'] = ego_point_xyz - ego_dict['label'] = ego_points_label - return ego_point_xyz - - -def parse_args(): - parser = argparse.ArgumentParser(description='Visualize the predicted ' - 'result of nuScenes') - parser.add_argument( - 'res', help='Path to the predicted result') - parser.add_argument( - '--canva-size', type=int, default=1000, help='Size of canva in pixel') - parser.add_argument( - '--vis-frames', - type=int, - default=500, - help='Number of frames for visualization') - parser.add_argument( - '--scale-factor', - type=int, - default=4, - help='Trade-off between image-view and bev in size of ' - 'the visualized canvas') - parser.add_argument( - '--version', - type=str, - default='val', - help='Version of nuScenes dataset') - parser.add_argument('--draw-gt', action='store_true') - parser.add_argument( - '--root_path', - type=str, - default='./data/nuscenes', - help='Path to nuScenes dataset') - parser.add_argument( - '--save_path', - type=str, - default='./vis', - help='Path to save visualization results') - parser.add_argument( - '--format', - type=str, - default='image', - choices=['video', 'image'], - help='The desired format of the visualization result') - parser.add_argument( - '--fps', type=int, default=10, help='Frame rate of video') - parser.add_argument( - '--video-prefix', type=str, default='vis', help='name of video') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - # load predicted results - results_dir = args.res - - # load dataset information - info_path = \ - args.root_path + '/bevdetv2-nuscenes_infos_%s.pkl' % args.version - dataset = pickle.load(open(info_path, 'rb')) - # prepare save path and medium - vis_dir = args.save_path - if not os.path.exists(vis_dir): - os.makedirs(vis_dir) - print('saving visualized result to %s' % vis_dir) - scale_factor = args.scale_factor - canva_size = args.canva_size - if args.format == 'video': - fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') - vout = cv2.VideoWriter( - os.path.join(vis_dir, '%s.mp4' % args.video_prefix), fourcc, - args.fps, (int(1600 / scale_factor * 3), - int(900 / scale_factor * 2 + canva_size))) - - views = [ - 'CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_LEFT', - 'CAM_BACK', 'CAM_BACK_RIGHT' - ] - print('start visualizing results') - - vis = o3d.visualization.VisualizerWithKeyCallback() - vis.create_window() - - for cnt, info in enumerate( - dataset['infos'][:min(args.vis_frames, len(dataset['infos']))]): - if cnt % 10 == 0: - print('%d/%d' % (cnt, min(args.vis_frames, len(dataset['infos'])))) - - scene_name = info['scene_name'] - sample_token = info['token'] - - pred_occ_path = os.path.join(results_dir, scene_name, sample_token, 'pred.npz') - gt_occ_path = info['occ_path'] - - pred_occ = np.load(pred_occ_path)['pred'] - gt_data = np.load(os.path.join(args.root_path, gt_occ_path, 'labels.npz')) - voxel_label = gt_data['semantics'] - lidar_mask = gt_data['mask_lidar'] - camera_mask = gt_data['mask_camera'] - - # load imgs - imgs = [] - for view in views: - img = cv2.imread(info['cams'][view]['data_path']) - imgs.append(img) - - # occ_canvas - voxel_show = np.logical_and(pred_occ != FREE_LABEL, camera_mask) - # voxel_show = pred_occ != FREE_LABEL - voxel_size = VOXEL_SIZE - vis = show_occ(torch.from_numpy(pred_occ), torch.from_numpy(voxel_show), voxel_size=voxel_size, vis=vis, - offset=[0, pred_occ.shape[0] * voxel_size[0] * 1.2 * 0, 0]) - - if args.draw_gt: - voxel_show = np.logical_and(voxel_label != FREE_LABEL, camera_mask) - vis = show_occ(torch.from_numpy(voxel_label), torch.from_numpy(voxel_show), voxel_size=voxel_size, vis=vis, - offset=[0, voxel_label.shape[0] * voxel_size[0] * 1.2 * 1, 0]) - - view_control = vis.get_view_control() - - look_at = np.array([-0.185, 0.513, 3.485]) - front = np.array([-0.974, -0.055, 0.221]) - up = np.array([0.221, 0.014, 0.975]) - zoom = np.array([0.08]) - - view_control.set_lookat(look_at) - view_control.set_front(front) - view_control.set_up(up) - view_control.set_zoom(zoom) - - opt = vis.get_render_option() - opt.background_color = np.asarray([1, 1, 1]) - opt.line_width = 5 - - vis.poll_events() - vis.update_renderer() - vis.run() - - # if args.format == 'image': - # out_dir = os.path.join(vis_dir, f'{scene_name}', f'{sample_token}') - # mmcv.mkdir_or_exist(out_dir) - # vis.capture_screen_image(os.path.join(out_dir, 'screen_occ.png'), do_render=True) - - occ_canvas = vis.capture_screen_float_buffer(do_render=True) - occ_canvas = np.asarray(occ_canvas) - occ_canvas = (occ_canvas * 255).astype(np.uint8) - occ_canvas = occ_canvas[..., [2, 1, 0]] - occ_canvas_resize = cv2.resize(occ_canvas, (canva_size, canva_size), interpolation=cv2.INTER_CUBIC) - - vis.clear_geometries() - - big_img = np.zeros((900 * 2 + canva_size * scale_factor, 1600 * 3, 3), - dtype=np.uint8) - big_img[:900, :, :] = np.concatenate(imgs[:3], axis=1) - img_back = np.concatenate( - [imgs[3][:, ::-1, :], imgs[4][:, ::-1, :], imgs[5][:, ::-1, :]], - axis=1) - big_img[900 + canva_size * scale_factor:, :, :] = img_back - big_img = cv2.resize(big_img, (int(1600 / scale_factor * 3), - int(900 / scale_factor * 2 + canva_size))) - w_begin = int((1600 * 3 / scale_factor - canva_size) // 2) - big_img[int(900 / scale_factor):int(900 / scale_factor) + canva_size, - w_begin:w_begin + canva_size, :] = occ_canvas_resize - - if args.format == 'image': - out_dir = os.path.join(vis_dir, f'{scene_name}', f'{sample_token}') - mmcv.mkdir_or_exist(out_dir) - for i, img in enumerate(imgs): - cv2.imwrite(os.path.join(out_dir, f'img{i}.png'), img) - cv2.imwrite(os.path.join(out_dir, 'occ.png'), occ_canvas) - cv2.imwrite(os.path.join(out_dir, 'overall.png'), big_img) - elif args.format == 'video': - cv2.putText(big_img, f'{cnt:{cnt}}', (5, 15), fontFace=cv2.FONT_HERSHEY_COMPLEX, color=(0, 0, 0), - fontScale=0.5) - cv2.putText(big_img, f'{scene_name}', (5, 35), fontFace=cv2.FONT_HERSHEY_COMPLEX, color=(0, 0, 0), - fontScale=0.5) - cv2.putText(big_img, f'{sample_token[:5]}', (5, 55), fontFace=cv2.FONT_HERSHEY_COMPLEX, color=(0, 0, 0), - fontScale=0.5) - vout.write(big_img) - - if args.format == 'video': - vout.release() - vis.destroy_window() - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/docker-hub/FlashOCC/Flashocc/tools/convert_bevdet_to_TRT.py b/docker-hub/FlashOCC/Flashocc/tools/convert_bevdet_to_TRT.py deleted file mode 100644 index 80b5da9e714183e14d75059e1d13a11bd530f413..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/convert_bevdet_to_TRT.py +++ /dev/null @@ -1,560 +0,0 @@ -import argparse -import sys -import os -sys.path.insert(0, os.getcwd()) - -import torch.onnx -from mmcv import Config -from mmdeploy.backend.tensorrt.utils import save, search_cuda_version - -try: - # If mmdet version > 2.23.0, compat_cfg would be imported and - # used from mmdet instead of mmdet3d. - from mmdet.utils import compat_cfg -except ImportError: - from mmdet3d.utils import compat_cfg - -import os -from typing import Dict, Optional, Sequence, Union - -import h5py -import mmcv -import numpy as np -import onnx -import pycuda.driver as cuda -import tensorrt as trt -import torch -import tqdm -from mmcv.runner import load_checkpoint -from mmdeploy.apis.core import no_mp -from mmdeploy.backend.tensorrt.calib_utils import HDF5Calibrator -from mmdeploy.backend.tensorrt.init_plugins import load_tensorrt_plugin -from mmdeploy.utils import load_config -from packaging import version -from torch.utils.data import DataLoader - -from mmdet3d.datasets import build_dataloader, build_dataset -from mmdet3d.models import build_model -from mmdet.datasets import replace_ImageToTensor -from tools.misc.fuse_conv_bn import fuse_module - - -class HDF5CalibratorBEVDet(HDF5Calibrator): - - def get_batch(self, names: Sequence[str], **kwargs) -> list: - """Get batch data.""" - if self.count < self.dataset_length: - if self.count % 100 == 0: - print('%d/%d' % (self.count, self.dataset_length)) - ret = [] - for name in names: - input_group = self.calib_data[name] - if name == 'img': - data_np = input_group[str(self.count)][...].astype( - np.float32) - else: - data_np = input_group[str(self.count)][...].astype( - np.int32) - - # tile the tensor so we can keep the same distribute - opt_shape = self.input_shapes[name]['opt_shape'] - data_shape = data_np.shape - - reps = [ - int(np.ceil(opt_s / data_s)) - for opt_s, data_s in zip(opt_shape, data_shape) - ] - - data_np = np.tile(data_np, reps) - - slice_list = tuple(slice(0, end) for end in opt_shape) - data_np = data_np[slice_list] - - data_np_cuda_ptr = cuda.mem_alloc(data_np.nbytes) - cuda.memcpy_htod(data_np_cuda_ptr, - np.ascontiguousarray(data_np)) - self.buffers[name] = data_np_cuda_ptr - - ret.append(self.buffers[name]) - self.count += 1 - return ret - else: - return None - - -def parse_args(): - parser = argparse.ArgumentParser(description='Deploy BEVDet with Tensorrt') - parser.add_argument('config', help='deploy config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('work_dir', help='work dir to save file') - parser.add_argument( - '--prefix', default='bevdet', help='prefix of the save file name') - parser.add_argument( - '--fp16', action='store_true', help='Whether to use tensorrt fp16') - parser.add_argument( - '--int8', action='store_true', help='Whether to use tensorrt int8') - parser.add_argument( - '--fuse-conv-bn', - action='store_true', - help='Whether to fuse conv and bn, this will slightly increase' - 'the inference speed') - parser.add_argument('--calib_num', type=int, help='num to calib') - args = parser.parse_args() - return args - - -def get_plugin_names(): - return [pc.name for pc in trt.get_plugin_registry().plugin_creator_list] - - -def create_calib_input_data_impl(calib_file: str, - dataloader: DataLoader, - model_partition: bool = False, - metas: list = [], - calib_num = None) -> None: - with h5py.File(calib_file, mode='w') as file: - calib_data_group = file.create_group('calib_data') - assert not model_partition - # create end2end group - input_data_group = calib_data_group.create_group('end2end') - input_group_img = input_data_group.create_group('img') - input_keys = [ - 'ranks_bev', 'ranks_depth', 'ranks_feat', 'interval_starts', - 'interval_lengths' - ] - input_groups = [] - for input_key in input_keys: - input_groups.append(input_data_group.create_group(input_key)) - metas = [ - metas[i].int().detach().cpu().numpy() for i in range(len(metas)) - ] - for data_id, input_data in enumerate(tqdm.tqdm(dataloader)): - # save end2end data - if (calib_num is not None) and (data_id > calib_num): - break - input_tensor = input_data['img_inputs'][0][0] - input_ndarray = input_tensor.squeeze(0).detach().cpu().numpy() - # print(input_ndarray.shape, input_ndarray.dtype) - input_group_img.create_dataset( - str(data_id), - shape=input_ndarray.shape, - compression='gzip', - compression_opts=4, - data=input_ndarray) - for kid, input_key in enumerate(input_keys): - input_groups[kid].create_dataset( - str(data_id), - shape=metas[kid].shape, - compression='gzip', - compression_opts=4, - data=metas[kid]) - file.flush() - - -def create_calib_input_data(calib_file: str, - deploy_cfg: Union[str, mmcv.Config], - model_cfg: Union[str, mmcv.Config], - model_checkpoint: Optional[str] = None, - dataset_cfg: Optional[Union[str, - mmcv.Config]] = None, - dataset_type: str = 'val', - device: str = 'cpu', - metas: list = [None], - calib_num = None) -> None: - """Create dataset for post-training quantization. - - Args: - calib_file (str): The output calibration data file. - deploy_cfg (str | mmcv.Config): Deployment config file or - Config object. - model_cfg (str | mmcv.Config): Model config file or Config object. - model_checkpoint (str): A checkpoint path of PyTorch model, - defaults to `None`. - dataset_cfg (Optional[Union[str, mmcv.Config]], optional): Model - config to provide calibration dataset. If none, use `model_cfg` - as the dataset config. Defaults to None. - dataset_type (str, optional): The dataset type. Defaults to 'val'. - device (str, optional): Device to create dataset. Defaults to 'cpu'. - """ - with no_mp(): - if dataset_cfg is None: - dataset_cfg = model_cfg - - # load cfg if necessary - deploy_cfg, model_cfg = load_config(deploy_cfg, model_cfg) - - if dataset_cfg is None: - dataset_cfg = model_cfg - - # load dataset_cfg if necessary - dataset_cfg = load_config(dataset_cfg)[0] - - from mmdeploy.apis.utils import build_task_processor - task_processor = build_task_processor(model_cfg, deploy_cfg, device) - - dataset = task_processor.build_dataset(dataset_cfg, dataset_type) - - dataloader = task_processor.build_dataloader( - dataset, 1, 1, dist=False, shuffle=False) - - create_calib_input_data_impl( - calib_file, dataloader, model_partition=False, metas=metas, calib_num=calib_num) - - -def from_onnx(onnx_model: Union[str, onnx.ModelProto], - output_file_prefix: str, - input_shapes: Dict[str, Sequence[int]], - max_workspace_size: int = 0, - fp16_mode: bool = False, - int8_mode: bool = False, - int8_param: Optional[dict] = None, - device_id: int = 0, - log_level: trt.Logger.Severity = trt.Logger.ERROR, - **kwargs) -> trt.ICudaEngine: - """Create a tensorrt engine from ONNX. - - Modified from mmdeploy.backend.tensorrt.utils.from_onnx - """ - - import os - old_cuda_device = os.environ.get('CUDA_DEVICE', None) - os.environ['CUDA_DEVICE'] = str(device_id) - import pycuda.autoinit # noqa:F401 - if old_cuda_device is not None: - os.environ['CUDA_DEVICE'] = old_cuda_device - else: - os.environ.pop('CUDA_DEVICE') - - load_tensorrt_plugin() - # create builder and network - logger = trt.Logger(log_level) - builder = trt.Builder(logger) - EXPLICIT_BATCH = 1 << (int)( - trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH) - network = builder.create_network(EXPLICIT_BATCH) - - # parse onnx - parser = trt.OnnxParser(network, logger) - - if isinstance(onnx_model, str): - onnx_model = onnx.load(onnx_model) - - if not parser.parse(onnx_model.SerializeToString()): - error_msgs = '' - for error in range(parser.num_errors): - error_msgs += f'{parser.get_error(error)}\n' - raise RuntimeError(f'Failed to parse onnx, {error_msgs}') - - # config builder - if version.parse(trt.__version__) < version.parse('8'): - builder.max_workspace_size = max_workspace_size - - config = builder.create_builder_config() - config.max_workspace_size = max_workspace_size - - cuda_version = search_cuda_version() - if cuda_version is not None: - version_major = int(cuda_version.split('.')[0]) - if version_major < 11: - # cu11 support cublasLt, so cudnn heuristic tactic should disable CUBLAS_LT # noqa E501 - tactic_source = config.get_tactic_sources() - ( - 1 << int(trt.TacticSource.CUBLAS_LT)) - config.set_tactic_sources(tactic_source) - - profile = builder.create_optimization_profile() - - for input_name, param in input_shapes.items(): - min_shape = param['min_shape'] - opt_shape = param['opt_shape'] - max_shape = param['max_shape'] - profile.set_shape(input_name, min_shape, opt_shape, max_shape) - config.add_optimization_profile(profile) - - if fp16_mode: - if version.parse(trt.__version__) < version.parse('8'): - builder.fp16_mode = fp16_mode - config.set_flag(trt.BuilderFlag.FP16) - - if int8_mode: - config.set_flag(trt.BuilderFlag.INT8) - assert int8_param is not None - config.int8_calibrator = HDF5CalibratorBEVDet( - int8_param['calib_file'], - input_shapes, - model_type=int8_param['model_type'], - device_id=device_id, - algorithm=int8_param.get( - 'algorithm', trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2)) - if version.parse(trt.__version__) < version.parse('8'): - builder.int8_mode = int8_mode - builder.int8_calibrator = config.int8_calibrator - - # create engine - engine = builder.build_engine(network, config) - - assert engine is not None, 'Failed to create TensorRT engine' - - save(engine, output_file_prefix + '.engine') - print('Save engine at ', output_file_prefix + '.engine') - return engine - - -def main(): - args = parse_args() - - max_workspace_size = 200*200*256*(2**8) - - if not os.path.exists(args.work_dir): - os.makedirs(args.work_dir) - - load_tensorrt_plugin() - assert 'bev_pool_v2' in get_plugin_names(), \ - 'bev_pool_v2 is not in the plugin list of tensorrt, ' \ - 'please install mmdeploy from ' \ - 'https://github.com/HuangJunJie2017/mmdeploy.git' - - # if args.int8: - # assert args.fp16 - model_prefix = args.prefix - if args.int8: - model_prefix = model_prefix + '_int8' - elif args.fp16: - model_prefix = model_prefix + '_fp16' - cfg = Config.fromfile(args.config) - cfg.model.pretrained = None - cfg.model.type = cfg.model.type + 'TRT' - - cfg = compat_cfg(cfg) - cfg.gpu_ids = [0] - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - plg_lib = importlib.import_module(_module_path) - - # build the dataloader - test_dataloader_default_args = dict( - samples_per_gpu=1, workers_per_gpu=2, dist=False, shuffle=False) - - if isinstance(cfg.data.test, dict): - cfg.data.test.test_mode = True - if cfg.data.test_dataloader.get('samples_per_gpu', 1) > 1: - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.test.pipeline = replace_ImageToTensor( - cfg.data.test.pipeline) - elif isinstance(cfg.data.test, list): - for ds_cfg in cfg.data.test: - ds_cfg.test_mode = True - if cfg.data.test_dataloader.get('samples_per_gpu', 1) > 1: - for ds_cfg in cfg.data.test: - ds_cfg.pipeline = replace_ImageToTensor(ds_cfg.pipeline) - - test_loader_cfg = { - **test_dataloader_default_args, - **cfg.data.get('test_dataloader', {}) - } - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader(dataset, **test_loader_cfg) - - # build the model and load checkpoint - cfg.model.train_cfg = None - model = build_model(cfg.model, test_cfg=cfg.get('test_cfg')) - # assert model.img_view_transformer.grid_size[0] == 128 - # assert model.img_view_transformer.grid_size[1] == 128 - # assert model.img_view_transformer.grid_size[2] == 1 - if os.path.exists(args.checkpoint): - load_checkpoint(model, args.checkpoint, map_location='cpu') - else: - print(args.checkpoint, " does not exists!") - if args.fuse_conv_bn: - model_prefix = model_prefix + '_fuse' - model = fuse_module(model) - model.cuda() - model.eval() - - for i, data in enumerate(data_loader): - inputs = [t.cuda() for t in data['img_inputs'][0]] - img = inputs[0].squeeze(0) - if img.shape[0] > 6: - img = img[:6] - if model.__class__.__name__ in ['FBOCCTRT', 'FBOCC2DTRT']: - metas = model.get_bev_pool_input(inputs, img_metas=data['img_metas']) - else: - if model.__class__.__name__ in ['BEVDetOCCTRT']: - metas = model.get_bev_pool_input(inputs) - elif model.__class__.__name__ in ['BEVDepthOCCTRT']: - metas, mlp_input = model.get_bev_pool_input(inputs) - - if model.__class__.__name__ in ['FBOCCTRT', 'FBOCC2DTRT', 'BEVDetOCCTRT']: - onnx_input = (img.float().contiguous(), metas[1].int().contiguous(), - metas[2].int().contiguous(), metas[0].int().contiguous(), - metas[3].int().contiguous(), metas[4].int().contiguous()) - dynamic_axes={ - "ranks_depth" : {0: 'M'}, - "ranks_feat" : {0: 'M'}, - "ranks_bev" : {0: 'M'}, - "interval_starts" : {0: 'N'}, - "interval_lengths" : {0: 'N'}, - } - input_names=[ - 'img', 'ranks_depth', 'ranks_feat', 'ranks_bev', - 'interval_starts', 'interval_lengths' - ] - elif model.__class__.__name__ in ['BEVDepthOCCTRT']: - onnx_input = (img.float().contiguous(), metas[1].int().contiguous(), - metas[2].int().contiguous(), metas[0].int().contiguous(), - metas[3].int().contiguous(), metas[4].int().contiguous(), mlp_input) - dynamic_axes={ - "ranks_depth" : {0: 'M'}, - "ranks_feat" : {0: 'M'}, - "ranks_bev" : {0: 'M'}, - "interval_starts" : {0: 'N'}, - "interval_lengths" : {0: 'N'}, - # "mlp_input" : {0: 'K'}, - } - input_names=[ - 'img', 'ranks_depth', 'ranks_feat', 'ranks_bev', - 'interval_starts', 'interval_lengths', 'mlp_input', - ] - - with torch.no_grad(): - if (model.wdet3d == True) and (model.wocc == False) : - output_names=[f'output_{j}' for j in range(6 * len(model.pts_bbox_head.task_heads))] - elif (model.wdet3d == True) and (model.wocc == True) : - output_names=[f'output_{j}' for j in range(1 + 6 * len(model.pts_bbox_head.task_heads))] - elif (model.wdet3d == False) and (model.wocc == True) : - output_names=[f'output_{j}' for j in range(1)] - else: - raise(" At least one of wdet3d and wocc is set as True!! ") - - model.forward = model.forward_ori - torch.onnx.export( - model, - onnx_input, - args.work_dir + model_prefix + '.onnx', - opset_version=11, - dynamic_axes=dynamic_axes, - input_names=input_names, - output_names=output_names) - print('output_names:', output_names) - print('====== onnx is saved at : ', args.work_dir + model_prefix + '.onnx') - # check onnx model - onnx_model = onnx.load(args.work_dir + model_prefix + '.onnx') - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - - model.forward = model.forward_with_argmax - output_names = [f'cls_occ_label'] - torch.onnx.export( - model, - onnx_input, - args.work_dir + model_prefix + '_with_argmax.onnx', - opset_version=11, - dynamic_axes=dynamic_axes, - input_names=input_names, - output_names=output_names) - print('output_names:', output_names) - print('====== onnx is saved at : ', args.work_dir + model_prefix + '_with_argmax.onnx') - # check onnx model - onnx_model = onnx.load(args.work_dir + model_prefix + '_with_argmax.onnx') - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - - break - - # convert to tensorrt - num_points = metas[0].shape[0] - num_intervals = metas[3].shape[0] - img_shape = img.shape - input_shapes = dict( - img=dict( - min_shape=img_shape, opt_shape=img_shape, max_shape=img_shape), - ranks_depth=dict( - min_shape=[num_points], - opt_shape=[num_points], - max_shape=[num_points]), - ranks_feat=dict( - min_shape=[num_points], - opt_shape=[num_points], - max_shape=[num_points]), - ranks_bev=dict( - min_shape=[num_points], - opt_shape=[num_points], - max_shape=[num_points]), - interval_starts=dict( - min_shape=[num_intervals], - opt_shape=[num_intervals], - max_shape=[num_intervals]), - interval_lengths=dict( - min_shape=[num_intervals], - opt_shape=[num_intervals], - max_shape=[num_intervals])) - deploy_cfg = dict( - backend_config=dict( - type='tensorrt', - common_config=dict( - fp16_mode=args.fp16, - max_workspace_size=max_workspace_size, - int8_mode=args.int8), - model_inputs=[dict(input_shapes=input_shapes)]), - codebase_config=dict( - type='mmdet3d', task='VoxelDetection', model_type='end2end')) - - if args.int8: - calib_filename = 'calib_data.h5' - calib_path = os.path.join(args.work_dir, calib_filename) - create_calib_input_data( - calib_path, - deploy_cfg, - args.config, - args.checkpoint, - dataset_cfg=None, - dataset_type='val', - device='cuda:0', - metas=metas, - calib_num=args.calib_num) - - from_onnx( - args.work_dir + model_prefix + '.onnx', - args.work_dir + model_prefix, - fp16_mode=args.fp16, - int8_mode=args.int8, - int8_param=dict( - calib_file=os.path.join(args.work_dir, 'calib_data.h5'), - model_type='end2end'), - max_workspace_size=max_workspace_size, - input_shapes=input_shapes) - - # if args.int8: - # os.remove(calib_path) - - -if __name__ == '__main__': - - main() diff --git a/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/__init__.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 8f5f9cf23d1ec56a61d0419554fc1f1b2ee1652a..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/nuscenes_converter.cpython-310.pyc b/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/nuscenes_converter.cpython-310.pyc deleted file mode 100644 index 98ea63612e06ca523c4621cd2c89fc320bb8fe06..0000000000000000000000000000000000000000 Binary files a/docker-hub/FlashOCC/Flashocc/tools/data_converter/__pycache__/nuscenes_converter.cpython-310.pyc and /dev/null differ diff --git a/docker-hub/FlashOCC/Flashocc/tools/export_onnx.py b/docker-hub/FlashOCC/Flashocc/tools/export_onnx.py deleted file mode 100644 index 0eb4016a710999d82b739a51fc1f83f3973da778..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/export_onnx.py +++ /dev/null @@ -1,603 +0,0 @@ -import argparse -import sys -import os -sys.path.insert(0, os.getcwd()) - -import torch.onnx -from mmcv import Config -from mmdeploy.backend.tensorrt.utils import save, search_cuda_version - -try: - # If mmdet version > 2.23.0, compat_cfg would be imported and - # used from mmdet instead of mmdet3d. - from mmdet.utils import compat_cfg -except ImportError: - from mmdet3d.utils import compat_cfg - -import os -from typing import Dict, Optional, Sequence, Union - -import h5py -import mmcv -import numpy as np -import onnx -import pycuda.driver as cuda -import tensorrt as trt -import torch -import tqdm -from mmcv.runner import load_checkpoint -from mmdeploy.apis.core import no_mp -from mmdeploy.backend.tensorrt.calib_utils import HDF5Calibrator -from mmdeploy.backend.tensorrt.init_plugins import load_tensorrt_plugin -from mmdeploy.utils import load_config -from packaging import version -from torch.utils.data import DataLoader - -from mmdet3d.datasets import build_dataloader, build_dataset -from mmdet3d.models import build_model -from mmdet.datasets import replace_ImageToTensor -from tools.misc.fuse_conv_bn import fuse_module - - -class HDF5CalibratorBEVDet(HDF5Calibrator): - - def get_batch(self, names: Sequence[str], **kwargs) -> list: - """Get batch data.""" - if self.count < self.dataset_length: - if self.count % 100 == 0: - print('%d/%d' % (self.count, self.dataset_length)) - ret = [] - for name in names: - input_group = self.calib_data[name] - if name == 'img': - data_np = input_group[str(self.count)][...].astype( - np.float32) - else: - data_np = input_group[str(self.count)][...].astype( - np.int32) - - # tile the tensor so we can keep the same distribute - opt_shape = self.input_shapes[name]['opt_shape'] - data_shape = data_np.shape - - reps = [ - int(np.ceil(opt_s / data_s)) - for opt_s, data_s in zip(opt_shape, data_shape) - ] - - data_np = np.tile(data_np, reps) - - slice_list = tuple(slice(0, end) for end in opt_shape) - data_np = data_np[slice_list] - - data_np_cuda_ptr = cuda.mem_alloc(data_np.nbytes) - cuda.memcpy_htod(data_np_cuda_ptr, - np.ascontiguousarray(data_np)) - self.buffers[name] = data_np_cuda_ptr - - ret.append(self.buffers[name]) - self.count += 1 - return ret - else: - return None - - -def parse_args(): - parser = argparse.ArgumentParser(description='Deploy BEVDet with Tensorrt') - parser.add_argument('config', help='deploy config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('work_dir', help='work dir to save file') - parser.add_argument( - '--prefix', default='bevdet', help='prefix of the save file name') - parser.add_argument( - '--fp16', action='store_true', help='Whether to use tensorrt fp16') - parser.add_argument( - '--int8', action='store_true', help='Whether to use tensorrt int8') - parser.add_argument( - '--fuse-conv-bn', - action='store_true', - help='Whether to fuse conv and bn, this will slightly increase' - 'the inference speed') - parser.add_argument('--calib_num', type=int, help='num to calib') - args = parser.parse_args() - return args - - -def get_plugin_names(): - return [pc.name for pc in trt.get_plugin_registry().plugin_creator_list] - - -def create_calib_input_data_impl(calib_file: str, - dataloader: DataLoader, - model_partition: bool = False, - metas: list = [], - calib_num = None) -> None: - with h5py.File(calib_file, mode='w') as file: - calib_data_group = file.create_group('calib_data') - assert not model_partition - # create end2end group - input_data_group = calib_data_group.create_group('end2end') - input_group_img = input_data_group.create_group('img') - input_keys = [ - 'ranks_bev', 'ranks_depth', 'ranks_feat', 'interval_starts', - 'interval_lengths' - ] - input_groups = [] - for input_key in input_keys: - input_groups.append(input_data_group.create_group(input_key)) - metas = [ - metas[i].int().detach().cpu().numpy() for i in range(len(metas)) - ] - for data_id, input_data in enumerate(tqdm.tqdm(dataloader)): - # save end2end data - if (calib_num is not None) and (data_id > calib_num): - break - input_tensor = input_data['img_inputs'][0][0] - input_ndarray = input_tensor.squeeze(0).detach().cpu().numpy() - # print(input_ndarray.shape, input_ndarray.dtype) - input_group_img.create_dataset( - str(data_id), - shape=input_ndarray.shape, - compression='gzip', - compression_opts=4, - data=input_ndarray) - for kid, input_key in enumerate(input_keys): - input_groups[kid].create_dataset( - str(data_id), - shape=metas[kid].shape, - compression='gzip', - compression_opts=4, - data=metas[kid]) - file.flush() - - -def create_calib_input_data(calib_file: str, - deploy_cfg: Union[str, mmcv.Config], - model_cfg: Union[str, mmcv.Config], - model_checkpoint: Optional[str] = None, - dataset_cfg: Optional[Union[str, - mmcv.Config]] = None, - dataset_type: str = 'val', - device: str = 'cpu', - metas: list = [None], - calib_num = None) -> None: - """Create dataset for post-training quantization. - - Args: - calib_file (str): The output calibration data file. - deploy_cfg (str | mmcv.Config): Deployment config file or - Config object. - model_cfg (str | mmcv.Config): Model config file or Config object. - model_checkpoint (str): A checkpoint path of PyTorch model, - defaults to `None`. - dataset_cfg (Optional[Union[str, mmcv.Config]], optional): Model - config to provide calibration dataset. If none, use `model_cfg` - as the dataset config. Defaults to None. - dataset_type (str, optional): The dataset type. Defaults to 'val'. - device (str, optional): Device to create dataset. Defaults to 'cpu'. - """ - with no_mp(): - if dataset_cfg is None: - dataset_cfg = model_cfg - - # load cfg if necessary - deploy_cfg, model_cfg = load_config(deploy_cfg, model_cfg) - - if dataset_cfg is None: - dataset_cfg = model_cfg - - # load dataset_cfg if necessary - dataset_cfg = load_config(dataset_cfg)[0] - - from mmdeploy.apis.utils import build_task_processor - task_processor = build_task_processor(model_cfg, deploy_cfg, device) - - dataset = task_processor.build_dataset(dataset_cfg, dataset_type) - - dataloader = task_processor.build_dataloader( - dataset, 1, 1, dist=False, shuffle=False) - - create_calib_input_data_impl( - calib_file, dataloader, model_partition=False, metas=metas, calib_num=calib_num) - - -def from_onnx(onnx_model: Union[str, onnx.ModelProto], - output_file_prefix: str, - input_shapes: Dict[str, Sequence[int]], - max_workspace_size: int = 0, - fp16_mode: bool = False, - int8_mode: bool = False, - int8_param: Optional[dict] = None, - device_id: int = 0, - log_level: trt.Logger.Severity = trt.Logger.ERROR, - **kwargs) -> trt.ICudaEngine: - """Create a tensorrt engine from ONNX. - - Modified from mmdeploy.backend.tensorrt.utils.from_onnx - """ - - import os - old_cuda_device = os.environ.get('CUDA_DEVICE', None) - os.environ['CUDA_DEVICE'] = str(device_id) - import pycuda.autoinit # noqa:F401 - if old_cuda_device is not None: - os.environ['CUDA_DEVICE'] = old_cuda_device - else: - os.environ.pop('CUDA_DEVICE') - - load_tensorrt_plugin() - # create builder and network - logger = trt.Logger(log_level) - builder = trt.Builder(logger) - EXPLICIT_BATCH = 1 << (int)( - trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH) - network = builder.create_network(EXPLICIT_BATCH) - - # parse onnx - parser = trt.OnnxParser(network, logger) - - if isinstance(onnx_model, str): - onnx_model = onnx.load(onnx_model) - - if not parser.parse(onnx_model.SerializeToString()): - error_msgs = '' - for error in range(parser.num_errors): - error_msgs += f'{parser.get_error(error)}\n' - raise RuntimeError(f'Failed to parse onnx, {error_msgs}') - - # config builder - if version.parse(trt.__version__) < version.parse('8'): - builder.max_workspace_size = max_workspace_size - - config = builder.create_builder_config() - config.max_workspace_size = max_workspace_size - - cuda_version = search_cuda_version() - if cuda_version is not None: - version_major = int(cuda_version.split('.')[0]) - if version_major < 11: - # cu11 support cublasLt, so cudnn heuristic tactic should disable CUBLAS_LT # noqa E501 - tactic_source = config.get_tactic_sources() - ( - 1 << int(trt.TacticSource.CUBLAS_LT)) - config.set_tactic_sources(tactic_source) - - profile = builder.create_optimization_profile() - - for input_name, param in input_shapes.items(): - min_shape = param['min_shape'] - opt_shape = param['opt_shape'] - max_shape = param['max_shape'] - profile.set_shape(input_name, min_shape, opt_shape, max_shape) - config.add_optimization_profile(profile) - - if fp16_mode: - if version.parse(trt.__version__) < version.parse('8'): - builder.fp16_mode = fp16_mode - config.set_flag(trt.BuilderFlag.FP16) - - if int8_mode: - config.set_flag(trt.BuilderFlag.INT8) - assert int8_param is not None - config.int8_calibrator = HDF5CalibratorBEVDet( - int8_param['calib_file'], - input_shapes, - model_type=int8_param['model_type'], - device_id=device_id, - algorithm=int8_param.get( - 'algorithm', trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2)) - if version.parse(trt.__version__) < version.parse('8'): - builder.int8_mode = int8_mode - builder.int8_calibrator = config.int8_calibrator - - # create engine - engine = builder.build_engine(network, config) - - assert engine is not None, 'Failed to create TensorRT engine' - - save(engine, output_file_prefix + '.engine') - print('Save engine at ', output_file_prefix + '.engine') - return engine - - -def main(): - args = parse_args() - - max_workspace_size = 200*200*256*(2**8) - - if not os.path.exists(args.work_dir): - os.makedirs(args.work_dir) - - load_tensorrt_plugin() - # assert 'bev_pool_v2' in get_plugin_names(), \ - # 'bev_pool_v2 is not in the plugin list of tensorrt, ' \ - # 'please install mmdeploy from ' \ - # 'https://github.com/HuangJunJie2017/mmdeploy.git' - - # if args.int8: - # assert args.fp16 - model_prefix = args.prefix - if args.int8: - model_prefix = model_prefix + '_int8' - elif args.fp16: - model_prefix = model_prefix + '_fp16' - cfg = Config.fromfile(args.config) - cfg.model.pretrained = None - cfg.model.type = cfg.model.type + 'TRT' - - cfg = compat_cfg(cfg) - cfg.gpu_ids = [0] - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - plg_lib = importlib.import_module(_module_path) - - # build the dataloader - test_dataloader_default_args = dict( - samples_per_gpu=1, workers_per_gpu=0, dist=False, shuffle=False) - - if isinstance(cfg.data.test, dict): - cfg.data.test.test_mode = True - if cfg.data.test_dataloader.get('samples_per_gpu', 1) > 1: - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.test.pipeline = replace_ImageToTensor( - cfg.data.test.pipeline) - elif isinstance(cfg.data.test, list): - for ds_cfg in cfg.data.test: - ds_cfg.test_mode = True - if cfg.data.test_dataloader.get('samples_per_gpu', 1) > 1: - for ds_cfg in cfg.data.test: - ds_cfg.pipeline = replace_ImageToTensor(ds_cfg.pipeline) - - test_loader_cfg = { - **test_dataloader_default_args, - **cfg.data.get('test_dataloader', {}) - } - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader(dataset, **test_loader_cfg) - - # build the model and load checkpoint - cfg.model.train_cfg = None - model = build_model(cfg.model, test_cfg=cfg.get('test_cfg')) - # assert model.img_view_transformer.grid_size[0] == 128 - # assert model.img_view_transformer.grid_size[1] == 128 - # assert model.img_view_transformer.grid_size[2] == 1 - if os.path.exists(args.checkpoint): - load_checkpoint(model, args.checkpoint, map_location='cpu') - else: - print(args.checkpoint, " does not exists!") - if args.fuse_conv_bn: - model_prefix = model_prefix + '_fuse' - model = fuse_module(model) - model.cuda() - model.eval() - - for i, data in enumerate(data_loader): - inputs = [t.cuda() for t in data['img_inputs'][0]] - img = inputs[0].squeeze(0) - if img.shape[0] > 6: - img = img[:6] - if model.__class__.__name__ in ['FBOCCTRT', 'FBOCC2DTRT']: - metas = model.get_bev_pool_input(inputs, img_metas=data['img_metas']) - else: - if model.__class__.__name__ in ['BEVDetOCCTRT']: - metas = model.get_bev_pool_input(inputs) - elif model.__class__.__name__ in ['BEVDepthOCCTRT', 'BEVDepthPanoTRT']: - metas, mlp_input = model.get_bev_pool_input(inputs) - - if model.__class__.__name__ in ['FBOCCTRT', 'FBOCC2DTRT', 'BEVDetOCCTRT']: - onnx_input = (img.float().contiguous(), metas[1].int().contiguous(), - metas[2].int().contiguous(), metas[0].int().contiguous(), - metas[3].int().contiguous(), metas[4].int().contiguous()) - dynamic_axes={ - "ranks_depth" : {0: 'M'}, - "ranks_feat" : {0: 'M'}, - "ranks_bev" : {0: 'M'}, - "interval_starts" : {0: 'N'}, - "interval_lengths" : {0: 'N'}, - } - input_names=[ - 'img', 'ranks_depth', 'ranks_feat', 'ranks_bev', - 'interval_starts', 'interval_lengths' - ] - elif model.__class__.__name__ in ['BEVDepthOCCTRT', 'BEVDepthPanoTRT']: - onnx_input = (img.float().contiguous(), metas[1].int().contiguous(), - metas[2].int().contiguous(), metas[0].int().contiguous(), - metas[3].int().contiguous(), metas[4].int().contiguous(), mlp_input) - dynamic_axes={ - "ranks_depth" : {0: 'M'}, - "ranks_feat" : {0: 'M'}, - "ranks_bev" : {0: 'M'}, - "interval_starts" : {0: 'N'}, - "interval_lengths" : {0: 'N'}, - # "mlp_input" : {0: 'K'}, - } - input_names=[ - 'img', 'ranks_depth', 'ranks_feat', 'ranks_bev', - 'interval_starts', 'interval_lengths', 'mlp_input', - ] - - with torch.no_grad(): - if (model.wdet3d == True) and (model.wocc == False) : - output_names=[f'output_{j}' for j in range(6 * len(model.pts_bbox_head.task_heads))] - elif (model.wdet3d == True) and (model.wocc == True) : - output_names=[f'output_{j}' for j in range(1 + 6 * len(model.pts_bbox_head.task_heads))] - elif (model.wdet3d == False) and (model.wocc == True) : - output_names=[f'output_{j}' for j in range(1)] - else: - raise(" At least one of wdet3d and wocc is set as True!! ") - - # part1 - from functools import partial - model.forward = partial(model.forward_part1, - mlp_input = mlp_input - ) - onnx_path = args.work_dir + 'part1.onnx' - torch.onnx.export( - model, - (img.float().contiguous(),), - onnx_path, - export_params=True, - opset_version=11, - input_names=['img'], - output_names=['tran_feat','depth']) - # check onnx model - onnx_model = onnx.load(onnx_path) - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - model_file = 'model.onnx' - onnx.save(onnx.shape_inference.infer_shapes(onnx_model), onnx_path) - print('====== onnx is saved at : ', onnx_path) - tran_feat, depth = model.forward(img) - # # from onnxsim import simplify - # # model_simp, check = simplify(onnx_model) - # # assert check, "Simplified ONNX model could not be validated" - # # onnx.save(model_simp, onnx_path) - # # print('====== onnx is saved at : ', onnx_path) - - # part2 - from functools import partial - model.forward = partial(model.forward_part2, - ranks_depth = onnx_input[1], - ranks_feat = onnx_input[2], - ranks_bev = onnx_input[3], - interval_starts = onnx_input[4], - interval_lengths = onnx_input[5] - ) - onnx_path = args.work_dir + 'part2.onnx' - torch.onnx.export( - model, - (tran_feat.float().contiguous(), depth.float().contiguous()), - onnx_path, - export_params=True, - opset_version=11, - input_names=['tran_feat','depth'], - output_names=['bev_feat']) - # check onnx model - onnx_model = onnx.load(onnx_path) - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - model_file = 'model.onnx' - onnx.save(onnx.shape_inference.infer_shapes(onnx_model), onnx_path) - print('====== onnx is saved at : ', onnx_path) - bev_pool_feat = model.forward(tran_feat, depth) - # # from onnxsim import simplify - # # model_simp, check = simplify(onnx_model) - # # assert check, "Simplified ONNX model could not be validated" - # # onnx.save(model_simp, onnx_path) - # # print('====== onnx is saved at : ', onnx_path) - - # part3 - model.forward = model.forward_part3 - onnx_path = args.work_dir + 'part3.onnx' - torch.onnx.export( - model, - (bev_pool_feat,), - onnx_path, - export_params=True, - opset_version=11, - input_names=['bev_feat'], - output_names=['occ_pred', 'inst_center_reg', 'inst_center_height', 'inst_center_heatmap']) - # check onnx model - onnx_model = onnx.load(onnx_path) - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - model_file = 'model.onnx' - onnx.save(onnx.shape_inference.infer_shapes(onnx_model), onnx_path) - print('====== onnx is saved at : ', onnx_path) - # # from onnxsim import simplify - # # model_simp, check = simplify(onnx_model) - # # assert check, "Simplified ONNX model could not be validated" - # # onnx.save(model_simp, onnx_path) - # # print('====== onnx is saved at : ', onnx_path) - - from functools import partial - model.forward = partial(model.forward_ori, - ranks_depth = onnx_input[1], - ranks_feat = onnx_input[2], - ranks_bev = onnx_input[3], - interval_starts = onnx_input[4], - interval_lengths = onnx_input[5], - mlp_input = mlp_input - ) - torch.onnx.export( - model, - (onnx_input[0],), - args.work_dir + model_prefix + '.onnx', - opset_version=11, - dynamic_axes=dynamic_axes, - input_names=['img'], - output_names=['occ_pred', 'inst_center_reg', 'inst_center_height', 'inst_center_heatmap'] - ) - print('output_names:', output_names) - print('====== onnx is saved at : ', args.work_dir + model_prefix + '.onnx') - # check onnx model - onnx_model = onnx.load(args.work_dir + model_prefix + '.onnx') - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - outs = model.forward(onnx_input[0]) - - model.forward = model.forward_with_argmax - out = model(*onnx_input) - output_names = [f'cls_occ_label'] - torch.onnx.export( - model, - onnx_input, - args.work_dir + model_prefix + '_with_argmax.onnx', - opset_version=11, - dynamic_axes=dynamic_axes, - input_names=input_names, - output_names=output_names) - print('output_names:', output_names) - print('====== onnx is saved at : ', args.work_dir + model_prefix + '_with_argmax.onnx') - # check onnx model - onnx_model = onnx.load(args.work_dir + model_prefix + '_with_argmax.onnx') - try: - onnx.checker.check_model(onnx_model) - except Exception: - print('ONNX Model Incorrect') - else: - print('ONNX Model Correct') - - break - - return - - -if __name__ == '__main__': - - main() diff --git a/docker-hub/FlashOCC/Flashocc/tools/vis_occ.py b/docker-hub/FlashOCC/Flashocc/tools/vis_occ.py deleted file mode 100644 index 1d9e27f2bbe015867426df596d10d36798be20e5..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/Flashocc/tools/vis_occ.py +++ /dev/null @@ -1,316 +0,0 @@ -import os -import cv2 -import logging -import argparse -import importlib -import torch -import numpy as np -from tqdm import tqdm -from mmcv import Config, DictAction -from mmdet.apis import set_random_seed -from mmdet3d.datasets import build_dataset, build_dataloader -from mmcv.parallel import MMDataParallel -from mmcv.runner import load_checkpoint -from mmdet3d.models import build_model -import mmdet -from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, - wrap_fp16_model) - -import sys -sys.path.insert(0, os.getcwd()) - -if mmdet.__version__ > '2.23.0': - # If mmdet version > 2.23.0, setup_multi_processes would be imported and - # used from mmdet instead of mmdet3d. - from mmdet.utils import setup_multi_processes -else: - from mmdet3d.utils import setup_multi_processes - -try: - # If mmdet version > 2.23.0, compat_cfg would be imported and - # used from mmdet instead of mmdet3d. - from mmdet.utils import compat_cfg -except ImportError: - from mmdet3d.utils import compat_cfg - -occ_class_names = [ - 'others', 'barrier', 'bicycle', 'bus', 'car', 'construction_vehicle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'trailer', 'truck', - 'driveable_surface', 'other_flat', 'sidewalk', - 'terrain', 'manmade', 'vegetation', 'free' -] - -color_map = np.array([ - [0, 0, 0, 255], # others - [255, 120, 50, 255], # barrier orangey - [255, 192, 203, 255], # bicycle pink - [255, 255, 0, 255], # bus yellow - [0, 150, 245, 255], # car blue - [0, 255, 255, 255], # construction_vehicle cyan - [200, 180, 0, 255], # motorcycle dark orange - [255, 0, 0, 255], # pedestrian red - [255, 240, 150, 255], # traffic_cone light yellow - [135, 60, 0, 255], # trailer brown - [160, 32, 240, 255], # truck purple - [255, 0, 255, 255], # driveable_surface dark pink - [175, 0, 75, 255], # other_flat dark red - [75, 0, 75, 255], # sidewalk dard purple - [150, 240, 80, 255], # terrain light green - [230, 230, 250, 255], # manmade white - [0, 175, 0, 255], # vegetation green - [255, 255, 255, 255], # free white -], dtype=np.uint8) - -# # from matplotlib import colors -# # hex_code_list = [ -# # '#000000', '#D3D3D3', '#BC8F8F', '#F08080', '#A52A2A', '#FF0000', '#FFA07A', '#A0522D', '#FFE4C4', '#FFE4B5', \ -# # '#DAA520', '#FFD700', '#F0E68C', '#BDB76B', '#808000', '#FFFF00', '#9ACD32', '#7FFF00', '#8FBC8F', '#90EE90', \ -# # '#32CD32', '#008000', '#00FF00', '#00FA9A', '#7FFFD4', '#48D1CC', '#2F4F4F', '#ADD8E6', '#87CEFA', '#DC143C', \ -# # '#696969', '#9370DB', '#8A2BE2', '#9400D3', '#DDA0DD', '#FF00FF', '#C71585', '#DB7093', '#FFB6C1', '#bf9b0c', \ -# # '#01889f', '#bb3f3f', '#1805db', '#48c072', '#fffd37', '#c44240', '#6140ef', '#ceaefa', '#04f489', '#c6f808', \ -# # '#507b9c', '#cffdbc', '#ac7e04', '#01386a', '#ffb7ce', '#ffd1df', '#D2691E', '#FFDAB9', '#a55af4', '#95d0fc', \ -# # ] -# # hex_code_list = np.array(hex_code_list).reshape(6,10).transpose(1,0).reshape(-1) -# # pano_color_map = np.array([[int(value * 255) for value in colors.hex2color(hex_code)] for hex_code in hex_code_list], dtype=np.uint8) - -import matplotlib.pyplot as plt -from scipy.ndimage import rotate -def draw_fig(tensor, name='tensor_image_colored_no_white.png'): - tensor = tensor.squeeze(0) - tensor = rotate(tensor, -90, reshape=False) - tensor = np.flip(tensor, axis=1) - fig, ax = plt.subplots(figsize=(4, 4)) - ax.imshow(tensor, cmap='viridis') - plt.axis('off') - plt.savefig(name, bbox_inches='tight', pad_inches=0) - plt.clf() - -def generate_rgb_color(number): - red = (number % 256) - green = ((number // 256) % 256) - blue = ((number // 65536) % 256) - return [red, green, blue] -pano_color_map = np.array([generate_rgb_color(number) for number in np.random.randint(0, 65536*256, 256)]) - -inst_class_ids=[2, 3, 4, 5, 6, 7, 9, 10] - -def occ2img(semantics=None, is_pano=False, panoptics=None): - H, W, D = semantics.shape - - free_id = len(occ_class_names) - 1 - semantics_2d = np.ones([H, W], dtype=np.int32) * free_id - for i in range(D): - semantics_i = semantics[..., i] - non_free_mask = (semantics_i != free_id) - semantics_2d[non_free_mask] = semantics_i[non_free_mask] - - viz = color_map[semantics_2d] - viz = viz[..., :3] - - inst_mask = np.zeros_like(semantics_2d).astype(np.bool) - for ind in inst_class_ids: - inst_mask[semantics_2d==ind] = True - - if is_pano: - panoptics_2d = np.ones([H, W], dtype=np.int32) * 0 - for i in range(D): - panoptics_i = panoptics[..., i] - semantics_i = semantics[..., i] - non_free_mask = (semantics_i != free_id) - panoptics_2d[non_free_mask] = panoptics_i[non_free_mask] - - - # # panoptics_2d = panoptics_2d%60 - - - viz_pano = pano_color_map[panoptics_2d] - viz[inst_mask,:] = viz_pano[inst_mask,:] - - viz = cv2.resize(viz, dsize=(800, 800)) - return viz - -def main(): - parser = argparse.ArgumentParser(description='Validate a detector') - parser.add_argument('--config', required=True) - parser.add_argument('--weights', required=True) - parser.add_argument('--viz-dir', required=True) - parser.add_argument('--override', nargs='+', action=DictAction) - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--draw-sem-gt', action='store_true') - parser.add_argument('--draw-pano-gt', action='store_true') - parser.add_argument('--surround-view-img', action='store_true') - parser.add_argument('--surround-pano-gt', action='store_true') - args = parser.parse_args() - - # parse configs - cfgs = Config.fromfile(args.config) - if args.override is not None: - cfgs.merge_from_dict(args.override) - - cfgs = compat_cfg(cfgs) - - # set multi-process settings - setup_multi_processes(cfgs) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfgs, 'plugin'): - if cfgs.plugin: - import importlib - if hasattr(cfgs, 'plugin_dir'): - plugin_dir = cfgs.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - plg_lib = importlib.import_module(_module_path) - - # use val-mini for visualization - #cfgs.data.val.ann_file = cfgs.data.val.ann_file.replace('val', 'val_mini') - - # MMCV, please shut up - from mmcv.utils.logging import logger_initialized - logger_initialized['root'] = logging.Logger(__name__, logging.WARNING) - logger_initialized['mmcv'] = logging.Logger(__name__, logging.WARNING) - - # you need one GPU - assert torch.cuda.is_available() - # assert torch.cuda.device_count() == 1 - - # logging - logging.info('Using GPU: %s' % torch.cuda.get_device_name(0)) - - # random seed - logging.info('Setting random seed: 0') - set_random_seed(0, deterministic=True) - - logging.info('Loading validation set from %s' % cfgs.data.val.data_root) - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfgs.dist_params) - - test_dataloader_default_args = dict( - samples_per_gpu=1, workers_per_gpu=2, dist=distributed, shuffle=False) - test_loader_cfg = { - **test_dataloader_default_args, - **cfgs.data.get('test_dataloader', {}) - } - dataset = build_dataset(cfgs.data.test) - test_loader_cfg['workers_per_gpu'] = 2 - val_loader = build_dataloader(dataset, **test_loader_cfg) - # val_dataset = build_dataset(cfgs.data.test) - # val_loader = build_dataloader( - # val_dataset, - # samples_per_gpu=1, - # workers_per_gpu=1, - # num_gpus=1, - # dist=False, - # shuffle=False, - # seed=0, - # ) - - logging.info('Creating model: %s' % cfgs.model.type) - model = build_model(cfgs.model) - model.cuda() - model = MMDataParallel(model, [0]) - model.eval() - - logging.info('Loading checkpoint from %s' % args.weights) - load_checkpoint( - model, args.weights, map_location='cuda', strict=True, - logger=logging.Logger(__name__, logging.ERROR) - ) - - if not os.path.exists(args.viz_dir): - os.makedirs(args.viz_dir) - - for i, data in tqdm(enumerate(val_loader)): - - with torch.no_grad(): - occ_pred = model(return_loss=False, rescale=True, **data)[0] - - if False: - occ_bev_feature = occ_pred['occ_bev_feature'] - outs = occ_pred['outs'] - - tensor = occ_bev_feature.max(dim=1)[0].cpu() - draw_fig(tensor, name=os.path.join(args.viz_dir, '%04d-occ_bev_feature.jpg' % i)) - print(os.path.join(args.viz_dir, '%04d-occ_bev_feature.jpg' % i)) - - tensor = outs[0][0]['heatmap'].sigmoid().sum(dim=1)[0].cpu() - draw_fig(tensor, name=os.path.join(args.viz_dir, '%04d-heatmap.jpg' % i)) - print(os.path.join(args.viz_dir, '%04d-heatmap.jpg' % i)) - - tensor = outs[0][0]['reg'][0,0].cpu() - tensor = outs[0][0]['reg'][0,1].cpu() - tensor = ((outs[0][0]['reg'][0,0]**2+outs[0][0]['reg'][0,1]**2)**0.5).unsqueeze(dim=0).cpu() - draw_fig(tensor, name=os.path.join(args.viz_dir, '%04d-reg.jpg' % i)) - print(os.path.join(args.viz_dir, '%04d-reg.jpg' % i)) - - tensor = outs[0][0]['height'][0,0].cpu() - draw_fig(tensor, name=os.path.join(args.viz_dir, '%04d-height.jpg' % i)) - print(os.path.join(args.viz_dir, '%04d-height.jpg' % i)) - - - sem_pred = occ_pred['pred_occ'] - cv2.imwrite(os.path.join(args.viz_dir, '%04d-sem.jpg' % i), occ2img(semantics=sem_pred.cpu())[..., ::-1]) - print(os.path.join(args.viz_dir, '%04d-sem.jpg' % i)) - - inst_pred = occ_pred['pano_inst'] - cv2.imwrite(os.path.join(args.viz_dir, '%04d-inst.jpg' % i), occ2img(semantics=sem_pred.cpu(), is_pano=True, panoptics=inst_pred.cpu())[..., ::-1]) - print(os.path.join(args.viz_dir, '%04d-inst.jpg' % i)) - - if args.surround_view_img: - img = data['img_inputs'][0][0][0][::9].cpu().numpy() - mean = np.array([123.675, 116.28, 103.53], dtype=np.float32).reshape(1,3,1,1) - std = np.array([58.395, 57.12, 57.375], dtype=np.float32).reshape(1,3,1,1) - img = img*std + mean - img = img.astype(np.uint8).transpose(0,2,3,1) - up = np.concatenate([img[0,...], img[1,...], img[2,...]], 1) - down = np.concatenate([img[3,...], img[4,...], img[5,...]], 1) - out = np.concatenate([up, down], 0) - cv2.imwrite(os.path.join(args.viz_dir, '%04d-rgb.jpg' % i), out) - print(os.path.join(args.viz_dir, '%04d-rgb.jpg' % i)) - - if args.draw_sem_gt or args.draw_pano_gt: - occ_gt = np.load(os.path.join(val_loader.dataset.data_infos[i]['occ_path'].\ - replace('data/nuscenes/gts/', 'data/nuscenes/occ3d_panoptic/'), 'labels.npz')) - pano_gt = occ_gt['instances'] - sem_gt = occ_gt['semantics'] - - if args.draw_sem_gt: - # sem_gt = np.array(data['voxel_semantics'][0])[0] - cv2.imwrite(os.path.join(args.viz_dir, '%04d-sem-gt.jpg' % i), occ2img(semantics=sem_gt.cpu())[..., ::-1]) - - if args.draw_pano_gt: - cv2.imwrite(os.path.join(args.viz_dir, '%04d-pano-gt.jpg' % i), occ2img(semantics=sem_gt, is_pano=True, panoptics=pano_gt)[..., ::-1]) - print(os.path.join(args.viz_dir, '%04d-pano-gt.jpg' % i)) - -if __name__ == '__main__': - main() - -''' -exp_name=flashoccv2-r50-depth-tiny-pano -python tools/vis_occ.py --config projects/configs/flashoccv2/${exp_name}.py --weights work_dirs/${exp_name}/epoch_24_ema.pth --viz-dir vis/${exp_name} --draw-gt - -exp_name=flashoccv2-r50-depth4d-longterm8f-pano -python tools/vis_occ.py --config projects/configs/flashoccv2/${exp_name}.py --weights work_dirs/${exp_name}/epoch_24_ema.pth --viz-dir vis/${exp_name} --draw-pano-gt #--draw-gt -''' \ No newline at end of file diff --git a/docker-hub/FlashOCC/readme.md b/docker-hub/FlashOCC/readme.md deleted file mode 100644 index 07e2b9774d7044c762494f9a1b2a014315057c44..0000000000000000000000000000000000000000 --- a/docker-hub/FlashOCC/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# Flashocc - -## 环境构建 - -``` - docker run -dit --network=host --name=flashocc --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal:/opt/hyhal:ro -v /public/opendas/DL_DATA/zijia:/data:ro harbor.sourcefind.cn:5443/dcu/admin/base/custom:pytorch2.5.1-driver-flashocc -``` - -数据集已完成处理在乌镇集群/public/opendas/DL_DATA/zijia路径内 - -## 代码执行 - -``` -## 代码已经在容器/workspace下了 -cd /workspace/Flashocc -bash start_flashocc.sh -``` - - - diff --git a/docker-hub/MapTRv2/MapTR/README.md b/docker-hub/MapTRv2/MapTR/README.md deleted file mode 100644 index 9dc6817753280e8e99d33309e86ca8b62ecaf541..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/README.md +++ /dev/null @@ -1,160 +0,0 @@ -
-

MapTR

-

An End-to-End Framework for Online Vectorized HD Map Construction

- -[Bencheng Liao](https://github.com/LegendBC)1,2,3 \*, [Shaoyu Chen](https://scholar.google.com/citations?user=PIeNN2gAAAAJ&hl=en&oi=sra)1,3 \*, Yunchi Zhang1,3 \*, [Bo Jiang](https://github.com/rb93dett)1,3 \*,[Tianheng Cheng](https://scholar.google.com/citations?user=PH8rJHYAAAAJ&hl=zh-CN)1,3, [Qian Zhang](https://scholar.google.com/citations?user=pCY-bikAAAAJ&hl=zh-CN)3, [Wenyu Liu](http://eic.hust.edu.cn/professor/liuwenyu/)1, [Chang Huang](https://scholar.google.com/citations?user=IyyEKyIAAAAJ&hl=zh-CN)3, [Xinggang Wang](https://xinggangw.info/)1 :email: - -1 School of EIC, HUST, 2 Institute of Artificial Intelligence, HUST, 3 Horizon Robotics - -(\*) equal contribution, (:email:) corresponding author. - -ArXiv Preprint ([arXiv 2208.14437](https://arxiv.org/abs/2208.14437)) - -[openreview ICLR'23](https://openreview.net/forum?id=k7p_YAO7yE), accepted as **ICLR Spotlight** - -extended ArXiv Preprint MapTRv2 ([arXiv 2308.05736](https://arxiv.org/abs/2308.05736)) - -
- -# -### News -* **`Aug. 31th, 2023`:** initial MapTRv2 is released at ***maptrv2*** branch. Please run `git checkout maptrv2` to use it. -* **`Aug. 14th, 2023`:** As required by many researchers, the code of MapTR-based map annotation framework (VMA) will be released at https://github.com/hustvl/VMA recently. -* **`Aug. 10th, 2023`:** We release [MapTRv2](https://arxiv.org/abs/2308.05736) on Arxiv. MapTRv2 demonstrates much stronger performance and much faster convergence. To better meet the requirement of the downstream planner (like [PDM](https://github.com/autonomousvision/nuplan_garage)), we introduce an extra semantic——centerline (using path-wise modeling proposed by [LaneGAP](https://github.com/hustvl/LaneGAP)). Code & model will be released in late August. Please stay tuned! -* **`May. 12th, 2023`:** MapTR now support various bevencoder, such as [BEVFormer encoder](projects/configs/maptr/maptr_tiny_r50_24e_bevformer.py) and [BEVFusion bevpool](projects\configs\maptr\maptr_tiny_r50_24e_bevpool.py). Check it out! -* **`Apr. 20th, 2023`:** Extending MapTR to a general map annotation framework ([paper](https://arxiv.org/pdf/2304.09807.pdf), [code](https://github.com/hustvl/VMA)), with high flexibility in terms of spatial scale and element type. -* **`Mar. 22nd, 2023`:** By leveraging MapTR, VAD ([paper](https://arxiv.org/abs/2303.12077), [code](https://github.com/hustvl/VAD)) models the driving scene as fully vectorized representation, achieving SoTA end-to-end planning performance! -* **`Jan. 21st, 2023`:** MapTR is accepted to ICLR 2023 as **Spotlight Presentation**! -* **`Nov. 11st, 2022`:** We release an initial version of MapTR. -* **`Aug. 31st, 2022`:** We released our paper on Arxiv. Code/Models are coming soon. Please stay tuned! ☕️ - - -## Introduction -

MapTR/MapTRv2 is a simple, fast and strong online vectorized HD map construction framework.

- -![framework](assets/teaser.png "framework") - -High-definition (HD) map provides abundant and precise static environmental information of the driving scene, serving as a fundamental and indispensable component for planning in autonomous driving system. In this paper, we present **Map** **TR**ansformer, an end-to-end framework for online vectorized HD map construction. We propose a unified permutation-equivalent modeling approach, i.e., modeling map element as a point set with a group of equivalent permutations, which accurately describes the shape of map element and stabilizes the learning process. We design a hierarchical query embedding scheme to flexibly encode structured map information and perform hierarchical bipartite matching for map element learning. To speed up convergence, we further introduce auxiliary one-to-many matching and dense supervision. The proposed method well copes with various map elements with arbitrary shapes. It runs at real-time inference speed and achieves state-of-the-art performance on both nuScenes and Argoverse2 datasets. Abundant qualitative results show stable and robust map construction quality in complex and various driving scenes. - -## Models -> Results from the [MapTRv2 paper](https://arxiv.org/abs/2308.05736) - - -![comparison]() - -| Method | Backbone | Lr Schd | mAP| FPS| -| :---: | :---: | :---: | :---: | :---: -| MapTR | R18 | 110ep | 45.9 | 35.0| -| MapTR | R50 | 24ep | 50.3 | 15.1| -| MapTR | R50 | 110ep | 58.7|15.1| -| MapTRv2 | R18 | 110ep | 52.3 | 33.7| -| MapTRv2 | R50 | 24ep | 61.5 | 14.1| -| MapTRv2 | R50 | 110ep | 68.7 | 14.1| -| MapTRv2 | V2-99 | 110ep | 73.4 | 9.9| - -**Notes**: - -- FPS is measured on NVIDIA RTX3090 GPU with batch size of 1 (containing 6 view images). -- All the experiments are performed on 8 NVIDIA GeForce RTX 3090 GPUs. - -> Results from this repo. - -### MapTR - -

nuScenes dataset

- -| Method | Backbone | BEVEncoder |Lr Schd | mAP| FPS|memory | Config | Download | -| :---: | :---: | :---: | :---: | :---: | :---:|:---:| :---: | :---: | -| MapTR-nano | R18 |GKT | 110ep |46.3 |35.0| 11907M (bs 24) |[config](projects/configs/maptr/maptr_nano_r18_110e.py) |[model](https://drive.google.com/file/d/1-wVO1pZhFif2igJoz-s451swQvPSto2m/view?usp=sharing) / [log](https://drive.google.com/file/d/1Hd25seDQKn8Vv6AQxPfSoiu-tY2i4Haa/view?usp=sharing) | -| MapTR-tiny | R50 | GKT |24ep | 50.0 |15.1| 10287M (bs 4) | [config](projects/configs/maptr/maptr_tiny_r50_24e.py)|[model](https://drive.google.com/file/d/1n1FUFnRqdskvmpLdnsuX_VK6pET19h95/view?usp=share_link) / [log](https://drive.google.com/file/d/1nvPkk0EMHV8Q82E9usEKKYx7P38bCx1U/view?usp=share_link) | -| MapTR-tiny | R50 |GKT | 110ep | 59.3 |15.1| 10287M (bs 4)|[config](projects/configs/maptr/maptr_tiny_r50_110e.py) |[model](https://drive.google.com/file/d/1SCF93LEEmXU0hMwPiUz9p2CWbL1FpB1h/view?usp=share_link) / [log](https://drive.google.com/file/d/1TQ4j_0Sf2ipzeYsEZZAHYzX4dCUaBqyp/view?usp=share_link) | -| MapTR-tiny | Camera & LiDAR | GKT |24ep | 62.7 | 6.0 | 11858M (bs 4)|[config](projects/configs/maptr/maptr_tiny_fusion_24e.py) |[model](https://drive.google.com/file/d/1CFlJrl3ZDj3gIOysf5Cli9bX5LEYSYO4/view?usp=share_link) / [log](https://drive.google.com/file/d/1rb3S4oluxdZjNm2aJ5lBH23jrkYIaJbC/view?usp=share_link) | -| MapTR-tiny | R50 | bevpool |24ep | 50.1 | 14.7 | 9817M (bs 4)|[config](projects/configs/maptr/maptr_tiny_r50_24e_bevpool.py) |[model](https://drive.google.com/file/d/16PK9XohV55_3qPVDtpXIl4_Iumw9EnfA/view?usp=sharing) / [log](https://drive.google.com/file/d/14nioV3_VV9KehmxK7XcAHxM8X6JH5WIr/view?usp=sharing) | -| MapTR-tiny | R50 | bevformer |24ep | 48.7 | 15.0 | 10219M (bs 4)|[config](projects/configs/maptr/maptr_tiny_r50_24e_bevformer.py) |[model](https://drive.google.com/file/d/1y-UBwGBSb2xiV40AuQEBhB-xJyV7VusX/view?usp=sharing) / [log](https://drive.google.com/file/d/1r35bRhTGVtyZTP8drXBTOIhLYGCzjEaF/view?usp=sharing) | - -### MapTRv2 -Please `git checkout maptrv2` and follow the install instruction to use following checkpoint - -

nuScenes dataset

- -| Method | Backbone | BEVEncoder |Lr Schd | mAP| FPS|memory | Config | Download | -| :---: | :---: | :---: | :---: | :---: | :---:|:---:| :---: | :---: | -| MapTRv2| R50 |bevpool | 24ep | WIP |14.1| WIP (bs 24) |[config](https://github.com/hustvl/MapTR/blob/maptrv2/projects/configs/maptrv2/maptrv2_nusc_r50_24ep.py) |model / log | -| MapTRv2*| R50 |bevpool | 24ep | WIP |WIP| WIP (bs 24) |[config](https://github.com/hustvl/MapTR/blob/maptrv2/projects/configs/maptrv2/maptrv2_nusc_r50_24ep_w_centerline.py) |model / log | - - -

Argoverse2 dataset

- -**Notes**: - -- \* means that we introduce an extra semantic——centerline (using path-wise modeling proposed by [LaneGAP](https://github.com/hustvl/LaneGAP)). - -## Qualitative results on nuScenes val split and Argoverse2 val split - -

MapTR/MapTRv2 maintains stable and robust map construction quality in various driving scenes.

- -![visualization](assets/MapTRv2_av2_visualizations.png "visualization") - - - -### *MapTRv2 on whole nuScenes val split* -[**Youtube**](https://www.youtube.com/watch?v=s7McToPNlJ4) - -### *MapTRv2 on whole Argoverse2 val split* -[**Youtube**](https://www.youtube.com/watch?v=nC8W_2BZuys) - - - -### *End-to-end Planning based on MapTR* -https://user-images.githubusercontent.com/26790424/229679664-0e9ba5e8-bf2c-45e0-abbc-36d840ee5cc9.mp4 - - - -## Getting Started -- [Installation](docs/install.md) -- [Prepare Dataset](docs/prepare_dataset.md) (Notes: annotation generation of MapTRv2 is different from MapTR ) -- [Train and Eval](docs/train_eval.md) -- [Visualization](docs/visualization.md) - - -## Catalog - -- [ ] centerline detection & topology support -- [x] multi-modal checkpoints -- [x] multi-modal code -- [ ] lidar modality code -- [x] argoverse2 dataset -- [x] Nuscenes dataset -- [x] MapTR checkpoints -- [x] MapTR code -- [x] Initialization - -## Acknowledgements - -MapTR is based on [mmdetection3d](https://github.com/open-mmlab/mmdetection3d). It is also greatly inspired by the following outstanding contributions to the open-source community: [BEVFusion](https://github.com/mit-han-lab/bevfusion), [BEVFormer](https://github.com/fundamentalvision/BEVFormer), [HDMapNet](https://github.com/Tsinghua-MARS-Lab/HDMapNet), [GKT](https://github.com/hustvl/GKT), [VectorMapNet](https://github.com/Mrmoore98/VectorMapNet_code). - -## Citation -If you find MapTR is useful in your research or applications, please consider giving us a star 🌟 and citing it by the following BibTeX entry. -```bibtex -@inproceedings{MapTR, - title={MapTR: Structured Modeling and Learning for Online Vectorized HD Map Construction}, - author={Liao, Bencheng and Chen, Shaoyu and Wang, Xinggang and Cheng, Tianheng, and Zhang, Qian and Liu, Wenyu and Huang, Chang}, - booktitle={International Conference on Learning Representations}, - year={2023} -} -``` -```bibtex -@inproceedings{MapTRv2, - title={MapTRv2: An End-to-End Framework for Online Vectorized HD Map Construction}, - author={Liao, Bencheng and Chen, Shaoyu and Zhang, Yunchi and Jiang, Bo and Zhang, Qian and Liu, Wenyu and Huang, Chang and Wang, Xinggang}, - booktitle={arXiv preprint arXiv: 2308.05736}, - year={2023} -} -``` diff --git a/docker-hub/MapTRv2/MapTR/docs/install.md b/docker-hub/MapTRv2/MapTR/docs/install.md deleted file mode 100644 index adc05e9cf30ea8f4a470ef6261e13993dd4bb72c..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/docs/install.md +++ /dev/null @@ -1,72 +0,0 @@ -# Step-by-step installation instructions - -Following https://mmdetection3d.readthedocs.io/en/latest/getting_started.html#installation - - - -**a. Create a conda virtual environment and activate it.** -```shell -conda create -n maptr python=3.8 -y -conda activate maptr -``` - -**b. Install PyTorch and torchvision following the [official instructions](https://pytorch.org/).** -```shell -pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html -# Recommended torch>=1.9 -``` - -**c. Install gcc>=5 in conda env (optional).** -```shell -conda install -c omgarcia gcc-5 # gcc-6.2 -``` - -**c. Install mmcv-full.** -```shell -pip install mmcv-full==1.4.0 -# pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html -``` - -**d. Install mmdet and mmseg.** -```shell -pip install mmdet==2.14.0 -pip install mmsegmentation==0.14.1 -``` - -**e. Install timm.** -```shell -pip install timm -``` - - -**f. Clone MapTR.** -``` -git clone https://github.com/hustvl/MapTR.git -``` - -**g. Install mmdet3d and GKT** -```shell -cd /path/to/MapTR/mmdetection3d -python setup.py develop - -cd /path/to/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn -python setup.py build install - -``` - -**h. Install other requirements.** -```shell -cd /path/to/MapTR -pip install -r requirement.txt -``` - -**i. Prepare pretrained models.** -```shell -cd /path/to/MapTR -mkdir ckpts - -cd ckpts -wget https://download.pytorch.org/models/resnet50-19c8e357.pth -wget https://download.pytorch.org/models/resnet18-f37072fd.pth -``` - diff --git a/docker-hub/MapTRv2/MapTR/docs/prepare_dataset.md b/docker-hub/MapTRv2/MapTR/docs/prepare_dataset.md deleted file mode 100644 index 1228ead7c1d83d8e1c8b420e43db2be6e48d29de..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/docs/prepare_dataset.md +++ /dev/null @@ -1,73 +0,0 @@ - - -## NuScenes -Download nuScenes V1.0 full dataset data and CAN bus expansion data [HERE](https://www.nuscenes.org/download). Prepare nuscenes data by running - - -**Download CAN bus expansion** -``` -# download 'can_bus.zip' -unzip can_bus.zip -# move can_bus to data dir -``` - -**Prepare nuScenes data** - -*We genetate custom annotation files which are different from mmdet3d's* -``` -python tools/maptrv2/custom_nusc_map_converter.py --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes --version v1.0 --canbus ./data -``` - -Using the above code will generate `nuscenes_map_infos_temporal_{train,val}.pkl`, which contain local vectorized map annotations. - -**Folder structure** -``` -MapTR -├── mmdetection3d/ -├── projects/ -├── tools/ -├── configs/ -├── ckpts/ -│ ├── r101_dcn_fcos3d_pretrain.pth -├── data/ -│ ├── can_bus/ -│ ├── nuscenes/ -│ │ ├── maps/ -│ │ ├── samples/ -│ │ ├── sweeps/ -│ │ ├── v1.0-test/ -| | ├── v1.0-trainval/ -| | ├── nuscenes_infos_temporal_train.pkl -| | ├── nuscenes_infos_temporal_val.pkl -``` - -## Argoverse2 -Download the Argoverse2 Sensor Dataset [here](https://www.argoverse.org/av2.html#download-link). - -**Folder structure** -``` -MapTR -├── mmdetection3d/ -├── projects/ -├── tools/ -├── configs/ -├── ckpts/ -│ ├── r101_dcn_fcos3d_pretrain.pth -├── data/ -│ ├── can_bus/ -│ ├── nuscenes/ -│ ├── argoverse2/ -│ │ ├── sensor/ -| | | |—— train/ -| | | |—— val/ -| | | |—— test/ -``` - -**Prepare Argoverse2 data** - -*We genetate custom annotation files which are different from mmdet3d's* -``` -python tools/maptrv2/custom_av2_map_converter.py --data-root ./data/argoverse2/sensor/ -``` - -Using the above code will generate `av2_map_infos_{train,val}.pkl`, which contain local vectorized map annotations. diff --git a/docker-hub/MapTRv2/MapTR/docs/train_eval.md b/docker-hub/MapTRv2/MapTR/docs/train_eval.md deleted file mode 100644 index cce200ff9175614dd96ccc5b390e521e81db3b1a..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/docs/train_eval.md +++ /dev/null @@ -1,22 +0,0 @@ -# Prerequisites - -**Please ensure you have prepared the environment and the nuScenes dataset.** - -# Train and Test - -Train MapTR with 8 GPUs -``` -./tools/dist_train.sh ./projects/configs/maptr/maptr_tiny_r50_24e.py 8 -``` - -Eval MapTR with 8 GPUs -``` -./tools/dist_test_map.sh ./projects/configs/maptr/maptr_tiny_r50_24e.py ./path/to/ckpts.pth 8 -``` - - - - -# Visualization - -we provide tools for visualization and benchmark under `path/to/MapTR/tools/maptr` \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/docs/visualization.md b/docker-hub/MapTRv2/MapTR/docs/visualization.md deleted file mode 100644 index e46cbe2681d793225246a7eca10298cd72072278..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/docs/visualization.md +++ /dev/null @@ -1,30 +0,0 @@ -# Visualization - -We provide all the visualization scripts under `/path/to/MapTR/tools/maptr/` - -## Visualize prediction - -```shell -cd /path/to/MapTR/ -export PYTHONPATH="/path/to/MapTR/" -# visualize nuscenes dataset -python tools/maptrv2/nusc_vis_pred.py /path/to/experiment/config /path/to/experiment/ckpt - -#visualize argoverse2 dataset -python tools/maptrv2/av2_vis_pred.py /path/to/experiment/config /path/to/experiment/ckpt -``` -**Notes**: - -- All the visualization samples will be saved in `/path/to/MapTR/work_dirs/experiment/vis_pred/` automatically. If you want to customize the saving path, you can add `--show-dir /customized_path`. -- The score threshold is set to 0.3 by default. For better visualization, you can adjust the threshold by adding `--score-thresh customized_thresh` -- The GT is visualized in fixed_num_pts format by default, we provide multiple formats to visualize GT at the same time by setting `--gt-format`: `se_pts` means the start and end points of GT, `bbox` means the bounding box envelops the GT, `polyline_pts` means the original annotated GT (you can use Douglas-Peucker algorithm to simplify the redundant annotated points). - -## Merge them into video - -We also provide the script to merge the input, output and GT into video to benchmark the performance qualitatively. - -```shell -python tools/maptr/generate_video.py /path/to/visualization/directory -``` -**Notes**: -- The video will be saved in `/path/to/MapTR/work_dirs/experiment/` \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/bevformer/bevformer_tiny.py b/docker-hub/MapTRv2/MapTR/projects/configs/bevformer/bevformer_tiny.py deleted file mode 100644 index 78858ee9a0f4b26395ae1f871ab3ed80c46e95ee..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/bevformer/bevformer_tiny.py +++ /dev/null @@ -1,270 +0,0 @@ -# BEvFormer-tiny consumes at lease 6700M GPU memory -# compared to bevformer_base, bevformer_tiny has -# smaller backbone: R101-DCN -> R50 -# smaller BEV: 200*200 -> 50*50 -# less encoder layers: 6 -> 3 -# smaller input size: 1600*900 -> 800*450 -# multi-scale feautres -> single scale features (C5) - - -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -voxel_size = [0.2, 0.2, 8] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -bev_h_ = 50 -bev_w_ = 50 -queue_length = 3 # each sequence contains `queue_length` frames. - -model = dict( - type='BEVFormer', - use_grid_mask=True, - video_test_mode=True, - pretrained=dict(img='torchvision://resnet50'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='BEVFormerHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_classes=10, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - transformer=dict( - type='PerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=3, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='DetectionTransformerDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='NMSFreeCoder', - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - pc_range=point_cloud_range, - max_num=300, - voxel_size=voxel_size, - num_classes=10), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.25), - loss_iou=dict(type='GIoULoss', loss_weight=0.0)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='HungarianAssigner3D', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - iou_cost=dict(type='IoUCost', weight=0.0), # Fake cost. This is just to make it compatible with DETR head. - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=1, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=2e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) - -checkpoint_config = dict(interval=1) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py b/docker-hub/MapTRv2/MapTR/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py deleted file mode 100644 index aa1e0437fdc182042a7c5513136f57f78ab81044..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/bevformer_fp16/bevformer_tiny_fp16.py +++ /dev/null @@ -1,272 +0,0 @@ -# BEvFormer-tiny consumes at lease 6700M GPU memory -# compared to bevformer_base, bevformer_tiny has -# smaller backbone: R101-DCN -> R50 -# smaller BEV: 200*200 -> 50*50 -# less encoder layers: 6 -> 3 -# smaller input size: 1600*900 -> 800*450 -# multi-scale feautres -> single scale features (C5) - - -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -voxel_size = [0.2, 0.2, 8] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -bev_h_ = 50 -bev_w_ = 50 -queue_length = 3 # each sequence contains `queue_length` frames. - -model = dict( - type='BEVFormer_fp16', - use_grid_mask=True, - video_test_mode=True, - pretrained=dict(img='torchvision://resnet50'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='BEVFormerHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_classes=10, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - transformer=dict( - type='PerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=3, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='DetectionTransformerDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='NMSFreeCoder', - post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - pc_range=point_cloud_range, - max_num=300, - voxel_size=voxel_size, - num_classes=10), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.25), - loss_iou=dict(type='GIoULoss', loss_weight=0.0)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='HungarianAssigner3D', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - iou_cost=dict(type='IoUCost', weight=0.0), # Fake cost. This is just to make it compatible with DETR head. - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=2, - workers_per_gpu=8, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=2.8e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner_video', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) - -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) -custom_hooks = [dict(type='TransferWeight',priority='LOWEST')] \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_lyft-3d.py b/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_lyft-3d.py deleted file mode 100644 index 5a95d898c91e463b731a08f7c52b8186e99da83a..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_lyft-3d.py +++ /dev/null @@ -1,136 +0,0 @@ -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-80, -80, -5, 80, 80, 3] -# For Lyft we usually do 9-class detection -class_names = [ - 'car', 'truck', 'bus', 'emergency_vehicle', 'other_vehicle', 'motorcycle', - 'bicycle', 'pedestrian', 'animal' -] -dataset_type = 'CustomLyftDataset' -data_root = 'data/lyft/' -# Input modality for Lyft dataset, this is consistent with the submission -# format which requires the information in input_modality. -input_modality = dict( - use_lidar=True, - use_camera=False, - use_radar=False, - use_map=False, - use_external=True) -file_client_args = dict(backend='disk') -# Uncomment the following if use ceph or other file clients. -# See https://mmcv.readthedocs.io/en/latest/api.html#mmcv.fileio.FileClient -# for more details. -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/lyft/': 's3://lyft/lyft/', -# 'data/lyft/': 's3://lyft/lyft/' -# })) -train_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True), - dict( - type='GlobalRotScaleTrans', - rot_range=[-0.3925, 0.3925], - scale_ratio_range=[0.95, 1.05], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D', flip_ratio_bev_horizontal=0.5), - dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='PointShuffle'), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) -] -test_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='GlobalRotScaleTrans', - rot_range=[0, 0], - scale_ratio_range=[1., 1.], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D'), - dict( - type='PointsRangeFilter', point_cloud_range=point_cloud_range), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points']) - ]) -] -# construct a pipeline for data and gt loading in show function -# please keep its loading function consistent with test_pipeline (e.g. client) -eval_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - file_client_args=file_client_args), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='Collect3D', keys=['points']) -] - -data = dict( - samples_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_val.pkl', - pipeline=test_pipeline, - classes=class_names, - modality=input_modality, - test_mode=True), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'lyft_infos_val.pkl', - pipeline=test_pipeline, - classes=class_names, - modality=input_modality, - test_mode=True)) -# For Lyft dataset, we usually evaluate the model at the end of training. -# Since the models are trained by 24 epochs by default, we set evaluation -# interval to be 24. Please change the interval accordingly if you do not -# use a default schedule. -evaluation = dict(interval=24, pipeline=eval_pipeline) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_waymo-3d.py b/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_waymo-3d.py deleted file mode 100644 index 4100e13546badb06e69fd0b1ed20158de8acf893..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/datasets/custom_waymo-3d.py +++ /dev/null @@ -1,112 +0,0 @@ -# dataset settings -# D5 in the config name means the whole dataset is divided into 5 folds -# We only use one fold for efficient experiments -dataset_type = 'CustomWaymoDataset' -data_root = 'data/waymo/kitti_format/' -file_client_args = dict(backend='disk') -# Uncomment the following if use ceph or other file clients. -# See https://mmcv.readthedocs.io/en/latest/api.html#mmcv.fileio.FileClient -# for more details. -# file_client_args = dict( -# backend='petrel', path_mapping=dict(data='s3://waymo_data/')) - -img_norm_cfg = dict( - mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) -class_names = ['Car', 'Pedestrian', 'Cyclist'] -point_cloud_range = [-74.88, -74.88, -2, 74.88, 74.88, 4] -input_modality = dict(use_lidar=False, use_camera=True) -db_sampler = dict( - data_root=data_root, - info_path=data_root + 'waymo_dbinfos_train.pkl', - rate=1.0, - prepare=dict( - filter_by_difficulty=[-1], - filter_by_min_points=dict(Car=5, Pedestrian=10, Cyclist=10)), - classes=class_names, - sample_groups=dict(Car=15, Pedestrian=10, Cyclist=10), - points_loader=dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=[0, 1, 2, 3, 4], - file_client_args=file_client_args)) - - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1920, 1280), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - - -# construct a pipeline for data and gt loading in show function -# please keep its loading function consistent with test_pipeline (e.g. client) - -data = dict( - samples_per_gpu=2, - workers_per_gpu=4, - train=dict( - type='RepeatDataset', - times=2, - dataset=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_train.pkl', - split='training', - pipeline=train_pipeline, - modality=input_modality, - classes=class_names, - test_mode=False, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR', - # load one frame every five frames - load_interval=5)), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_val.pkl', - split='training', - pipeline=test_pipeline, - modality=input_modality, - classes=class_names, - test_mode=True, - box_type_3d='LiDAR'), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'waymo_infos_val.pkl', - split='training', - pipeline=test_pipeline, - modality=input_modality, - classes=class_names, - test_mode=True, - box_type_3d='LiDAR')) - -evaluation = dict(interval=24, pipeline=test_pipeline) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_nano_r18_110e.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_nano_r18_110e.py deleted file mode 100644 index aba45e30a9a2f40de1ca6137e8f845dd87edaa3e..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_nano_r18_110e.py +++ /dev/null @@ -1,312 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0, -2.0, 15.0, 30.0, 2.0] -voxel_size = [0.15, 0.15, 4] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 80 -bev_w_ = 40 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet18-f37072fd.pth'), - img_backbone=dict( - type='ResNet', - depth=18, - num_stages=4, - out_indices=(3,), - frozen_stages=-1, - norm_cfg=dict(type='SyncBN', requires_grad=True), - norm_eval=False, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[512], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=100, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='GeometrySptialCrossAttention', - pc_range=point_cloud_range, - attention=dict( - type='GeometryKernelAttention', - embed_dims=_dim_, - num_heads=4, - dilation=1, - kernel_size=(3,5), - num_levels=_num_levels_, - im2col_step=192), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=2, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=4, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1, - im2col_step=192), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.2]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.2]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=24, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=4e-3, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=50, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 110 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=5) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_fusion_24e.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_fusion_24e.py deleted file mode 100644 index b1fdb8c6e20f3b91ce1eaf65edd348a7df16f492..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_fusion_24e.py +++ /dev/null @@ -1,342 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0, -2.0, 15.0, 30.0, 2.0] -lidar_point_cloud_range = [-15.0, -30.0, -5.0, 15.0, 30.0, 3.0] -voxel_size = [0.1, 0.1, 0.2] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=True, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - modality='fusion', - lidar_encoder=dict( - voxelize=dict(max_num_points=10,point_cloud_range=lidar_point_cloud_range,voxel_size=voxel_size,max_voxels=[90000, 120000]), - backbone=dict( - type='SparseEncoder', - in_channels=5, - sparse_shape=[300, 600, 41], - output_channels=128, - order=('conv', 'norm', 'act'), - encoder_channels=((16, 16, 32), (32, 32, 64), (64, 64, 128), (128, - 128)), - encoder_paddings=([0, 0, 1], [0, 0, 1], [0, 0, [1, 1, 0]], [0, 0]), - block_type='basicblock' - ), - ), - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - modality='fusion', - fuser=dict( - type='ConvFuser', - in_channels=[_dim_, 256], - out_channels=_dim_, - ), - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='GeometrySptialCrossAttention', - pc_range=point_cloud_range, - attention=dict( - type='GeometryKernelAttention', - embed_dims=_dim_, - num_heads=4, - dilation=1, - kernel_size=(3,5), - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - -reduce_beams=32 -load_dim=5 -use_dim=5 - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='CustomLoadPointsFromFile', coord_type='LIDAR', load_dim=load_dim, use_dim=use_dim, reduce_beams=reduce_beams), - dict(type='CustomLoadPointsFromMultiSweeps', sweeps_num=9, load_dim=load_dim, use_dim=use_dim, reduce_beams=reduce_beams, pad_empty_sweeps=True, remove_close=True), - dict(type='CustomPointsRangeFilter', point_cloud_range=lidar_point_cloud_range), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img', 'points']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='CustomLoadPointsFromFile', coord_type='LIDAR', load_dim=load_dim, use_dim=use_dim, reduce_beams=reduce_beams), - dict(type='CustomLoadPointsFromMultiSweeps', sweeps_num=9, load_dim=load_dim, use_dim=use_dim, reduce_beams=reduce_beams, pad_empty_sweeps=True, remove_close=True), - dict(type='CustomPointsRangeFilter', point_cloud_range=lidar_point_cloud_range), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img', 'points']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) -find_unused_parameters=True - diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_110e.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_110e.py deleted file mode 100644 index 9457c677aca7d378d089f04c3003658ff2af08d6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_110e.py +++ /dev/null @@ -1,310 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0, -2.0, 15.0, 30.0, 2.0] -voxel_size = [0.15, 0.15, 4] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='GeometrySptialCrossAttention', - pc_range=point_cloud_range, - attention=dict( - type='GeometryKernelAttention', - embed_dims=_dim_, - num_heads=4, - dilation=1, - kernel_size=(3,5), - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 110 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=5) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e.py deleted file mode 100644 index 5fcded904a2d7b72e7d9e283f6cd6d2e39efa591..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e.py +++ /dev/null @@ -1,310 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0, -2.0, 15.0, 30.0, 2.0] -voxel_size = [0.15, 0.15, 4] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='GeometrySptialCrossAttention', - pc_range=point_cloud_range, - attention=dict( - type='GeometryKernelAttention', - embed_dims=_dim_, - num_heads=4, - dilation=1, - kernel_size=(3,5), - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevformer.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevformer.py deleted file mode 100644 index 1f734f01feddd47133cf68af2099b60069af44f6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevformer.py +++ /dev/null @@ -1,308 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0, -2.0, 15.0, 30.0, 2.0] -voxel_size = [0.15, 0.15, 4] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='SpatialCrossAttention', - pc_range=point_cloud_range, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=_dim_, - num_points=8, - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevpool.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevpool.py deleted file mode 100644 index 189d67f06f7aaddc3c7523324b2f4f4ff8e52017..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_24e_bevpool.py +++ /dev/null @@ -1,290 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0,-10.0, 15.0, 30.0, 10.0] -voxel_size = [0.15, 0.15, 20.0] -dbound=[1.0, 35.0, 0.5] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='LSSTransform', - in_channels=_dim_, - out_channels=_dim_, - feat_down_sample=32, - pc_range=point_cloud_range, - voxel_size=voxel_size, - dbound=dbound, - downsample=2), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True, with_attr_label=False), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['gt_bboxes_3d', 'gt_labels_3d', 'img']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_av2_24e.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_av2_24e.py deleted file mode 100644 index 8bb0958574d19aacd6232a60433cb68197eb9853..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptr/maptr_tiny_r50_av2_24e.py +++ /dev/null @@ -1,315 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-30.0, -15.0, -2.0, 30.0, 15.0, 2.0] -voxel_size = [0.15, 0.15, 4] - - - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 100 -bev_w_ = 200 -queue_length = 1 # each sequence contains `queue_length` frames. - -model = dict( - type='MapTR', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRHead', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec=50, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - num_cams=7, - encoder=dict( - type='BEVFormerEncoder', - num_layers=1, - pc_range=point_cloud_range, - num_points_in_pillar=4, - return_intermediate=False, - transformerlayers=dict( - type='BEVFormerLayer', - attn_cfgs=[ - dict( - type='TemporalSelfAttention', - embed_dims=_dim_, - num_levels=1), - dict( - type='GeometrySptialCrossAttention', - pc_range=point_cloud_range, - num_cams=7, - attention=dict( - type='GeometryKernelAttention', - embed_dims=_dim_, - num_heads=4, - dilation=1, - kernel_size=(3,5), - num_levels=_num_levels_), - embed_dims=_dim_, - ) - ], - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm'))), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DetrTransformerDecoderLayer', - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-35, -20, -35, -20, 35, 20, 35, 20], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005)), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomAV2LocalMapDataset' -data_root = 'data/argoverse2/sensor/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', class_names=class_names), - dict(type='CustomCollect3D', keys=['img']) -] - -test_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(2048, 2048), # 2048*0.3, 2048*0.3 - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - class_names=class_names, - with_label=False), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=6, - workers_per_gpu=8, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - # ann_file=data_root + 'av2_map_infos_train.pkl', - map_ann_file=data_root + 'av2_map_anns_val.json', - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict(type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - # ann_file=data_root + 'av2_map_infos_train.pkl', - map_ann_file=data_root + 'av2_map_anns_val.json', - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer') - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep.py deleted file mode 100644 index efd5118944d5714b8cecf3c0f6e413d87a6ee9e1..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep.py +++ /dev/null @@ -1,350 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-30.0, -15.0, -5.0, 30.0, 15.0, 3.0] -voxel_size = [0.15, 0.15, 8.0] -dbound=[1.0, 35.0, 0.5] - -grid_config = { - 'x': [-30.0, -30.0, 0.15], # useless - 'y': [-15.0, -15.0, 0.15], # useless - 'z': [-10, 10, 20], # useless - 'depth': [1.0, 35.0, 0.5], # useful -} - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -num_vec=50 -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 100 -bev_w_ = 200 -queue_length = 1 # each sequence contains `queue_length` frames. - -aux_seg_cfg = dict( - use_aux_seg=True, - bev_seg=True, - pv_seg=True, - seg_classes=1, - feat_down_sample=32, - pv_thickness=1, -) - -z_cfg = dict( - pred_z_flag=True, - gt_z_flag=True, -) - -model = dict( - type='MapTRv2', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRv2Head', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec_one2one=num_vec, - num_vec_one2many=300, - k_one2many=6, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=3, - code_weights=[1.0, 1.0, 1.0, 1.0], - aux_seg=aux_seg_cfg, - z_cfg=z_cfg, - transformer=dict( - type='MapTRPerceptionTransformer', - num_cams=7, - z_cfg=z_cfg, - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='LSSTransform', - in_channels=_dim_, - out_channels=_dim_, - feat_down_sample=32, - pc_range=point_cloud_range, - voxel_size=voxel_size, - dbound=dbound, - downsample=2, - loss_depth_weight=3.0, - depthnet_cfg=dict(use_dcn=False, with_cp=False, aspp_mid_channels=96), - grid_config=grid_config,), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DecoupledDetrTransformerDecoderLayer', - num_vec=num_vec, - num_pts_per_vec=fixed_ptsnum_per_pred_line, - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'self_attn', 'norm','cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - z_cfg=z_cfg, - post_center_range=[-35, -20, -35, -20, 35, 20, 35, 20], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005), - loss_seg=dict(type='SimpleLoss', - pos_weight=4.0, - loss_weight=1.0), - loss_pv_seg=dict(type='SimpleLoss', - pos_weight=1.0, - loss_weight=2.0),), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - z_cfg=z_cfg, - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomAV2OfflineLocalMapDataset' -data_root = 'data/argoverse2/sensor/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', with_gt=False, with_label=False,class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) -] - -test_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(2048, 2048), # 2048*0.3, 2048*0.3 - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - with_gt=False, - with_label=False, - class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_train.pkl', - z_cfg=z_cfg, - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - aux_seg=aux_seg_cfg, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - map_ann_file=data_root + 'av2_gt_map_anns_val.json', - # code_size=3, - z_cfg=z_cfg, - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality, - samples_per_gpu=1), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - map_ann_file=data_root + 'av2_gt_map_anns_val.json', - # code_size=3, - z_cfg=z_cfg, - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=200, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 6 -evaluation = dict(interval=1, pipeline=test_pipeline, metric='chamfer') -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) -find_unused_parameters=True \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep_w_centerline.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep_w_centerline.py deleted file mode 100644 index af8faa687ec08948112db12420e4d108ca1fa359..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_av2_3d_r50_6ep_w_centerline.py +++ /dev/null @@ -1,350 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-30.0, -15.0, -5.0, 30.0, 15.0, 3.0] -voxel_size = [0.15, 0.15, 8.0] -dbound=[1.0, 35.0, 0.5] - -grid_config = { - 'x': [-30.0, -30.0, 0.15], # useless - 'y': [-15.0, -15.0, 0.15], # useless - 'z': [-10, 10, 20], # useless - 'depth': [1.0, 35.0, 0.5], # useful -} - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary', 'centerline'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -num_vec=70 -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 100 -bev_w_ = 200 -queue_length = 1 # each sequence contains `queue_length` frames. - -aux_seg_cfg = dict( - use_aux_seg=True, - bev_seg=True, - pv_seg=True, - seg_classes=1, - feat_down_sample=32, - pv_thickness=1, -) - -z_cfg = dict( - pred_z_flag=True, - gt_z_flag=True, -) - -model = dict( - type='MapTRv2', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRv2Head', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec_one2one=num_vec, - num_vec_one2many=300, - k_one2many=6, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=3, - code_weights=[1.0, 1.0, 1.0, 1.0], - aux_seg=aux_seg_cfg, - z_cfg=z_cfg, - transformer=dict( - type='MapTRPerceptionTransformer', - num_cams=7, - z_cfg=z_cfg, - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='LSSTransform', - in_channels=_dim_, - out_channels=_dim_, - feat_down_sample=32, - pc_range=point_cloud_range, - voxel_size=voxel_size, - dbound=dbound, - downsample=2, - loss_depth_weight=3.0, - depthnet_cfg=dict(use_dcn=False, with_cp=False, aspp_mid_channels=96), - grid_config=grid_config,), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DecoupledDetrTransformerDecoderLayer', - num_vec=num_vec, - num_pts_per_vec=fixed_ptsnum_per_pred_line, - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'self_attn', 'norm','cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - z_cfg=z_cfg, - post_center_range=[-35, -20, -35, -20, 35, 20, 35, 20], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005), - loss_seg=dict(type='SimpleLoss', - pos_weight=4.0, - loss_weight=1.0), - loss_pv_seg=dict(type='SimpleLoss', - pos_weight=1.0, - loss_weight=2.0),), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - z_cfg=z_cfg, - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomAV2OfflineLocalMapDataset' -data_root = 'data/argoverse2/sensor/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict(type='PadMultiViewImage', size_divisor=32), - dict(type='DefaultFormatBundle3D', with_gt=False, with_label=False,class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) -] - -test_pipeline = [ - dict(type='CustomLoadMultiViewImageFromFiles', to_float32=True, padding=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.3]), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(2048, 2048), # 2048*0.3, 2048*0.3 - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - with_gt=False, - with_label=False, - class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_train.pkl', - z_cfg=z_cfg, - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - aux_seg=aux_seg_cfg, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - map_ann_file=data_root + 'av2_gt_map_anns_val.json', - # code_size=3, - z_cfg=z_cfg, - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality, - samples_per_gpu=1), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'av2_map_infos_val.pkl', - map_ann_file=data_root + 'av2_gt_map_anns_val.json', - # code_size=3, - z_cfg=z_cfg, - load_interval=4, # av2 uses 10 Hz, set to 5, 2HZ the same as nuscenes, - # load_interval=1, # TODO debug - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=200, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 6 -evaluation = dict(interval=1, pipeline=test_pipeline, metric='chamfer') -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(interval=1) -find_unused_parameters=True \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep.py deleted file mode 100644 index e0e8235d16543db0c23f6767898d74b38b56cbd2..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep.py +++ /dev/null @@ -1,341 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0,-10.0, 15.0, 30.0, 10.0] -voxel_size = [0.15, 0.15, 20.0] -dbound=[1.0, 35.0, 0.5] - -grid_config = { - 'x': [-30.0, -30.0, 0.15], # useless - 'y': [-15.0, -15.0, 0.15], # useless - 'z': [-10, 10, 20], # useless - 'depth': [1.0, 35.0, 0.5], # useful -} - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -num_vec=50 -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -aux_seg_cfg = dict( - use_aux_seg=True, - bev_seg=True, - pv_seg=True, - seg_classes=1, - feat_down_sample=32, - pv_thickness=1, -) - -model = dict( - type='MapTRv2', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRv2Head', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec_one2one=50, - num_vec_one2many=300, - k_one2many=6, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - aux_seg=aux_seg_cfg, - # z_cfg=z_cfg, - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='LSSTransform', - in_channels=_dim_, - out_channels=_dim_, - feat_down_sample=32, - pc_range=point_cloud_range, - voxel_size=voxel_size, - dbound=dbound, - downsample=2, - loss_depth_weight=3.0, - depthnet_cfg=dict(use_dcn=False, with_cp=False, aspp_mid_channels=96), - grid_config=grid_config,), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DecoupledDetrTransformerDecoderLayer', - num_vec=num_vec, - num_pts_per_vec=fixed_ptsnum_per_pred_line, - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'self_attn', 'norm','cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005), - loss_seg=dict(type='SimpleLoss', - pos_weight=4.0, - loss_weight=1.0), - loss_pv_seg=dict(type='SimpleLoss', - pos_weight=1.0, - loss_weight=2.0),), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesOfflineLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='CustomPointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='PadMultiViewImageDepth', size_divisor=32), - dict(type='DefaultFormatBundle3D', with_gt=False, with_label=False,class_names=map_classes), - dict(type='CustomCollect3D', keys=['img', 'gt_depth']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - with_gt=False, - with_label=False, - class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=8, - workers_per_gpu=32, - # 最优 - #samples_per_gpu=12, - #workers_per_gpu=48, # TODO - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - aux_seg=aux_seg_cfg, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - #type='Miopen_AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 1 #24 -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer', - save_best='NuscMap_chamfer/mAP', rule='greater') -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=1, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(max_keep_ckpts=1, interval=2) -find_unused_parameters=True diff --git a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep_w_centerline.py b/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep_w_centerline.py deleted file mode 100644 index 5cfdee3344f33e072c5738cc33e175edb4d15a09..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/configs/maptrv2/maptrv2_nusc_r50_24ep_w_centerline.py +++ /dev/null @@ -1,337 +0,0 @@ -_base_ = [ - '../datasets/custom_nus-3d.py', - '../_base_/default_runtime.py' -] -# -plugin = True -plugin_dir = 'projects/mmdet3d_plugin/' - -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -# point_cloud_range = [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] -point_cloud_range = [-15.0, -30.0,-10.0, 15.0, 30.0, 10.0] -voxel_size = [0.15, 0.15, 20.0] -dbound=[1.0, 35.0, 0.5] - -grid_config = { - 'x': [-30.0, -30.0, 0.15], # useless - 'y': [-15.0, -15.0, 0.15], # useless - 'z': [-10, 10, 20], # useless - 'depth': [1.0, 35.0, 0.5], # useful -} - - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) - -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'construction_vehicle', 'bus', 'trailer', 'barrier', - 'motorcycle', 'bicycle', 'pedestrian', 'traffic_cone' -] -# map has classes: divider, ped_crossing, boundary -map_classes = ['divider', 'ped_crossing','boundary','centerline'] -# fixed_ptsnum_per_line = 20 -# map_classes = ['divider',] -num_vec=70 -fixed_ptsnum_per_gt_line = 20 # now only support fixed_pts > 0 -fixed_ptsnum_per_pred_line = 20 -eval_use_same_gt_sample_num_flag=True -num_map_classes = len(map_classes) - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=True) - -_dim_ = 256 -_pos_dim_ = _dim_//2 -_ffn_dim_ = _dim_*2 -_num_levels_ = 1 -# bev_h_ = 50 -# bev_w_ = 50 -bev_h_ = 200 -bev_w_ = 100 -queue_length = 1 # each sequence contains `queue_length` frames. - -aux_seg_cfg = dict( - use_aux_seg=True, - bev_seg=True, - pv_seg=True, - seg_classes=1, - feat_down_sample=32, - pv_thickness=1, -) - -model = dict( - type='MapTRv2', - use_grid_mask=True, - video_test_mode=False, - pretrained=dict(img='ckpts/resnet50-19c8e357.pth'), - img_backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(3,), - frozen_stages=1, - norm_cfg=dict(type='BN', requires_grad=False), - norm_eval=True, - style='pytorch'), - img_neck=dict( - type='FPN', - in_channels=[2048], - out_channels=_dim_, - start_level=0, - add_extra_convs='on_output', - num_outs=_num_levels_, - relu_before_extra_convs=True), - pts_bbox_head=dict( - type='MapTRv2Head', - bev_h=bev_h_, - bev_w=bev_w_, - num_query=900, - num_vec_one2one=num_vec, - num_vec_one2many=300, - k_one2many=6, - num_pts_per_vec=fixed_ptsnum_per_pred_line, # one bbox - num_pts_per_gt_vec=fixed_ptsnum_per_gt_line, - dir_interval=1, - query_embed_type='instance_pts', - transform_method='minmax', - gt_shift_pts_pattern='v2', - num_classes=num_map_classes, - in_channels=_dim_, - sync_cls_avg_factor=True, - with_box_refine=True, - as_two_stage=False, - code_size=2, - code_weights=[1.0, 1.0, 1.0, 1.0], - aux_seg=aux_seg_cfg, - # z_cfg=z_cfg, - transformer=dict( - type='MapTRPerceptionTransformer', - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - embed_dims=_dim_, - encoder=dict( - type='LSSTransform', - in_channels=_dim_, - out_channels=_dim_, - feat_down_sample=32, - pc_range=point_cloud_range, - voxel_size=voxel_size, - dbound=dbound, - downsample=2, - loss_depth_weight=3.0, - depthnet_cfg=dict(use_dcn=False, with_cp=False, aspp_mid_channels=96), - grid_config=grid_config,), - decoder=dict( - type='MapTRDecoder', - num_layers=6, - return_intermediate=True, - transformerlayers=dict( - type='DecoupledDetrTransformerDecoderLayer', - num_vec=num_vec, - num_pts_per_vec=fixed_ptsnum_per_pred_line, - attn_cfgs=[ - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='MultiheadAttention', - embed_dims=_dim_, - num_heads=8, - dropout=0.1), - dict( - type='CustomMSDeformableAttention', - embed_dims=_dim_, - num_levels=1), - ], - - feedforward_channels=_ffn_dim_, - ffn_dropout=0.1, - operation_order=('self_attn', 'norm', 'self_attn', 'norm','cross_attn', 'norm', - 'ffn', 'norm')))), - bbox_coder=dict( - type='MapTRNMSFreeCoder', - # post_center_range=[-61.2, -61.2, -10.0, 61.2, 61.2, 10.0], - post_center_range=[-20, -35, -20, -35, 20, 35, 20, 35], - pc_range=point_cloud_range, - max_num=50, - voxel_size=voxel_size, - num_classes=num_map_classes), - positional_encoding=dict( - type='LearnedPositionalEncoding', - num_feats=_pos_dim_, - row_num_embed=bev_h_, - col_num_embed=bev_w_, - ), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0), - loss_bbox=dict(type='L1Loss', loss_weight=0.0), - loss_iou=dict(type='GIoULoss', loss_weight=0.0), - loss_pts=dict(type='PtsL1Loss', - loss_weight=5.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=0.005), - loss_seg=dict(type='SimpleLoss', - pos_weight=4.0, - loss_weight=1.0), - loss_pv_seg=dict(type='SimpleLoss', - pos_weight=1.0, - loss_weight=2.0),), - # model training and testing settings - train_cfg=dict(pts=dict( - grid_size=[512, 512, 1], - voxel_size=voxel_size, - point_cloud_range=point_cloud_range, - out_size_factor=4, - assigner=dict( - type='MapTRAssigner', - cls_cost=dict(type='FocalLossCost', weight=2.0), - reg_cost=dict(type='BBoxL1Cost', weight=0.0, box_format='xywh'), - # reg_cost=dict(type='BBox3DL1Cost', weight=0.25), - # iou_cost=dict(type='IoUCost', weight=1.0), # Fake cost. This is just to make it compatible with DETR head. - iou_cost=dict(type='IoUCost', iou_mode='giou', weight=0.0), - pts_cost=dict(type='OrderedPtsL1Cost', - weight=5), - pc_range=point_cloud_range)))) - -dataset_type = 'CustomNuScenesOfflineLocalMapDataset' -data_root = 'data/nuscenes/' -file_client_args = dict(backend='disk') - - -train_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='PhotoMetricDistortionMultiViewImage'), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - file_client_args=file_client_args), - dict(type='CustomPointToMultiViewDepth', downsample=1, grid_config=grid_config), - dict(type='PadMultiViewImageDepth', size_divisor=32), - dict(type='DefaultFormatBundle3D', with_gt=False, with_label=False,class_names=map_classes), - dict(type='CustomCollect3D', keys=['img', 'gt_depth']) -] - -test_pipeline = [ - dict(type='LoadMultiViewImageFromFiles', to_float32=True), - dict(type='RandomScaleImageMultiViewImage', scales=[0.5]), - dict(type='NormalizeMultiviewImage', **img_norm_cfg), - - dict( - type='MultiScaleFlipAug3D', - img_scale=(1600, 900), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict(type='PadMultiViewImage', size_divisor=32), - dict( - type='DefaultFormatBundle3D', - with_gt=False, - with_label=False, - class_names=map_classes), - dict(type='CustomCollect3D', keys=['img']) - ]) -] - -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, # TODO - train=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_train.pkl', - pipeline=train_pipeline, - classes=class_names, - modality=input_modality, - aux_seg=aux_seg_cfg, - test_mode=False, - use_valid_flag=True, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - queue_length=queue_length, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR'), - val=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, modality=input_modality, samples_per_gpu=1), - test=dict( - type=dataset_type, - data_root=data_root, - ann_file=data_root + 'nuscenes_map_infos_temporal_val.pkl', - map_ann_file=data_root + 'nuscenes_map_anns_val.json', - pipeline=test_pipeline, - bev_size=(bev_h_, bev_w_), - pc_range=point_cloud_range, - fixed_ptsnum_per_line=fixed_ptsnum_per_gt_line, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag, - padding_value=-10000, - map_classes=map_classes, - classes=class_names, - modality=input_modality), - shuffler_sampler=dict(type='DistributedGroupSampler'), - nonshuffler_sampler=dict(type='DistributedSampler') -) - -optimizer = dict( - type='AdamW', - lr=6e-4, - paramwise_cfg=dict( - custom_keys={ - 'img_backbone': dict(lr_mult=0.1), - }), - weight_decay=0.01) - -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='CosineAnnealing', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3) -total_epochs = 24 -evaluation = dict(interval=2, pipeline=test_pipeline, metric='chamfer', - save_best='NuscMap_chamfer/mAP', rule='greater') -# total_epochs = 50 -# evaluation = dict(interval=1, pipeline=test_pipeline) - -runner = dict(type='EpochBasedRunner', max_epochs=total_epochs) - -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - dict(type='TensorboardLoggerHook') - ]) -fp16 = dict(loss_scale=512.) -checkpoint_config = dict(max_keep_ckpts=1, interval=2) -find_unused_parameters=True \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/__init__.py deleted file mode 100644 index 15dff22b7478a0f30151d376d41f3dc46e88ba7d..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .train import custom_train_model -from .mmdet_train import custom_train_detector -# from .test import custom_multi_gpu_test \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py deleted file mode 100644 index 9f3ce904c69ef60997271bd8f4ce7763318d0e9e..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py +++ /dev/null @@ -1,280 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import random -import warnings - -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, - Fp16OptimizerHook, OptimizerHook, build_optimizer, - build_runner, get_dist_info) -from mmcv.utils import build_from_cfg - -from mmdet.core import EvalHook - -from mmdet.datasets import (build_dataset, - replace_ImageToTensor) -from mmdet.utils import get_root_logger -import time -import os.path as osp -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.core.evaluation.eval_hooks import CustomDistEvalHook -from projects.mmdet3d_plugin.datasets import custom_build_dataset - -from mmcv.runner import Hook - -class ProfilerHook(Hook): - def __init__(self, profiler, total_steps): - self.profiler = profiler - self.total_steps = total_steps # 总步数 (wait + warmup + active) * repeat - self.stopped = False - - def after_train_iter(self, runner): - - if self.profiler.step_num == self.total_steps and not self.stopped: - # 停止Profiler - self.profiler.stop() - self.stopped = True - - # 只在rank 0上打印结果 - rank, _ = get_dist_info() - if rank == 0: - # 获取并打印关键指标 - # table = self.profiler.key_averages().table( - # sort_by="self_cuda_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - # table = self.profiler.key_averages().table( - # sort_by="self_cpu_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - - results = self.profiler.key_averages().table(sort_by="cuda_time_total") - log_file = "/workspace/MapTR/profiler_logs/BW_log_step{}.txt".format(self.total_steps) - with open(log_file, mode='w') as file: - file.write(str(results)) - # self.profiler.start() - if not self.stopped: - self.profiler.step() - # 检测是否完成所有schedule步骤 - -def custom_train_detector(model, - dataset, - cfg, - distributed=False, - validate=False, - timestamp=None, - eval_model=None, - meta=None): - logger = get_root_logger(cfg.log_level) - - # prepare data loaders - - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - #assert len(dataset)==1s - if 'imgs_per_gpu' in cfg.data: - logger.warning('"imgs_per_gpu" is deprecated in MMDet V2.0. ' - 'Please use "samples_per_gpu" instead') - if 'samples_per_gpu' in cfg.data: - logger.warning( - f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' - f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' - f'={cfg.data.imgs_per_gpu} is used in this experiments') - else: - logger.warning( - 'Automatically set "samples_per_gpu"="imgs_per_gpu"=' - f'{cfg.data.imgs_per_gpu} in this experiments') - cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu - - data_loaders = [ - build_dataloader( - ds, - cfg.data.samples_per_gpu, - cfg.data.workers_per_gpu, - # cfg.gpus will be ignored if distributed - len(cfg.gpu_ids), - dist=distributed, - seed=cfg.seed, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) for ds in dataset - ] - - # put model on gpus - if distributed: - find_unused_parameters = cfg.get('find_unused_parameters', False) - # Sets the `find_unused_parameters` parameter in - # torch.nn.parallel.DistributedDataParallel - model = MMDistributedDataParallel( - model.cuda().to(memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - if eval_model is not None: - eval_model = MMDistributedDataParallel( - eval_model.cuda(), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - else: - model = MMDataParallel( - model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - if eval_model is not None: - eval_model = MMDataParallel( - eval_model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - - if 'runner' not in cfg: - cfg.runner = { - 'type': 'EpochBasedRunner', - 'max_epochs': cfg.total_epochs - } - warnings.warn( - 'config is now expected to have a `runner` section, ' - 'please set `runner` in your config.', UserWarning) - else: - if 'total_epochs' in cfg: - assert cfg.total_epochs == cfg.runner.max_epochs - if eval_model is not None: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - eval_model=eval_model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - else: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - - # an ugly workaround to make .log and .log.json filenames the same - runner.timestamp = timestamp - - # fp16 setting - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=distributed) - elif distributed and 'type' not in cfg.optimizer_config: - optimizer_config = OptimizerHook(**cfg.optimizer_config) - else: - optimizer_config = cfg.optimizer_config - - # register hooks - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config, - cfg.get('momentum_config', None)) - - # register profiler hook - #trace_config = dict(type='tb_trace', dir_name='work_dir') - #profiler_config = dict(on_trace_ready=trace_config) - #runner.register_profiler_hook(profiler_config) - - if distributed: - if isinstance(runner, EpochBasedRunner): - runner.register_hook(DistSamplerSeedHook()) - - # register eval hooks - if validate: - # Support batch_size > 1 in validation - val_samples_per_gpu = cfg.data.val.pop('samples_per_gpu', 1) - if val_samples_per_gpu > 1: - assert False - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.val.pipeline = replace_ImageToTensor( - cfg.data.val.pipeline) - val_dataset = custom_build_dataset(cfg.data.val, dict(test_mode=True)) - - val_dataloader = build_dataloader( - val_dataset, - samples_per_gpu=val_samples_per_gpu, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) - eval_cfg = cfg.get('evaluation', {}) - eval_cfg['by_epoch'] = cfg.runner['type'] != 'IterBasedRunner' - eval_cfg['jsonfile_prefix'] = osp.join('val', cfg.work_dir, time.ctime().replace(' ','_').replace(':','_')) - eval_hook = CustomDistEvalHook if distributed else EvalHook - runner.register_hook(eval_hook(val_dataloader, **eval_cfg)) - - # user-defined hooks - if cfg.get('custom_hooks', None): - custom_hooks = cfg.custom_hooks - assert isinstance(custom_hooks, list), \ - f'custom_hooks expect list type, but got {type(custom_hooks)}' - for hook_cfg in cfg.custom_hooks: - assert isinstance(hook_cfg, dict), \ - 'Each item in custom_hooks expects dict type, but got ' \ - f'{type(hook_cfg)}' - hook_cfg = hook_cfg.copy() - priority = hook_cfg.pop('priority', 'NORMAL') - hook = build_from_cfg(hook_cfg, HOOKS) - runner.register_hook(hook, priority=priority) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - - if False: - # 创建profiler配置 - total_steps = (1 + 20 + 1) * 1 # 22 steps - profiler = torch.profiler.profile( - activities=[ - torch.profiler.ProfilerActivity.CPU, - torch.profiler.ProfilerActivity.CUDA - ], - schedule=torch.profiler.schedule( - wait=1, # 跳过前1个step - warmup=20, # 预热1个step(不计入结果) - active=1, # 分析3个step - repeat=1 # 只执行一轮 - ), - on_trace_ready=torch.profiler.tensorboard_trace_handler( - # f"{cfg.work_dir}/profiler_logs" # 输出目录 - "/workspace/MapTR/profiler_logs" - # "./profiler_logs" - ), - with_stack=True, # 收集调用栈信息 - profile_memory=False, # 分析内存使用 - record_shapes=False # 记录张量形状 - ) - # 创建并注册ProfilerHook - # profiler_hook = ProfilerHook(profiler) - profiler_hook = ProfilerHook(profiler,total_steps) - runner.register_hook(profiler_hook) - # 启动profiler - profiler.start() - print("==================================== profiler.start()===================================================================") - try: - # 运行训练 - runner.run(data_loaders, cfg.workflow) - finally: - # 确保profiler停止 - profiler.stop() - else: - # 正常训练 - runner.run(data_loaders, cfg.workflow) - #runner.run(data_loaders, cfg.workflow) - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old deleted file mode 100644 index 10b3ded551a0a4b25a49ba9b7f09f6863fe74f5f..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/mmdet_train.py_old +++ /dev/null @@ -1,202 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import random -import warnings - -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, - Fp16OptimizerHook, OptimizerHook, build_optimizer, - build_runner, get_dist_info) -from mmcv.utils import build_from_cfg - -from mmdet.core import EvalHook - -from mmdet.datasets import (build_dataset, - replace_ImageToTensor) -from mmdet.utils import get_root_logger -import time -import os.path as osp -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.core.evaluation.eval_hooks import CustomDistEvalHook -from projects.mmdet3d_plugin.datasets import custom_build_dataset - - -def custom_train_detector(model, - dataset, - cfg, - distributed=False, - validate=False, - timestamp=None, - eval_model=None, - meta=None): - logger = get_root_logger(cfg.log_level) - - # prepare data loaders - - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - #assert len(dataset)==1s - if 'imgs_per_gpu' in cfg.data: - logger.warning('"imgs_per_gpu" is deprecated in MMDet V2.0. ' - 'Please use "samples_per_gpu" instead') - if 'samples_per_gpu' in cfg.data: - logger.warning( - f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' - f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' - f'={cfg.data.imgs_per_gpu} is used in this experiments') - else: - logger.warning( - 'Automatically set "samples_per_gpu"="imgs_per_gpu"=' - f'{cfg.data.imgs_per_gpu} in this experiments') - cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu - - data_loaders = [ - build_dataloader( - ds, - cfg.data.samples_per_gpu, - cfg.data.workers_per_gpu, - # cfg.gpus will be ignored if distributed - len(cfg.gpu_ids), - dist=distributed, - seed=cfg.seed, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) for ds in dataset - ] - - # put model on gpus - if distributed: - find_unused_parameters = cfg.get('find_unused_parameters', False) - # Sets the `find_unused_parameters` parameter in - # torch.nn.parallel.DistributedDataParallel - model = MMDistributedDataParallel( - model.cuda().to(memory_format=torch.channels_last), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - if eval_model is not None: - eval_model = MMDistributedDataParallel( - eval_model.cuda(), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters) - else: - model = MMDataParallel( - model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - if eval_model is not None: - eval_model = MMDataParallel( - eval_model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids) - - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - - if 'runner' not in cfg: - cfg.runner = { - 'type': 'EpochBasedRunner', - 'max_epochs': cfg.total_epochs - } - warnings.warn( - 'config is now expected to have a `runner` section, ' - 'please set `runner` in your config.', UserWarning) - else: - if 'total_epochs' in cfg: - assert cfg.total_epochs == cfg.runner.max_epochs - if eval_model is not None: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - eval_model=eval_model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - else: - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta)) - - # an ugly workaround to make .log and .log.json filenames the same - runner.timestamp = timestamp - - # fp16 setting - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=distributed) - elif distributed and 'type' not in cfg.optimizer_config: - optimizer_config = OptimizerHook(**cfg.optimizer_config) - else: - optimizer_config = cfg.optimizer_config - - # register hooks - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config, - cfg.get('momentum_config', None)) - - # register profiler hook - #trace_config = dict(type='tb_trace', dir_name='work_dir') - #profiler_config = dict(on_trace_ready=trace_config) - #runner.register_profiler_hook(profiler_config) - - if distributed: - if isinstance(runner, EpochBasedRunner): - runner.register_hook(DistSamplerSeedHook()) - - # register eval hooks - if validate: - # Support batch_size > 1 in validation - val_samples_per_gpu = cfg.data.val.pop('samples_per_gpu', 1) - if val_samples_per_gpu > 1: - assert False - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.val.pipeline = replace_ImageToTensor( - cfg.data.val.pipeline) - val_dataset = custom_build_dataset(cfg.data.val, dict(test_mode=True)) - - val_dataloader = build_dataloader( - val_dataset, - samples_per_gpu=val_samples_per_gpu, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False, - shuffler_sampler=cfg.data.shuffler_sampler, # dict(type='DistributedGroupSampler'), - nonshuffler_sampler=cfg.data.nonshuffler_sampler, # dict(type='DistributedSampler'), - ) - eval_cfg = cfg.get('evaluation', {}) - eval_cfg['by_epoch'] = cfg.runner['type'] != 'IterBasedRunner' - eval_cfg['jsonfile_prefix'] = osp.join('val', cfg.work_dir, time.ctime().replace(' ','_').replace(':','_')) - eval_hook = CustomDistEvalHook if distributed else EvalHook - runner.register_hook(eval_hook(val_dataloader, **eval_cfg)) - - # user-defined hooks - if cfg.get('custom_hooks', None): - custom_hooks = cfg.custom_hooks - assert isinstance(custom_hooks, list), \ - f'custom_hooks expect list type, but got {type(custom_hooks)}' - for hook_cfg in cfg.custom_hooks: - assert isinstance(hook_cfg, dict), \ - 'Each item in custom_hooks expects dict type, but got ' \ - f'{type(hook_cfg)}' - hook_cfg = hook_cfg.copy() - priority = hook_cfg.pop('priority', 'NORMAL') - hook = build_from_cfg(hook_cfg, HOOKS) - runner.register_hook(hook, priority=priority) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - runner.run(data_loaders, cfg.workflow) - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/test.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/test.py deleted file mode 100644 index cd507e4c8d56af2a3b21eb6ce64d563345bff213..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/apis/test.py +++ /dev/null @@ -1,164 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import os.path as osp -import pickle -import shutil -import tempfile -import time - -import mmcv -import torch -import torch.distributed as dist -from mmcv.image import tensor2imgs -from mmcv.runner import get_dist_info - -from mmdet.core import encode_mask_results - - -import mmcv -import numpy as np -import pycocotools.mask as mask_util - -def custom_encode_mask_results(mask_results): - """Encode bitmap mask to RLE code. Semantic Masks only - Args: - mask_results (list | tuple[list]): bitmap mask results. - In mask scoring rcnn, mask_results is a tuple of (segm_results, - segm_cls_score). - Returns: - list | tuple: RLE encoded mask. - """ - cls_segms = mask_results - num_classes = len(cls_segms) - encoded_mask_results = [] - for i in range(len(cls_segms)): - encoded_mask_results.append( - mask_util.encode( - np.array( - cls_segms[i][:, :, np.newaxis], order='F', - dtype='uint8'))[0]) # encoded with RLE - return [encoded_mask_results] - -def custom_multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): - """Test model with multiple gpus. - This method tests model with multiple gpus and collects the results - under two different modes: gpu and cpu modes. By setting 'gpu_collect=True' - it encodes results to gpu tensors and use gpu communication for results - collection. On cpu mode it saves the results on different gpus to 'tmpdir' - and collects them by the rank 0 worker. - Args: - model (nn.Module): Model to be tested. - data_loader (nn.Dataloader): Pytorch data loader. - tmpdir (str): Path of directory to save the temporary results from - different gpus under cpu mode. - gpu_collect (bool): Option to use either gpu or cpu to collect results. - Returns: - list: The prediction results. - """ - model.eval() - bbox_results = [] - mask_results = [] - dataset = data_loader.dataset - rank, world_size = get_dist_info() - if rank == 0: - prog_bar = mmcv.ProgressBar(len(dataset)) - time.sleep(2) # This line can prevent deadlock problem in some cases. - have_mask = False - for i, data in enumerate(data_loader): - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - # encode mask results - if isinstance(result, dict): - if 'bbox_results' in result.keys(): - bbox_result = result['bbox_results'] - batch_size = len(result['bbox_results']) - bbox_results.extend(bbox_result) - if 'mask_results' in result.keys() and result['mask_results'] is not None: - mask_result = custom_encode_mask_results(result['mask_results']) - mask_results.extend(mask_result) - have_mask = True - else: - batch_size = len(result) - bbox_results.extend(result) - - #if isinstance(result[0], tuple): - # assert False, 'this code is for instance segmentation, which our code will not utilize.' - # result = [(bbox_results, encode_mask_results(mask_results)) - # for bbox_results, mask_results in result] - if rank == 0: - - for _ in range(batch_size * world_size): - prog_bar.update() - - # collect results from all ranks - if gpu_collect: - bbox_results = collect_results_gpu(bbox_results, len(dataset)) - if have_mask: - mask_results = collect_results_gpu(mask_results, len(dataset)) - else: - mask_results = None - else: - bbox_results = collect_results_cpu(bbox_results, len(dataset), tmpdir) - tmpdir = tmpdir+'_mask' if tmpdir is not None else None - if have_mask: - mask_results = collect_results_cpu(mask_results, len(dataset), tmpdir) - else: - mask_results = None - - if mask_results is None: - return bbox_results - return {'bbox_results': bbox_results, 'mask_results': mask_results} - - -def collect_results_cpu(result_part, size, tmpdir=None): - rank, world_size = get_dist_info() - # create a tmp dir if it is not specified - if tmpdir is None: - MAX_LEN = 512 - # 32 is whitespace - dir_tensor = torch.full((MAX_LEN, ), - 32, - dtype=torch.uint8, - device='cuda') - if rank == 0: - mmcv.mkdir_or_exist('.dist_test') - tmpdir = tempfile.mkdtemp(dir='.dist_test') - tmpdir = torch.tensor( - bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') - dir_tensor[:len(tmpdir)] = tmpdir - dist.broadcast(dir_tensor, 0) - tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() - else: - mmcv.mkdir_or_exist(tmpdir) - # dump the part result to the dir - mmcv.dump(result_part, osp.join(tmpdir, f'part_{rank}.pkl')) - dist.barrier() - # collect all parts - if rank != 0: - return None - else: - # load results of all parts from tmp dir - part_list = [] - for i in range(world_size): - part_file = osp.join(tmpdir, f'part_{i}.pkl') - part_list.append(mmcv.load(part_file)) - # sort the results - ordered_results = [] - ''' - bacause we change the sample of the evaluation stage to make sure that each gpu will handle continuous sample, - ''' - #for res in zip(*part_list): - for res in part_list: - ordered_results.extend(list(res)) - # the dataloader may pad some samples - ordered_results = ordered_results[:size] - # remove tmp dir - shutil.rmtree(tmpdir) - return ordered_results - - -def collect_results_gpu(result_part, size): - collect_results_cpu(result_part, size) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/__init__.py deleted file mode 100644 index 6823adfb593d67f27af4af2207a515af4cbab6f5..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .bevformer_head import BEVFormerHead \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py deleted file mode 100644 index 91d38d1411e5093cf4ae801ea08de88ef47b6a8e..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/dense_heads/bevformer_head.py +++ /dev/null @@ -1,523 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import copy -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import Linear, bias_init_with_prob -from mmcv.utils import TORCH_VERSION, digit_version - -from mmdet.core import (multi_apply, multi_apply, reduce_mean) -from mmdet.models.utils.transformer import inverse_sigmoid -from mmdet.models import HEADS -from mmdet.models.dense_heads import DETRHead -from mmdet3d.core.bbox.coders import build_bbox_coder -from projects.mmdet3d_plugin.core.bbox.util import normalize_bbox -from mmcv.cnn.bricks.transformer import build_positional_encoding -from mmcv.runner import force_fp32, auto_fp16 -from projects.mmdet3d_plugin.models.utils.bricks import run_time -import numpy as np -import mmcv -import cv2 as cv -from projects.mmdet3d_plugin.models.utils.visual import save_tensor - - -@HEADS.register_module() -class BEVFormerHead(DETRHead): - """Head of Detr3D. - Args: - with_box_refine (bool): Whether to refine the reference points - in the decoder. Defaults to False. - as_two_stage (bool) : Whether to generate the proposal from - the outputs of encoder. - transformer (obj:`ConfigDict`): ConfigDict is used for building - the Encoder and Decoder. - bev_h, bev_w (int): spatial shape of BEV queries. - """ - - def __init__(self, - *args, - with_box_refine=False, - as_two_stage=False, - transformer=None, - bbox_coder=None, - num_cls_fcs=2, - code_weights=None, - bev_h=30, - bev_w=30, - **kwargs): - - self.bev_h = bev_h - self.bev_w = bev_w - self.fp16_enabled = False - - self.with_box_refine = with_box_refine - self.as_two_stage = as_two_stage - if self.as_two_stage: - transformer['as_two_stage'] = self.as_two_stage - if 'code_size' in kwargs: - self.code_size = kwargs['code_size'] - else: - self.code_size = 10 - if code_weights is not None: - self.code_weights = code_weights - else: - self.code_weights = [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2] - - self.bbox_coder = build_bbox_coder(bbox_coder) - self.pc_range = self.bbox_coder.pc_range - self.real_w = self.pc_range[3] - self.pc_range[0] - self.real_h = self.pc_range[4] - self.pc_range[1] - self.num_cls_fcs = num_cls_fcs - 1 - super(BEVFormerHead, self).__init__( - *args, transformer=transformer, **kwargs) - self.code_weights = nn.Parameter(torch.tensor( - self.code_weights, requires_grad=False), requires_grad=False) - - def _init_layers(self): - """Initialize classification branch and regression branch of head.""" - cls_branch = [] - for _ in range(self.num_reg_fcs): - cls_branch.append(Linear(self.embed_dims, self.embed_dims)) - cls_branch.append(nn.LayerNorm(self.embed_dims)) - cls_branch.append(nn.ReLU(inplace=True)) - cls_branch.append(Linear(self.embed_dims, self.cls_out_channels)) - fc_cls = nn.Sequential(*cls_branch) - - reg_branch = [] - for _ in range(self.num_reg_fcs): - reg_branch.append(Linear(self.embed_dims, self.embed_dims)) - reg_branch.append(nn.ReLU()) - reg_branch.append(Linear(self.embed_dims, self.code_size)) - reg_branch = nn.Sequential(*reg_branch) - - def _get_clones(module, N): - return nn.ModuleList([copy.deepcopy(module) for i in range(N)]) - - # last reg_branch is used to generate proposal from - # encode feature map when as_two_stage is True. - num_pred = (self.transformer.decoder.num_layers + 1) if \ - self.as_two_stage else self.transformer.decoder.num_layers - - if self.with_box_refine: - self.cls_branches = _get_clones(fc_cls, num_pred) - self.reg_branches = _get_clones(reg_branch, num_pred) - else: - self.cls_branches = nn.ModuleList( - [fc_cls for _ in range(num_pred)]) - self.reg_branches = nn.ModuleList( - [reg_branch for _ in range(num_pred)]) - - if not self.as_two_stage: - self.bev_embedding = nn.Embedding( - self.bev_h * self.bev_w, self.embed_dims) - self.query_embedding = nn.Embedding(self.num_query, - self.embed_dims * 2) - - def init_weights(self): - """Initialize weights of the DeformDETR head.""" - self.transformer.init_weights() - if self.loss_cls.use_sigmoid: - bias_init = bias_init_with_prob(0.01) - for m in self.cls_branches: - nn.init.constant_(m[-1].bias, bias_init) - - @auto_fp16(apply_to=('mlvl_feats')) - def forward(self, mlvl_feats, img_metas, prev_bev=None, only_bev=False): - """Forward function. - Args: - mlvl_feats (tuple[Tensor]): Features from the upstream - network, each is a 5D-tensor with shape - (B, N, C, H, W). - prev_bev: previous bev featues - only_bev: only compute BEV features with encoder. - Returns: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, theta, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - """ - - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - object_query_embeds = self.query_embedding.weight.to(dtype) - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - - if only_bev: # only use encoder to obtain BEV features, TODO: refine the workaround - return self.transformer.get_bev_features( - mlvl_feats, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - ) - else: - outputs = self.transformer( - mlvl_feats, - bev_queries, - object_query_embeds, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - reg_branches=self.reg_branches if self.with_box_refine else None, # noqa:E501 - cls_branches=self.cls_branches if self.as_two_stage else None, - img_metas=img_metas, - prev_bev=prev_bev - ) - - bev_embed, hs, init_reference, inter_references = outputs - hs = hs.permute(0, 2, 1, 3) - outputs_classes = [] - outputs_coords = [] - for lvl in range(hs.shape[0]): - if lvl == 0: - reference = init_reference - else: - reference = inter_references[lvl - 1] - reference = inverse_sigmoid(reference) - outputs_class = self.cls_branches[lvl](hs[lvl]) - tmp = self.reg_branches[lvl](hs[lvl]) - - # TODO: check the shape of reference - assert reference.shape[-1] == 3 - tmp[..., 0:2] += reference[..., 0:2] - tmp[..., 0:2] = tmp[..., 0:2].sigmoid() - tmp[..., 4:5] += reference[..., 2:3] - tmp[..., 4:5] = tmp[..., 4:5].sigmoid() - tmp[..., 0:1] = (tmp[..., 0:1] * (self.pc_range[3] - - self.pc_range[0]) + self.pc_range[0]) - tmp[..., 1:2] = (tmp[..., 1:2] * (self.pc_range[4] - - self.pc_range[1]) + self.pc_range[1]) - tmp[..., 4:5] = (tmp[..., 4:5] * (self.pc_range[5] - - self.pc_range[2]) + self.pc_range[2]) - - # TODO: check if using sigmoid - outputs_coord = tmp - outputs_classes.append(outputs_class) - outputs_coords.append(outputs_coord) - - outputs_classes = torch.stack(outputs_classes) - outputs_coords = torch.stack(outputs_coords) - - outs = { - 'bev_embed': bev_embed, - 'all_cls_scores': outputs_classes, - 'all_bbox_preds': outputs_coords, - 'enc_cls_scores': None, - 'enc_bbox_preds': None, - } - - return outs - - def _get_target_single(self, - cls_score, - bbox_pred, - gt_labels, - gt_bboxes, - gt_bboxes_ignore=None): - """"Compute regression and classification targets for one image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_score (Tensor): Box score logits from a single decoder layer - for one image. Shape [num_query, cls_out_channels]. - bbox_pred (Tensor): Sigmoid outputs from a single decoder layer - for one image, with normalized coordinate (cx, cy, w, h) and - shape [num_query, 4]. - gt_bboxes (Tensor): Ground truth bboxes for one image with - shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels (Tensor): Ground truth class indices for one image - with shape (num_gts, ). - gt_bboxes_ignore (Tensor, optional): Bounding boxes - which can be ignored. Default None. - Returns: - tuple[Tensor]: a tuple containing the following for one image. - - labels (Tensor): Labels of each image. - - label_weights (Tensor]): Label weights of each image. - - bbox_targets (Tensor): BBox targets of each image. - - bbox_weights (Tensor): BBox weights of each image. - - pos_inds (Tensor): Sampled positive indices for each image. - - neg_inds (Tensor): Sampled negative indices for each image. - """ - - num_bboxes = bbox_pred.size(0) - # assigner and sampler - gt_c = gt_bboxes.shape[-1] - - assign_result = self.assigner.assign(bbox_pred, cls_score, gt_bboxes, - gt_labels, gt_bboxes_ignore) - - sampling_result = self.sampler.sample(assign_result, bbox_pred, - gt_bboxes) - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - - # label targets - labels = gt_bboxes.new_full((num_bboxes,), - self.num_classes, - dtype=torch.long) - labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] - label_weights = gt_bboxes.new_ones(num_bboxes) - - # bbox targets - bbox_targets = torch.zeros_like(bbox_pred)[..., :gt_c] - bbox_weights = torch.zeros_like(bbox_pred) - bbox_weights[pos_inds] = 1.0 - - # DETR - bbox_targets[pos_inds] = sampling_result.pos_gt_bboxes - return (labels, label_weights, bbox_targets, bbox_weights, - pos_inds, neg_inds) - - def get_targets(self, - cls_scores_list, - bbox_preds_list, - gt_bboxes_list, - gt_labels_list, - gt_bboxes_ignore_list=None): - """"Compute regression and classification targets for a batch image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_scores_list (list[Tensor]): Box score logits from a single - decoder layer for each image with shape [num_query, - cls_out_channels]. - bbox_preds_list (list[Tensor]): Sigmoid outputs from a single - decoder layer for each image, with normalized coordinate - (cx, cy, w, h) and shape [num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - tuple: a tuple containing the following targets. - - labels_list (list[Tensor]): Labels for all images. - - label_weights_list (list[Tensor]): Label weights for all \ - images. - - bbox_targets_list (list[Tensor]): BBox targets for all \ - images. - - bbox_weights_list (list[Tensor]): BBox weights for all \ - images. - - num_total_pos (int): Number of positive samples in all \ - images. - - num_total_neg (int): Number of negative samples in all \ - images. - """ - assert gt_bboxes_ignore_list is None, \ - 'Only supports for gt_bboxes_ignore setting to None.' - num_imgs = len(cls_scores_list) - gt_bboxes_ignore_list = [ - gt_bboxes_ignore_list for _ in range(num_imgs) - ] - - (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pos_inds_list, neg_inds_list) = multi_apply( - self._get_target_single, cls_scores_list, bbox_preds_list, - gt_labels_list, gt_bboxes_list, gt_bboxes_ignore_list) - num_total_pos = sum((inds.numel() for inds in pos_inds_list)) - num_total_neg = sum((inds.numel() for inds in neg_inds_list)) - return (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, num_total_pos, num_total_neg) - - def loss_single(self, - cls_scores, - bbox_preds, - gt_bboxes_list, - gt_labels_list, - gt_bboxes_ignore_list=None): - """"Loss function for outputs from a single decoder layer of a single - feature level. - Args: - cls_scores (Tensor): Box score logits from a single decoder layer - for all images. Shape [bs, num_query, cls_out_channels]. - bbox_preds (Tensor): Sigmoid outputs from a single decoder layer - for all images, with normalized coordinate (cx, cy, w, h) and - shape [bs, num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components for outputs from - a single decoder layer. - """ - num_imgs = cls_scores.size(0) - cls_scores_list = [cls_scores[i] for i in range(num_imgs)] - bbox_preds_list = [bbox_preds[i] for i in range(num_imgs)] - cls_reg_targets = self.get_targets(cls_scores_list, bbox_preds_list, - gt_bboxes_list, gt_labels_list, - gt_bboxes_ignore_list) - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - labels = torch.cat(labels_list, 0) - label_weights = torch.cat(label_weights_list, 0) - bbox_targets = torch.cat(bbox_targets_list, 0) - bbox_weights = torch.cat(bbox_weights_list, 0) - - # classification loss - cls_scores = cls_scores.reshape(-1, self.cls_out_channels) - # construct weighted avg_factor to match with the official DETR repo - cls_avg_factor = num_total_pos * 1.0 + \ - num_total_neg * self.bg_cls_weight - if self.sync_cls_avg_factor: - cls_avg_factor = reduce_mean( - cls_scores.new_tensor([cls_avg_factor])) - - cls_avg_factor = max(cls_avg_factor, 1) - loss_cls = self.loss_cls( - cls_scores, labels, label_weights, avg_factor=cls_avg_factor) - - # Compute the average number of gt boxes accross all gpus, for - # normalization purposes - num_total_pos = loss_cls.new_tensor([num_total_pos]) - num_total_pos = torch.clamp(reduce_mean(num_total_pos), min=1).item() - - # regression L1 loss - bbox_preds = bbox_preds.reshape(-1, bbox_preds.size(-1)) - normalized_bbox_targets = normalize_bbox(bbox_targets, self.pc_range) - isnotnan = torch.isfinite(normalized_bbox_targets).all(dim=-1) - bbox_weights = bbox_weights * self.code_weights - - loss_bbox = self.loss_bbox( - bbox_preds[isnotnan, :10], normalized_bbox_targets[isnotnan, - :10], bbox_weights[isnotnan, :10], - avg_factor=num_total_pos) - if digit_version(TORCH_VERSION) >= digit_version('1.8'): - loss_cls = torch.nan_to_num(loss_cls) - loss_bbox = torch.nan_to_num(loss_bbox) - return loss_cls, loss_bbox - - @force_fp32(apply_to=('preds_dicts')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - preds_dicts, - gt_bboxes_ignore=None, - img_metas=None): - """"Loss function. - Args: - - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - preds_dicts: - all_cls_scores (Tensor): Classification score of all - decoder layers, has shape - [nb_dec, bs, num_query, cls_out_channels]. - all_bbox_preds (Tensor): Sigmoid regression - outputs of all decode layers. Each is a 4D-tensor with - normalized coordinate format (cx, cy, w, h) and shape - [nb_dec, bs, num_query, 4]. - enc_cls_scores (Tensor): Classification scores of - points on encode feature map , has shape - (N, h*w, num_classes). Only be passed when as_two_stage is - True, otherwise is None. - enc_bbox_preds (Tensor): Regression results of each points - on the encode feature map, has shape (N, h*w, 4). Only be - passed when as_two_stage is True, otherwise is None. - gt_bboxes_ignore (list[Tensor], optional): Bounding boxes - which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components. - """ - assert gt_bboxes_ignore is None, \ - f'{self.__class__.__name__} only supports ' \ - f'for gt_bboxes_ignore setting to None.' - - all_cls_scores = preds_dicts['all_cls_scores'] - all_bbox_preds = preds_dicts['all_bbox_preds'] - enc_cls_scores = preds_dicts['enc_cls_scores'] - enc_bbox_preds = preds_dicts['enc_bbox_preds'] - - num_dec_layers = len(all_cls_scores) - device = gt_labels_list[0].device - - gt_bboxes_list = [torch.cat( - (gt_bboxes.gravity_center, gt_bboxes.tensor[:, 3:]), - dim=1).to(device) for gt_bboxes in gt_bboxes_list] - - all_gt_bboxes_list = [gt_bboxes_list for _ in range(num_dec_layers)] - all_gt_labels_list = [gt_labels_list for _ in range(num_dec_layers)] - all_gt_bboxes_ignore_list = [ - gt_bboxes_ignore for _ in range(num_dec_layers) - ] - - losses_cls, losses_bbox = multi_apply( - self.loss_single, all_cls_scores, all_bbox_preds, - all_gt_bboxes_list, all_gt_labels_list, - all_gt_bboxes_ignore_list) - - loss_dict = dict() - # loss of proposal generated from encode feature map. - if enc_cls_scores is not None: - binary_labels_list = [ - torch.zeros_like(gt_labels_list[i]) - for i in range(len(all_gt_labels_list)) - ] - enc_loss_cls, enc_losses_bbox = \ - self.loss_single(enc_cls_scores, enc_bbox_preds, - gt_bboxes_list, binary_labels_list, gt_bboxes_ignore) - loss_dict['enc_loss_cls'] = enc_loss_cls - loss_dict['enc_loss_bbox'] = enc_losses_bbox - - # loss from the last decoder layer - loss_dict['loss_cls'] = losses_cls[-1] - loss_dict['loss_bbox'] = losses_bbox[-1] - - # loss from other decoder layers - num_dec_layer = 0 - for loss_cls_i, loss_bbox_i in zip(losses_cls[:-1], - losses_bbox[:-1]): - loss_dict[f'd{num_dec_layer}.loss_cls'] = loss_cls_i - loss_dict[f'd{num_dec_layer}.loss_bbox'] = loss_bbox_i - num_dec_layer += 1 - return loss_dict - - @force_fp32(apply_to=('preds_dicts')) - def get_bboxes(self, preds_dicts, img_metas, rescale=False): - """Generate bboxes from bbox head predictions. - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - img_metas (list[dict]): Point cloud and image's meta info. - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - """ - - preds_dicts = self.bbox_coder.decode(preds_dicts) - - num_samples = len(preds_dicts) - ret_list = [] - for i in range(num_samples): - preds = preds_dicts[i] - bboxes = preds['bboxes'] - - bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - - code_size = bboxes.shape[-1] - bboxes = img_metas[i]['box_type_3d'](bboxes, code_size) - scores = preds['scores'] - labels = preds['labels'] - - ret_list.append([bboxes, scores, labels]) - - return ret_list diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/__init__.py deleted file mode 100644 index 4c39fd341d5d65f809bb94bee71c6e9a523639e6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .bevformer import BEVFormer -from .bevformer_fp16 import BEVFormer_fp16 \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer.py deleted file mode 100644 index 8d3b676115bb46a39ef21ba7b061e98a72ae11c2..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer.py +++ /dev/null @@ -1,289 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from tkinter.messagebox import NO -import torch -from mmcv.runner import force_fp32, auto_fp16 -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask -import time -import copy -import numpy as np -import mmdet3d -from projects.mmdet3d_plugin.models.utils.bricks import run_time - - -@DETECTORS.register_module() -class BEVFormer(MVXTwoStageDetector): - """BEVFormer. - Args: - video_test_mode (bool): Decide whether to use temporal information during inference. - """ - - def __init__(self, - use_grid_mask=False, - pts_voxel_layer=None, - pts_voxel_encoder=None, - pts_middle_encoder=None, - pts_fusion_layer=None, - img_backbone=None, - pts_backbone=None, - img_neck=None, - pts_neck=None, - pts_bbox_head=None, - img_roi_head=None, - img_rpn_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None, - video_test_mode=False - ): - - super(BEVFormer, - self).__init__(pts_voxel_layer, pts_voxel_encoder, - pts_middle_encoder, pts_fusion_layer, - img_backbone, pts_backbone, img_neck, pts_neck, - pts_bbox_head, img_roi_head, img_rpn_head, - train_cfg, test_cfg, pretrained) - self.grid_mask = GridMask( - True, True, rotate=1, offset=False, ratio=0.5, mode=1, prob=0.7) - self.use_grid_mask = use_grid_mask - self.fp16_enabled = False - - # temporal - self.video_test_mode = video_test_mode - self.prev_frame_info = { - 'prev_bev': None, - 'scene_token': None, - 'prev_pos': 0, - 'prev_angle': 0, - } - - - def extract_img_feat(self, img, img_metas, len_queue=None): - """Extract features of images.""" - B = img.size(0) - if img is not None: - - # input_shape = img.shape[-2:] - # # update real input shape of each single img - # for img_meta in img_metas: - # img_meta.update(input_shape=input_shape) - - if img.dim() == 5 and img.size(0) == 1: - img.squeeze_() - elif img.dim() == 5 and img.size(0) > 1: - B, N, C, H, W = img.size() - img = img.reshape(B * N, C, H, W) - if self.use_grid_mask: - img = self.grid_mask(img) - - img_feats = self.img_backbone(img) - if isinstance(img_feats, dict): - img_feats = list(img_feats.values()) - else: - return None - if self.with_img_neck: - img_feats = self.img_neck(img_feats) - - img_feats_reshaped = [] - for img_feat in img_feats: - BN, C, H, W = img_feat.size() - if len_queue is not None: - img_feats_reshaped.append(img_feat.view(int(B/len_queue), len_queue, int(BN / B), C, H, W)) - else: - img_feats_reshaped.append(img_feat.view(B, int(BN / B), C, H, W)) - return img_feats_reshaped - - @auto_fp16(apply_to=('img')) - def extract_feat(self, img, img_metas=None, len_queue=None): - """Extract features from images and points.""" - - img_feats = self.extract_img_feat(img, img_metas, len_queue=len_queue) - - return img_feats - - - def forward_pts_train(self, - pts_feats, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None, - prev_bev=None): - """Forward function' - Args: - pts_feats (list[torch.Tensor]): Features of point cloud branch - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`]): Ground truth - boxes for each sample. - gt_labels_3d (list[torch.Tensor]): Ground truth labels for - boxes of each sampole - img_metas (list[dict]): Meta information of samples. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - boxes to be ignored. Defaults to None. - prev_bev (torch.Tensor, optional): BEV features of previous frame. - Returns: - dict: Losses of each branch. - """ - - outs = self.pts_bbox_head( - pts_feats, img_metas, prev_bev) - loss_inputs = [gt_bboxes_3d, gt_labels_3d, outs] - losses = self.pts_bbox_head.loss(*loss_inputs, img_metas=img_metas) - return losses - - def forward_dummy(self, img): - dummy_metas = None - return self.forward_test(img=img, img_metas=[[dummy_metas]]) - - def forward(self, return_loss=True, **kwargs): - """Calls either forward_train or forward_test depending on whether - return_loss=True. - Note this setting will change the expected inputs. When - `return_loss=True`, img and img_metas are single-nested (i.e. - torch.Tensor and list[dict]), and when `resturn_loss=False`, img and - img_metas should be double nested (i.e. list[torch.Tensor], - list[list[dict]]), with the outer list indicating test time - augmentations. - """ - if return_loss: - return self.forward_train(**kwargs) - else: - return self.forward_test(**kwargs) - - def obtain_history_bev(self, imgs_queue, img_metas_list): - """Obtain history BEV features iteratively. To save GPU memory, gradients are not calculated. - """ - self.eval() - - with torch.no_grad(): - prev_bev = None - bs, len_queue, num_cams, C, H, W = imgs_queue.shape - imgs_queue = imgs_queue.reshape(bs*len_queue, num_cams, C, H, W) - img_feats_list = self.extract_feat(img=imgs_queue, len_queue=len_queue) - for i in range(len_queue): - img_metas = [each[i] for each in img_metas_list] - # img_feats = self.extract_feat(img=img, img_metas=img_metas) - img_feats = [each_scale[:, i] for each_scale in img_feats_list] - prev_bev = self.pts_bbox_head( - img_feats, img_metas, prev_bev, only_bev=True) - self.train() - return prev_bev - - @auto_fp16(apply_to=('img', 'points')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - - len_queue = img.size(1) - prev_img = img[:, :-1, ...] - img = img[:, -1, ...] - - prev_img_metas = copy.deepcopy(img_metas) - prev_bev = self.obtain_history_bev(prev_img, prev_img_metas) - - img_metas = [each[len_queue-1] for each in img_metas] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - losses = dict() - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev) - - losses.update(losses_pts) - return losses - - def forward_test(self, img_metas, img=None, **kwargs): - for var, name in [(img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - img = [img] if img is None else img - - if img_metas[0][0]['scene_token'] != self.prev_frame_info['scene_token']: - # the first sample of each scene is truncated - self.prev_frame_info['prev_bev'] = None - # update idx - self.prev_frame_info['scene_token'] = img_metas[0][0]['scene_token'] - - # do not use temporal information - if not self.video_test_mode: - self.prev_frame_info['prev_bev'] = None - - # Get the delta of ego position and angle between two timestamps. - tmp_pos = copy.deepcopy(img_metas[0][0]['can_bus'][:3]) - tmp_angle = copy.deepcopy(img_metas[0][0]['can_bus'][-1]) - if self.prev_frame_info['prev_bev'] is not None: - img_metas[0][0]['can_bus'][:3] -= self.prev_frame_info['prev_pos'] - img_metas[0][0]['can_bus'][-1] -= self.prev_frame_info['prev_angle'] - else: - img_metas[0][0]['can_bus'][-1] = 0 - img_metas[0][0]['can_bus'][:3] = 0 - - new_prev_bev, bbox_results = self.simple_test( - img_metas[0], img[0], prev_bev=self.prev_frame_info['prev_bev'], **kwargs) - # During inference, we save the BEV features and ego motion of each timestamp. - self.prev_frame_info['prev_pos'] = tmp_pos - self.prev_frame_info['prev_angle'] = tmp_angle - self.prev_frame_info['prev_bev'] = new_prev_bev - return bbox_results - - def simple_test_pts(self, x, img_metas, prev_bev=None, rescale=False): - """Test function""" - outs = self.pts_bbox_head(x, img_metas, prev_bev=prev_bev) - - bbox_list = self.pts_bbox_head.get_bboxes( - outs, img_metas, rescale=rescale) - bbox_results = [ - bbox3d2result(bboxes, scores, labels) - for bboxes, scores, labels in bbox_list - ] - return outs['bev_embed'], bbox_results - - def simple_test(self, img_metas, img=None, prev_bev=None, rescale=False): - """Test function without augmentaiton.""" - img_feats = self.extract_feat(img=img, img_metas=img_metas) - - bbox_list = [dict() for i in range(len(img_metas))] - new_prev_bev, bbox_pts = self.simple_test_pts( - img_feats, img_metas, prev_bev, rescale=rescale) - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return new_prev_bev, bbox_list diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py deleted file mode 100644 index 5325e3ccb8ac576a6764df3f0094ac5ea1bbc7cb..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/detectors/bevformer_fp16.py +++ /dev/null @@ -1,89 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from tkinter.messagebox import NO -import torch -from mmcv.runner import force_fp32, auto_fp16 -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask -from projects.mmdet3d_plugin.bevformer.detectors.bevformer import BEVFormer -import time -import copy -import numpy as np -import mmdet3d -from projects.mmdet3d_plugin.models.utils.bricks import run_time - - -@DETECTORS.register_module() -class BEVFormer_fp16(BEVFormer): - """ - The default version BEVFormer currently can not support FP16. - We provide this version to resolve this issue. - """ - - @auto_fp16(apply_to=('img', 'prev_bev', 'points')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - prev_bev=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - - img_feats = self.extract_feat(img=img, img_metas=img_metas) - - losses = dict() - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev=prev_bev) - losses.update(losses_pts) - return losses - - - def val_step(self, data, optimizer): - """ - In BEVFormer_fp16, we use this `val_step` function to inference the `prev_pev`. - This is not the standard function of `val_step`. - """ - - img = data['img'] - img_metas = data['img_metas'] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - prev_bev = data.get('prev_bev', None) - prev_bev = self.pts_bbox_head(img_feats, img_metas, prev_bev=prev_bev, only_bev=True) - return prev_bev \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/__init__.py deleted file mode 100644 index aa04ec16df5b0bb9f21cadf22f9172c3cc9a58c1..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .custom_hooks import TransferWeight \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py deleted file mode 100644 index 091738a0950869767647383ad001e5e7e5a5bcaa..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/hooks/custom_hooks.py +++ /dev/null @@ -1,14 +0,0 @@ -from mmcv.runner.hooks.hook import HOOKS, Hook -from projects.mmdet3d_plugin.models.utils import run_time - - -@HOOKS.register_module() -class TransferWeight(Hook): - - def __init__(self, every_n_inters=1): - self.every_n_inters=every_n_inters - - def after_train_iter(self, runner): - if self.every_n_inner_iters(runner, self.every_n_inters): - runner.eval_model.load_state_dict(runner.model.state_dict()) - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/__init__.py deleted file mode 100644 index c6acf05288e8e9bc3ee1afddfd938e305d5d6eca..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .transformer import PerceptionTransformer -from .spatial_cross_attention import SpatialCrossAttention, MSDeformableAttention3D, MSIPM3D -from .temporal_self_attention import TemporalSelfAttention -from .encoder import BEVFormerEncoder, BEVFormerLayer -from .decoder import DetectionTransformerDecoder - - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py deleted file mode 100644 index 77b0f319ccff7e023e1c2d94b63f8c2d7b9c727d..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/multi_scale_deformable_attn_function.py +++ /dev/null @@ -1,163 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import torch -from torch.cuda.amp import custom_bwd, custom_fwd -from torch.autograd.function import Function, once_differentiable -from mmcv.utils import ext_loader -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - - -class MultiScaleDeformableAttnFunction_fp16(Function): - - @staticmethod - @custom_fwd(cast_inputs=torch.float16) - def forward(ctx, value, value_spatial_shapes, value_level_start_index, - sampling_locations, attention_weights, im2col_step): - """GPU version of multi-scale deformable attention. - - Args: - value (Tensor): The value has shape - (bs, num_keys, mum_heads, embed_dims//num_heads) - value_spatial_shapes (Tensor): Spatial shape of - each feature map, has shape (num_levels, 2), - last dimension 2 represent (h, w) - sampling_locations (Tensor): The location of sampling points, - has shape - (bs ,num_queries, num_heads, num_levels, num_points, 2), - the last dimension 2 represent (x, y). - attention_weights (Tensor): The weight of sampling points used - when calculate the attention, has shape - (bs ,num_queries, num_heads, num_levels, num_points), - im2col_step (Tensor): The step used in image to column. - - Returns: - Tensor: has shape (bs, num_queries, embed_dims) - """ - ctx.im2col_step = im2col_step - output = ext_module.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - im2col_step=ctx.im2col_step) - ctx.save_for_backward(value, value_spatial_shapes, - value_level_start_index, sampling_locations, - attention_weights) - return output - - @staticmethod - @once_differentiable - @custom_bwd - def backward(ctx, grad_output): - """GPU version of backward function. - - Args: - grad_output (Tensor): Gradient - of output tensor of forward. - - Returns: - Tuple[Tensor]: Gradient - of input tensors in forward. - """ - value, value_spatial_shapes, value_level_start_index, \ - sampling_locations, attention_weights = ctx.saved_tensors - grad_value = torch.zeros_like(value) - grad_sampling_loc = torch.zeros_like(sampling_locations) - grad_attn_weight = torch.zeros_like(attention_weights) - - ext_module.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output.contiguous(), - grad_value, - grad_sampling_loc, - grad_attn_weight, - im2col_step=ctx.im2col_step) - - return grad_value, None, None, \ - grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttnFunction_fp32(Function): - - @staticmethod - @custom_fwd(cast_inputs=torch.float32) - def forward(ctx, value, value_spatial_shapes, value_level_start_index, - sampling_locations, attention_weights, im2col_step): - """GPU version of multi-scale deformable attention. - - Args: - value (Tensor): The value has shape - (bs, num_keys, mum_heads, embed_dims//num_heads) - value_spatial_shapes (Tensor): Spatial shape of - each feature map, has shape (num_levels, 2), - last dimension 2 represent (h, w) - sampling_locations (Tensor): The location of sampling points, - has shape - (bs ,num_queries, num_heads, num_levels, num_points, 2), - the last dimension 2 represent (x, y). - attention_weights (Tensor): The weight of sampling points used - when calculate the attention, has shape - (bs ,num_queries, num_heads, num_levels, num_points), - im2col_step (Tensor): The step used in image to column. - - Returns: - Tensor: has shape (bs, num_queries, embed_dims) - """ - - ctx.im2col_step = im2col_step - output = ext_module.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - im2col_step=ctx.im2col_step) - ctx.save_for_backward(value, value_spatial_shapes, - value_level_start_index, sampling_locations, - attention_weights) - return output - - @staticmethod - @once_differentiable - @custom_bwd - def backward(ctx, grad_output): - """GPU version of backward function. - - Args: - grad_output (Tensor): Gradient - of output tensor of forward. - - Returns: - Tuple[Tensor]: Gradient - of input tensors in forward. - """ - value, value_spatial_shapes, value_level_start_index, \ - sampling_locations, attention_weights = ctx.saved_tensors - grad_value = torch.zeros_like(value) - grad_sampling_loc = torch.zeros_like(sampling_locations) - grad_attn_weight = torch.zeros_like(attention_weights) - - ext_module.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output.contiguous(), - grad_value, - grad_sampling_loc, - grad_attn_weight, - im2col_step=ctx.im2col_step) - - return grad_value, None, None, \ - grad_sampling_loc, grad_attn_weight, None diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py deleted file mode 100644 index bdebb00fd84139eb25dbc159a5d1a45506278c43..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/spatial_cross_attention.py +++ /dev/null @@ -1,626 +0,0 @@ - -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from mmcv.ops.multi_scale_deform_attn import multi_scale_deformable_attn_pytorch -import warnings -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init, constant_init -from mmcv.cnn.bricks.registry import (ATTENTION, - TRANSFORMER_LAYER, - TRANSFORMER_LAYER_SEQUENCE) -from mmcv.cnn.bricks.transformer import build_attention -import math -from mmcv.runner import force_fp32, auto_fp16 - -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential - -from mmcv.utils import ext_loader -from .multi_scale_deformable_attn_function import MultiScaleDeformableAttnFunction_fp32, \ - MultiScaleDeformableAttnFunction_fp16 -from projects.mmdet3d_plugin.models.utils.bricks import run_time -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - - -@ATTENTION.register_module() -class SpatialCrossAttention(BaseModule): - """An attention module used in BEVFormer. - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_cams (int): The number of cameras - dropout (float): A Dropout layer on `inp_residual`. - Default: 0.. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - deformable_attention: (dict): The config for the deformable attention used in SCA. - """ - - def __init__(self, - embed_dims=256, - num_cams=6, - pc_range=None, - dropout=0.1, - init_cfg=None, - batch_first=False, - deformable_attention=dict( - type='MSDeformableAttention3D', - embed_dims=256, - num_levels=4), - **kwargs - ): - super(SpatialCrossAttention, self).__init__(init_cfg) - - self.init_cfg = init_cfg - self.dropout = nn.Dropout(dropout) - self.pc_range = pc_range - self.fp16_enabled = False - self.deformable_attention = build_attention(deformable_attention) - self.embed_dims = embed_dims - self.num_cams = num_cams - self.output_proj = nn.Linear(embed_dims, embed_dims) - self.batch_first = batch_first - self.init_weight() - - def init_weight(self): - """Default initialization for Parameters of Module.""" - xavier_init(self.output_proj, distribution='uniform', bias=0.) - - @force_fp32(apply_to=('query', 'key', 'value', 'query_pos', 'reference_points_cam')) - def forward(self, - query, - key, - value, - residual=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - reference_points_cam=None, - bev_mask=None, - level_start_index=None, - flag='encoder', - **kwargs): - """Forward Function of Detr3DCrossAtten. - Args: - query (Tensor): Query of Transformer with shape - (num_query, bs, embed_dims). - key (Tensor): The key tensor with shape - `(num_key, bs, embed_dims)`. - value (Tensor): The value tensor with shape - `(num_key, bs, embed_dims)`. (B, N, C, H, W) - residual (Tensor): The tensor used for addition, with the - same shape as `x`. Default None. If None, `x` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, 4), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different level. With shape (num_levels, 2), - last dimension represent (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape (num_levels) and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if key is None: - key = query - if value is None: - value = key - - if residual is None: - inp_residual = query - slots = torch.zeros_like(query) - if query_pos is not None: - query = query + query_pos - - bs, num_query, _ = query.size() - - D = reference_points_cam.size(3) - indexes = [] - for i, mask_per_img in enumerate(bev_mask): - index_query_per_img = mask_per_img[0].sum(-1).nonzero().squeeze(-1) - indexes.append(index_query_per_img) - max_len = max([len(each) for each in indexes]) - - # each camera only interacts with its corresponding BEV queries. This step can greatly save GPU memory. - queries_rebatch = query.new_zeros( - [bs, self.num_cams, max_len, self.embed_dims]) - reference_points_rebatch = reference_points_cam.new_zeros( - [bs, self.num_cams, max_len, D, 2]) - - for j in range(bs): - for i, reference_points_per_img in enumerate(reference_points_cam): - index_query_per_img = indexes[i] - queries_rebatch[j, i, :len(index_query_per_img)] = query[j, index_query_per_img] - reference_points_rebatch[j, i, :len(index_query_per_img)] = reference_points_per_img[j, index_query_per_img] - - num_cams, l, bs, embed_dims = key.shape - - key = key.permute(2, 0, 1, 3).reshape( - bs * self.num_cams, l, self.embed_dims) - value = value.permute(2, 0, 1, 3).reshape( - bs * self.num_cams, l, self.embed_dims) - - queries = self.deformable_attention(query=queries_rebatch.view(bs*self.num_cams, max_len, self.embed_dims), key=key, value=value, - reference_points=reference_points_rebatch.view(bs*self.num_cams, max_len, D, 2), spatial_shapes=spatial_shapes, - level_start_index=level_start_index).view(bs, self.num_cams, max_len, self.embed_dims) - for j in range(bs): - for i, index_query_per_img in enumerate(indexes): - slots[j, index_query_per_img] += queries[j, i, :len(index_query_per_img)] - - count = bev_mask.sum(-1) > 0 - count = count.permute(1, 2, 0).sum(-1) - count = torch.clamp(count, min=1.0) - slots = slots / count[..., None] - slots = self.output_proj(slots) - - return self.dropout(slots) + inp_residual - - -@ATTENTION.register_module() -class MSDeformableAttention3D(BaseModule): - """An attention module used in BEVFormer based on Deformable-Detr. - `Deformable DETR: Deformable Transformers for End-to-End Object Detection. - `_. - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_heads (int): Parallel attention heads. Default: 64. - num_levels (int): The number of feature map used in - Attention. Default: 4. - num_points (int): The number of sampling points for - each query in each head. Default: 4. - im2col_step (int): The step used in image_to_column. - Default: 64. - dropout (float): A Dropout layer on `inp_identity`. - Default: 0.1. - batch_first (bool): Key, Query and Value are shape of - (batch, n, embed_dim) - or (n, batch, embed_dim). Default to False. - norm_cfg (dict): Config dict for normalization layer. - Default: None. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims=256, - num_heads=8, - num_levels=4, - num_points=8, - im2col_step=64, - dropout=0.1, - batch_first=True, - norm_cfg=None, - init_cfg=None): - super().__init__(init_cfg) - if embed_dims % num_heads != 0: - raise ValueError(f'embed_dims must be divisible by num_heads, ' - f'but got {embed_dims} and {num_heads}') - dim_per_head = embed_dims // num_heads - self.norm_cfg = norm_cfg - self.batch_first = batch_first - self.output_proj = None - self.fp16_enabled = False - - # you'd better set dim_per_head to a power of 2 - # which is more efficient in the CUDA implementation - def _is_power_of_2(n): - if (not isinstance(n, int)) or (n < 0): - raise ValueError( - 'invalid input for _is_power_of_2: {} (type: {})'.format( - n, type(n))) - return (n & (n - 1) == 0) and n != 0 - - if not _is_power_of_2(dim_per_head): - warnings.warn( - "You'd better set embed_dims in " - 'MultiScaleDeformAttention to make ' - 'the dimension of each attention head a power of 2 ' - 'which is more efficient in our CUDA implementation.') - - self.im2col_step = im2col_step - self.embed_dims = embed_dims - self.num_levels = num_levels - self.num_heads = num_heads - self.num_points = num_points - self.sampling_offsets = nn.Linear( - embed_dims, num_heads * num_levels * num_points * 2) - self.attention_weights = nn.Linear(embed_dims, - num_heads * num_levels * num_points) - self.value_proj = nn.Linear(embed_dims, embed_dims) - - self.init_weights() - - def init_weights(self): - """Default initialization for Parameters of Module.""" - constant_init(self.sampling_offsets, 0.) - thetas = torch.arange( - self.num_heads, - dtype=torch.float32) * (2.0 * math.pi / self.num_heads) - grid_init = torch.stack([thetas.cos(), thetas.sin()], -1) - grid_init = (grid_init / - grid_init.abs().max(-1, keepdim=True)[0]).view( - self.num_heads, 1, 1, - 2).repeat(1, self.num_levels, self.num_points, 1) - for i in range(self.num_points): - grid_init[:, :, i, :] *= i + 1 - - self.sampling_offsets.bias.data = grid_init.view(-1) - constant_init(self.attention_weights, val=0., bias=0.) - xavier_init(self.value_proj, distribution='uniform', bias=0.) - xavier_init(self.output_proj, distribution='uniform', bias=0.) - self._is_init = True - - def forward(self, - query, - key=None, - value=None, - identity=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - level_start_index=None, - **kwargs): - """Forward Function of MultiScaleDeformAttention. - Args: - query (Tensor): Query of Transformer with shape - ( bs, num_query, embed_dims). - key (Tensor): The key tensor with shape - `(bs, num_key, embed_dims)`. - value (Tensor): The value tensor with shape - `(bs, num_key, embed_dims)`. - identity (Tensor): The tensor used for addition, with the - same shape as `query`. Default None. If None, - `query` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, num_levels, 2), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different levels. With shape (num_levels, 2), - last dimension represents (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape ``(num_levels, )`` and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if value is None: - value = query - if identity is None: - identity = query - if query_pos is not None: - query = query + query_pos - - if not self.batch_first: - # change to (bs, num_query ,embed_dims) - query = query.permute(1, 0, 2) - value = value.permute(1, 0, 2) - - bs, num_query, _ = query.shape - bs, num_value, _ = value.shape - assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value - - value = self.value_proj(value) - if key_padding_mask is not None: - value = value.masked_fill(key_padding_mask[..., None], 0.0) - value = value.view(bs, num_value, self.num_heads, -1) - sampling_offsets = self.sampling_offsets(query).view( - bs, num_query, self.num_heads, self.num_levels, self.num_points, 2) - attention_weights = self.attention_weights(query).view( - bs, num_query, self.num_heads, self.num_levels * self.num_points) - - attention_weights = attention_weights.softmax(-1) - - attention_weights = attention_weights.view(bs, num_query, - self.num_heads, - self.num_levels, - self.num_points) - - if reference_points.shape[-1] == 2: - """ - For each BEV query, it owns `num_Z_anchors` in 3D space that having different heights. - After proejcting, each BEV query has `num_Z_anchors` reference points in each 2D image. - For each referent point, we sample `num_points` sampling points. - For `num_Z_anchors` reference points, it has overall `num_points * num_Z_anchors` sampling points. - """ - offset_normalizer = torch.stack( - [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1) - - bs, num_query, num_Z_anchors, xy = reference_points.shape - reference_points = reference_points[:, :, None, None, None, :, :] - sampling_offsets = sampling_offsets / \ - offset_normalizer[None, None, None, :, None, :] - bs, num_query, num_heads, num_levels, num_all_points, xy = sampling_offsets.shape - sampling_offsets = sampling_offsets.view( - bs, num_query, num_heads, num_levels, num_all_points // num_Z_anchors, num_Z_anchors, xy) - sampling_locations = reference_points + sampling_offsets - bs, num_query, num_heads, num_levels, num_points, num_Z_anchors, xy = sampling_locations.shape - assert num_all_points == num_points * num_Z_anchors - - sampling_locations = sampling_locations.view( - bs, num_query, num_heads, num_levels, num_all_points, xy) - - elif reference_points.shape[-1] == 4: - assert False - else: - raise ValueError( - f'Last dim of reference_points must be' - f' 2 or 4, but get {reference_points.shape[-1]} instead.') - - # sampling_locations.shape: bs, num_query, num_heads, num_levels, num_all_points, 2 - # attention_weights.shape: bs, num_query, num_heads, num_levels, num_all_points - # - - if torch.cuda.is_available() and value.is_cuda: - if value.dtype == torch.float16: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - else: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - output = MultiScaleDeformableAttnFunction.apply( - value, spatial_shapes, level_start_index, sampling_locations, - attention_weights, self.im2col_step) - else: - output = multi_scale_deformable_attn_pytorch( - value, spatial_shapes, sampling_locations, attention_weights) - if not self.batch_first: - output = output.permute(1, 0, 2) - - return output - - - -@ATTENTION.register_module() -class MSIPM3D(BaseModule): - """An attention module used in BEVFormer based on Deformable-Detr. - `Deformable DETR: Deformable Transformers for End-to-End Object Detection. - `_. - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_heads (int): Parallel attention heads. Default: 64. - num_levels (int): The number of feature map used in - Attention. Default: 4. - num_points (int): The number of sampling points for - each query in each head. Default: 4. - im2col_step (int): The step used in image_to_column. - Default: 64. - dropout (float): A Dropout layer on `inp_identity`. - Default: 0.1. - batch_first (bool): Key, Query and Value are shape of - (batch, n, embed_dim) - or (n, batch, embed_dim). Default to False. - norm_cfg (dict): Config dict for normalization layer. - Default: None. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims=256, - num_heads=8, - num_levels=4, - num_points=8, - im2col_step=64, - dropout=0.1, - batch_first=True, - norm_cfg=None, - init_cfg=None): - super().__init__(init_cfg) - if embed_dims % num_heads != 0: - raise ValueError(f'embed_dims must be divisible by num_heads, ' - f'but got {embed_dims} and {num_heads}') - dim_per_head = embed_dims // num_heads - self.norm_cfg = norm_cfg - self.batch_first = batch_first - self.output_proj = None - self.fp16_enabled = False - - # you'd better set dim_per_head to a power of 2 - # which is more efficient in the CUDA implementation - def _is_power_of_2(n): - if (not isinstance(n, int)) or (n < 0): - raise ValueError( - 'invalid input for _is_power_of_2: {} (type: {})'.format( - n, type(n))) - return (n & (n - 1) == 0) and n != 0 - - if not _is_power_of_2(dim_per_head): - warnings.warn( - "You'd better set embed_dims in " - 'MultiScaleDeformAttention to make ' - 'the dimension of each attention head a power of 2 ' - 'which is more efficient in our CUDA implementation.') - - self.im2col_step = im2col_step - self.embed_dims = embed_dims - self.num_levels = num_levels - self.num_heads = num_heads - self.num_points = num_points - # self.sampling_offsets = nn.Linear( - # embed_dims, num_heads * num_levels * num_points * 2) - # self.attention_weights = nn.Linear(embed_dims, - # num_heads * num_levels * num_points) - self.value_proj = nn.Linear(embed_dims, embed_dims) - - self.init_weights() - - def init_weights(self): - """Default initialization for Parameters of Module.""" - # constant_init(self.sampling_offsets, 0.) - thetas = torch.arange( - self.num_heads, - dtype=torch.float32) * (2.0 * math.pi / self.num_heads) - grid_init = torch.stack([thetas.cos(), thetas.sin()], -1) - grid_init = (grid_init / - grid_init.abs().max(-1, keepdim=True)[0]).view( - self.num_heads, 1, 1, - 2).repeat(1, self.num_levels, self.num_points, 1) - for i in range(self.num_points): - grid_init[:, :, i, :] *= i + 1 - - # self.sampling_offsets.bias.data = grid_init.view(-1) - self.fixed_sampling_offsets = nn.Parameter(grid_init.view(-1), requires_grad=False) - # constant_init(self.attention_weights, val=0., bias=0.) - xavier_init(self.value_proj, distribution='uniform', bias=0.) - xavier_init(self.output_proj, distribution='uniform', bias=0.) - self._is_init = True - - def forward(self, - query, - key=None, - value=None, - identity=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - level_start_index=None, - **kwargs): - """Forward Function of MultiScaleDeformAttention. - Args: - query (Tensor): Query of Transformer with shape - ( bs, num_query, embed_dims). - key (Tensor): The key tensor with shape - `(bs, num_key, embed_dims)`. - value (Tensor): The value tensor with shape - `(bs, num_key, embed_dims)`. - identity (Tensor): The tensor used for addition, with the - same shape as `query`. Default None. If None, - `query` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, num_levels, 2), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different levels. With shape (num_levels, 2), - last dimension represents (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape ``(num_levels, )`` and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if value is None: - value = query - if identity is None: - identity = query - if query_pos is not None: - query = query + query_pos - - if not self.batch_first: - # change to (bs, num_query ,embed_dims) - query = query.permute(1, 0, 2) - value = value.permute(1, 0, 2) - - bs, num_query, _ = query.shape - bs, num_value, _ = value.shape - assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value - - value = self.value_proj(value) - if key_padding_mask is not None: - value = value.masked_fill(key_padding_mask[..., None], 0.0) - value = value.view(bs, num_value, self.num_heads, -1) - sampling_offsets = self.fixed_sampling_offsets.view( - 1, 1, self.num_heads, self.num_levels, self.num_points, 2).repeat( - bs, num_query, 1, 1, 1,1) - # attention_weights = self.attention_weights(query).view( - # bs, num_query, self.num_heads, self.num_levels * self.num_points) - attention_weights = query.new_ones((bs, num_query, self.num_heads, self.num_levels * self.num_points)) - attention_weights = attention_weights.softmax(-1) - # import pdb;pdb.set_trace() - attention_weights = attention_weights.view(bs, num_query, - self.num_heads, - self.num_levels, - self.num_points) - - if reference_points.shape[-1] == 2: - """ - For each BEV query, it owns `num_Z_anchors` in 3D space that having different heights. - After proejcting, each BEV query has `num_Z_anchors` reference points in each 2D image. - For each referent point, we sample `num_points` sampling points. - For `num_Z_anchors` reference points, it has overall `num_points * num_Z_anchors` sampling points. - """ - offset_normalizer = torch.stack( - [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1) - - bs, num_query, num_Z_anchors, xy = reference_points.shape - reference_points = reference_points[:, :, None, None, None, :, :] - sampling_offsets = sampling_offsets / \ - offset_normalizer[None, None, None, :, None, :] - bs, num_query, num_heads, num_levels, num_all_points, xy = sampling_offsets.shape - sampling_offsets = sampling_offsets.view( - bs, num_query, num_heads, num_levels, num_all_points // num_Z_anchors, num_Z_anchors, xy) - sampling_locations = reference_points + sampling_offsets - bs, num_query, num_heads, num_levels, num_points, num_Z_anchors, xy = sampling_locations.shape - assert num_all_points == num_points * num_Z_anchors - - sampling_locations = sampling_locations.view( - bs, num_query, num_heads, num_levels, num_all_points, xy) - - elif reference_points.shape[-1] == 4: - assert False - else: - raise ValueError( - f'Last dim of reference_points must be' - f' 2 or 4, but get {reference_points.shape[-1]} instead.') - - # sampling_locations.shape: bs, num_query, num_heads, num_levels, num_all_points, 2 - # attention_weights.shape: bs, num_query, num_heads, num_levels, num_all_points - # - - if torch.cuda.is_available() and value.is_cuda: - if value.dtype == torch.float16: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - else: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - output = MultiScaleDeformableAttnFunction.apply( - value, spatial_shapes, level_start_index, sampling_locations, - attention_weights, self.im2col_step) - else: - output = multi_scale_deformable_attn_pytorch( - value, spatial_shapes, sampling_locations, attention_weights) - if not self.batch_first: - output = output.permute(1, 0, 2) - - return output diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/temporal_self_attention.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/temporal_self_attention.py deleted file mode 100644 index 78fb9f529c925d1a4f74f1cc1f83de6b1cb20f67..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/modules/temporal_self_attention.py +++ /dev/null @@ -1,272 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -from projects.mmdet3d_plugin.models.utils.bricks import run_time -from .multi_scale_deformable_attn_function import MultiScaleDeformableAttnFunction_fp32 -from mmcv.ops.multi_scale_deform_attn import multi_scale_deformable_attn_pytorch -import warnings -import torch -import torch.nn as nn -from mmcv.cnn import xavier_init, constant_init -from mmcv.cnn.bricks.registry import ATTENTION -import math -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential -from mmcv.utils import (ConfigDict, build_from_cfg, deprecated_api_warning, - to_2tuple) - -from mmcv.utils import ext_loader -ext_module = ext_loader.load_ext( - '_ext', ['ms_deform_attn_backward', 'ms_deform_attn_forward']) - - -@ATTENTION.register_module() -class TemporalSelfAttention(BaseModule): - """An attention module used in BEVFormer based on Deformable-Detr. - - `Deformable DETR: Deformable Transformers for End-to-End Object Detection. - `_. - - Args: - embed_dims (int): The embedding dimension of Attention. - Default: 256. - num_heads (int): Parallel attention heads. Default: 64. - num_levels (int): The number of feature map used in - Attention. Default: 4. - num_points (int): The number of sampling points for - each query in each head. Default: 4. - im2col_step (int): The step used in image_to_column. - Default: 64. - dropout (float): A Dropout layer on `inp_identity`. - Default: 0.1. - batch_first (bool): Key, Query and Value are shape of - (batch, n, embed_dim) - or (n, batch, embed_dim). Default to True. - norm_cfg (dict): Config dict for normalization layer. - Default: None. - init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. - Default: None. - num_bev_queue (int): In this version, we only use one history BEV and one currenct BEV. - the length of BEV queue is 2. - """ - - def __init__(self, - embed_dims=256, - num_heads=8, - num_levels=4, - num_points=4, - num_bev_queue=2, - im2col_step=64, - dropout=0.1, - batch_first=True, - norm_cfg=None, - init_cfg=None): - - super().__init__(init_cfg) - if embed_dims % num_heads != 0: - raise ValueError(f'embed_dims must be divisible by num_heads, ' - f'but got {embed_dims} and {num_heads}') - dim_per_head = embed_dims // num_heads - self.norm_cfg = norm_cfg - self.dropout = nn.Dropout(dropout) - self.batch_first = batch_first - self.fp16_enabled = False - - # you'd better set dim_per_head to a power of 2 - # which is more efficient in the CUDA implementation - def _is_power_of_2(n): - if (not isinstance(n, int)) or (n < 0): - raise ValueError( - 'invalid input for _is_power_of_2: {} (type: {})'.format( - n, type(n))) - return (n & (n - 1) == 0) and n != 0 - - if not _is_power_of_2(dim_per_head): - warnings.warn( - "You'd better set embed_dims in " - 'MultiScaleDeformAttention to make ' - 'the dimension of each attention head a power of 2 ' - 'which is more efficient in our CUDA implementation.') - - self.im2col_step = im2col_step - self.embed_dims = embed_dims - self.num_levels = num_levels - self.num_heads = num_heads - self.num_points = num_points - self.num_bev_queue = num_bev_queue - self.sampling_offsets = nn.Linear( - embed_dims*self.num_bev_queue, num_bev_queue*num_heads * num_levels * num_points * 2) - self.attention_weights = nn.Linear(embed_dims*self.num_bev_queue, - num_bev_queue*num_heads * num_levels * num_points) - self.value_proj = nn.Linear(embed_dims, embed_dims) - self.output_proj = nn.Linear(embed_dims, embed_dims) - self.init_weights() - - def init_weights(self): - """Default initialization for Parameters of Module.""" - constant_init(self.sampling_offsets, 0.) - thetas = torch.arange( - self.num_heads, - dtype=torch.float32) * (2.0 * math.pi / self.num_heads) - grid_init = torch.stack([thetas.cos(), thetas.sin()], -1) - grid_init = (grid_init / - grid_init.abs().max(-1, keepdim=True)[0]).view( - self.num_heads, 1, 1, - 2).repeat(1, self.num_levels*self.num_bev_queue, self.num_points, 1) - - for i in range(self.num_points): - grid_init[:, :, i, :] *= i + 1 - - self.sampling_offsets.bias.data = grid_init.view(-1) - constant_init(self.attention_weights, val=0., bias=0.) - xavier_init(self.value_proj, distribution='uniform', bias=0.) - xavier_init(self.output_proj, distribution='uniform', bias=0.) - self._is_init = True - - def forward(self, - query, - key=None, - value=None, - identity=None, - query_pos=None, - key_padding_mask=None, - reference_points=None, - spatial_shapes=None, - level_start_index=None, - flag='decoder', - - **kwargs): - """Forward Function of MultiScaleDeformAttention. - - Args: - query (Tensor): Query of Transformer with shape - (num_query, bs, embed_dims). - key (Tensor): The key tensor with shape - `(num_key, bs, embed_dims)`. - value (Tensor): The value tensor with shape - `(num_key, bs, embed_dims)`. - identity (Tensor): The tensor used for addition, with the - same shape as `query`. Default None. If None, - `query` will be used. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. Default - None. - reference_points (Tensor): The normalized reference - points with shape (bs, num_query, num_levels, 2), - all elements is range in [0, 1], top-left (0,0), - bottom-right (1, 1), including padding area. - or (N, Length_{query}, num_levels, 4), add - additional two dimensions is (w, h) to - form reference boxes. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_key]. - spatial_shapes (Tensor): Spatial shape of features in - different levels. With shape (num_levels, 2), - last dimension represents (h, w). - level_start_index (Tensor): The start index of each level. - A tensor has shape ``(num_levels, )`` and can be represented - as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...]. - - Returns: - Tensor: forwarded results with shape [num_query, bs, embed_dims]. - """ - - if value is None: - assert self.batch_first - bs, len_bev, c = query.shape - value = torch.stack([query, query], 1).reshape(bs*2, len_bev, c) - - # value = torch.cat([query, query], 0) - - if identity is None: - identity = query - if query_pos is not None: - query = query + query_pos - if not self.batch_first: - # change to (bs, num_query ,embed_dims) - query = query.permute(1, 0, 2) - value = value.permute(1, 0, 2) - bs, num_query, embed_dims = query.shape - _, num_value, _ = value.shape - assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value - assert self.num_bev_queue == 2 - - query = torch.cat([value[:bs], query], -1) - value = self.value_proj(value) - - if key_padding_mask is not None: - value = value.masked_fill(key_padding_mask[..., None], 0.0) - - value = value.reshape(bs*self.num_bev_queue, - num_value, self.num_heads, -1) - - sampling_offsets = self.sampling_offsets(query) - sampling_offsets = sampling_offsets.view( - bs, num_query, self.num_heads, self.num_bev_queue, self.num_levels, self.num_points, 2) - attention_weights = self.attention_weights(query).view( - bs, num_query, self.num_heads, self.num_bev_queue, self.num_levels * self.num_points) - attention_weights = attention_weights.softmax(-1) - - attention_weights = attention_weights.view(bs, num_query, - self.num_heads, - self.num_bev_queue, - self.num_levels, - self.num_points) - - attention_weights = attention_weights.permute(0, 3, 1, 2, 4, 5)\ - .reshape(bs*self.num_bev_queue, num_query, self.num_heads, self.num_levels, self.num_points).contiguous() - sampling_offsets = sampling_offsets.permute(0, 3, 1, 2, 4, 5, 6)\ - .reshape(bs*self.num_bev_queue, num_query, self.num_heads, self.num_levels, self.num_points, 2) - - if reference_points.shape[-1] == 2: - offset_normalizer = torch.stack( - [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1) - sampling_locations = reference_points[:, :, None, :, None, :] \ - + sampling_offsets \ - / offset_normalizer[None, None, None, :, None, :] - - elif reference_points.shape[-1] == 4: - sampling_locations = reference_points[:, :, None, :, None, :2] \ - + sampling_offsets / self.num_points \ - * reference_points[:, :, None, :, None, 2:] \ - * 0.5 - else: - raise ValueError( - f'Last dim of reference_points must be' - f' 2 or 4, but get {reference_points.shape[-1]} instead.') - if torch.cuda.is_available() and value.is_cuda: - - # using fp16 deformable attention is unstable because it performs many sum operations - if value.dtype == torch.float16: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - else: - MultiScaleDeformableAttnFunction = MultiScaleDeformableAttnFunction_fp32 - output = MultiScaleDeformableAttnFunction.apply( - value, spatial_shapes, level_start_index, sampling_locations, - attention_weights, self.im2col_step) - else: - - output = multi_scale_deformable_attn_pytorch( - value, spatial_shapes, sampling_locations, attention_weights) - - # output shape (bs*num_bev_queue, num_query, embed_dims) - # (bs*num_bev_queue, num_query, embed_dims)-> (num_query, embed_dims, bs*num_bev_queue) - output = output.permute(1, 2, 0) - - # fuse history value and current value - # (num_query, embed_dims, bs*num_bev_queue)-> (num_query, embed_dims, bs, num_bev_queue) - output = output.view(num_query, embed_dims, bs, self.num_bev_queue) - output = output.mean(-1) - - # (num_query, embed_dims, bs)-> (bs, num_query, embed_dims) - output = output.permute(2, 0, 1) - - output = self.output_proj(output) - - if not self.batch_first: - output = output.permute(1, 0, 2) - - return self.dropout(output) + identity diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/__init__.py deleted file mode 100644 index 03f906ce601e2dfac207af680774086067808830..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .epoch_based_runner import EpochBasedRunner_video \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py deleted file mode 100644 index e73e5e7873f831b3c6e0f19715d950701b65fa25..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/bevformer/runner/epoch_based_runner.py +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- - -import os.path as osp -import torch -import mmcv -from mmcv.runner.base_runner import BaseRunner -from mmcv.runner.epoch_based_runner import EpochBasedRunner -from mmcv.runner.builder import RUNNERS -from mmcv.runner.checkpoint import save_checkpoint -from mmcv.runner.utils import get_host_info -from pprint import pprint -from mmcv.parallel.data_container import DataContainer - - -@RUNNERS.register_module() -class EpochBasedRunner_video(EpochBasedRunner): - - ''' - # basic logic - - input_sequence = [a, b, c] # given a sequence of samples - - prev_bev = None - for each in input_sequcene[:-1] - prev_bev = eval_model(each, prev_bev)) # inference only. - - model(input_sequcene[-1], prev_bev) # train the last sample. - ''' - - def __init__(self, - model, - eval_model=None, - batch_processor=None, - optimizer=None, - work_dir=None, - logger=None, - meta=None, - keys=['gt_bboxes_3d', 'gt_labels_3d', 'img'], - max_iters=None, - max_epochs=None): - super().__init__(model, - batch_processor, - optimizer, - work_dir, - logger, - meta, - max_iters, - max_epochs) - keys.append('img_metas') - self.keys = keys - self.eval_model = eval_model - self.eval_model.eval() - - def run_iter(self, data_batch, train_mode, **kwargs): - if self.batch_processor is not None: - assert False - # outputs = self.batch_processor( - # self.model, data_batch, train_mode=train_mode, **kwargs) - elif train_mode: - - num_samples = data_batch['img'].data[0].size(1) - data_list = [] - prev_bev = None - for i in range(num_samples): - data = {} - for key in self.keys: - if key not in ['img_metas', 'img', 'points']: - data[key] = data_batch[key] - else: - if key == 'img': - data['img'] = DataContainer(data=[data_batch['img'].data[0][:, i]], cpu_only=data_batch['img'].cpu_only, stack=True) - elif key == 'img_metas': - data['img_metas'] = DataContainer(data=[[each[i] for each in data_batch['img_metas'].data[0]]], cpu_only=data_batch['img_metas'].cpu_only) - else: - assert False - data_list.append(data) - with torch.no_grad(): - for i in range(num_samples-1): - if i>0: data_list[i]['prev_bev'] = DataContainer(data=[prev_bev], cpu_only=False) - prev_bev = self.eval_model.val_step(data_list[i], self.optimizer, **kwargs) - - data_list[-1]['prev_bev'] = DataContainer(data=[prev_bev], cpu_only=False) - outputs = self.model.train_step(data_list[-1], self.optimizer, **kwargs) - else: - assert False - # outputs = self.model.val_step(data_batch, self.optimizer, **kwargs) - - if not isinstance(outputs, dict): - raise TypeError('"batch_processor()" or "model.train_step()"' - 'and "model.val_step()" must return a dict') - if 'log_vars' in outputs: - self.log_buffer.update(outputs['log_vars'], outputs['num_samples']) - self.outputs = outputs \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py deleted file mode 100644 index 583fcab72f6b2bbf20bda90b8f877cc1f81072d9..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/assigners/hungarian_assigner_3d.py +++ /dev/null @@ -1,136 +0,0 @@ -import torch - -from mmdet.core.bbox.builder import BBOX_ASSIGNERS -from mmdet.core.bbox.assigners import AssignResult -from mmdet.core.bbox.assigners import BaseAssigner -from mmdet.core.bbox.match_costs import build_match_cost -from mmdet.models.utils.transformer import inverse_sigmoid -from projects.mmdet3d_plugin.core.bbox.util import normalize_bbox - -try: - from scipy.optimize import linear_sum_assignment -except ImportError: - linear_sum_assignment = None - - -@BBOX_ASSIGNERS.register_module() -class HungarianAssigner3D(BaseAssigner): - """Computes one-to-one matching between predictions and ground truth. - This class computes an assignment between the targets and the predictions - based on the costs. The costs are weighted sum of three components: - classification cost, regression L1 cost and regression iou cost. The - targets don't include the no_object, so generally there are more - predictions than targets. After the one-to-one matching, the un-matched - are treated as backgrounds. Thus each query prediction will be assigned - with `0` or a positive integer indicating the ground truth index: - - 0: negative sample, no assigned gt - - positive integer: positive sample, index (1-based) of assigned gt - Args: - cls_weight (int | float, optional): The scale factor for classification - cost. Default 1.0. - bbox_weight (int | float, optional): The scale factor for regression - L1 cost. Default 1.0. - iou_weight (int | float, optional): The scale factor for regression - iou cost. Default 1.0. - iou_calculator (dict | optional): The config for the iou calculation. - Default type `BboxOverlaps2D`. - iou_mode (str | optional): "iou" (intersection over union), "iof" - (intersection over foreground), or "giou" (generalized - intersection over union). Default "giou". - """ - - def __init__(self, - cls_cost=dict(type='ClassificationCost', weight=1.), - reg_cost=dict(type='BBoxL1Cost', weight=1.0), - iou_cost=dict(type='IoUCost', weight=0.0), - pc_range=None): - self.cls_cost = build_match_cost(cls_cost) - self.reg_cost = build_match_cost(reg_cost) - self.iou_cost = build_match_cost(iou_cost) - self.pc_range = pc_range - - def assign(self, - bbox_pred, - cls_pred, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - eps=1e-7): - """Computes one-to-one matching based on the weighted costs. - This method assign each query prediction to a ground truth or - background. The `assigned_gt_inds` with -1 means don't care, - 0 means negative sample, and positive number is the index (1-based) - of assigned gt. - The assignment is done in the following steps, the order matters. - 1. assign every prediction to -1 - 2. compute the weighted costs - 3. do Hungarian matching on CPU based on the costs - 4. assign all to 0 (background) first, then for each matched pair - between predictions and gts, treat this prediction as foreground - and assign the corresponding gt index (plus 1) to it. - Args: - bbox_pred (Tensor): Predicted boxes with normalized coordinates - (cx, cy, w, h), which are all in range [0, 1]. Shape - [num_query, 4]. - cls_pred (Tensor): Predicted classification logits, shape - [num_query, num_class]. - gt_bboxes (Tensor): Ground truth boxes with unnormalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). - gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are - labelled as `ignored`. Default None. - eps (int | float, optional): A value added to the denominator for - numerical stability. Default 1e-7. - Returns: - :obj:`AssignResult`: The assigned result. - """ - assert gt_bboxes_ignore is None, \ - 'Only case when gt_bboxes_ignore is None is supported.' - num_gts, num_bboxes = gt_bboxes.size(0), bbox_pred.size(0) - - # 1. assign -1 by default - assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - assigned_labels = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - if num_gts == 0 or num_bboxes == 0: - # No ground truth or boxes, return empty assignment - if num_gts == 0: - # No ground truth, assign all to background - assigned_gt_inds[:] = 0 - return AssignResult( - num_gts, assigned_gt_inds, None, labels=assigned_labels) - - # 2. compute the weighted costs - # classification and bboxcost. - cls_cost = self.cls_cost(cls_pred, gt_labels) - # regression L1 cost - - normalized_gt_bboxes = normalize_bbox(gt_bboxes, self.pc_range) - - reg_cost = self.reg_cost(bbox_pred[:, :8], normalized_gt_bboxes[:, :8]) - - # weighted sum of above two costs - cost = cls_cost + reg_cost - - # 3. do Hungarian matching on CPU using linear_sum_assignment - cost = cost.detach().cpu() - if linear_sum_assignment is None: - raise ImportError('Please run "pip install scipy" ' - 'to install scipy first.') - matched_row_inds, matched_col_inds = linear_sum_assignment(cost) - matched_row_inds = torch.from_numpy(matched_row_inds).to( - bbox_pred.device) - matched_col_inds = torch.from_numpy(matched_col_inds).to( - bbox_pred.device) - - # 4. assign backgrounds and foregrounds - # assign all indices to backgrounds first - assigned_gt_inds[:] = 0 - # assign foregrounds based on matching results - assigned_gt_inds[matched_row_inds] = matched_col_inds + 1 - assigned_labels[matched_row_inds] = gt_labels[matched_col_inds] - return AssignResult( - num_gts, assigned_gt_inds, None, labels=assigned_labels) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py deleted file mode 100644 index a6882290ff6813c291a375045e3a43d6a2b50590..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/coders/nms_free_coder.py +++ /dev/null @@ -1,313 +0,0 @@ -import torch - -from mmdet.core.bbox import BaseBBoxCoder -from mmdet.core.bbox.builder import BBOX_CODERS -from projects.mmdet3d_plugin.core.bbox.util import denormalize_bbox -import numpy as np -from mmdet.core.bbox.transforms import bbox_xyxy_to_cxcywh, bbox_cxcywh_to_xyxy - -def denormalize_3d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - new_pts[...,2:3] = (pts[...,2:3]*(pc_range[5] - - pc_range[2]) + pc_range[2]) - return new_pts - -def normalize_3d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - patch_z = pc_range[5]-pc_range[2] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - new_pts[...,2:3] = pts[...,2:3] - pc_range[2] - factor = pts.new_tensor([patch_w, patch_h,patch_z]) - normalized_pts = new_pts / factor - return normalized_pts - - -def normalize_2d_bbox(bboxes, pc_range): - - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - cxcywh_bboxes = bbox_xyxy_to_cxcywh(bboxes) - cxcywh_bboxes[...,0:1] = cxcywh_bboxes[..., 0:1] - pc_range[0] - cxcywh_bboxes[...,1:2] = cxcywh_bboxes[...,1:2] - pc_range[1] - factor = bboxes.new_tensor([patch_w, patch_h,patch_w,patch_h]) - - normalized_bboxes = cxcywh_bboxes / factor - return normalized_bboxes - -def normalize_2d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - factor = pts.new_tensor([patch_w, patch_h]) - normalized_pts = new_pts / factor - return normalized_pts - -def denormalize_2d_bbox(bboxes, pc_range): - - bboxes = bbox_cxcywh_to_xyxy(bboxes) - bboxes[..., 0::2] = (bboxes[..., 0::2]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - bboxes[..., 1::2] = (bboxes[..., 1::2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - - return bboxes -def denormalize_2d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - return new_pts - -@BBOX_CODERS.register_module() -class NMSFreeCoder(BaseBBoxCoder): - """Bbox coder for NMS-free detector. - Args: - pc_range (list[float]): Range of point cloud. - post_center_range (list[float]): Limit of the center. - Default: None. - max_num (int): Max number to be kept. Default: 100. - score_threshold (float): Threshold to filter boxes based on score. - Default: None. - code_size (int): Code size of bboxes. Default: 9 - """ - - def __init__(self, - pc_range, - voxel_size=None, - post_center_range=None, - max_num=100, - score_threshold=None, - num_classes=10): - self.pc_range = pc_range - self.voxel_size = voxel_size - self.post_center_range = post_center_range - self.max_num = max_num - self.score_threshold = score_threshold - self.num_classes = num_classes - - def encode(self): - - pass - - def decode_single(self, cls_scores, bbox_preds): - """Decode bboxes. - Args: - cls_scores (Tensor): Outputs from the classification head, \ - shape [num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - bbox_preds (Tensor): Outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [num_query, 9]. - Returns: - list[dict]: Decoded boxes. - """ - max_num = self.max_num - - cls_scores = cls_scores.sigmoid() - scores, indexs = cls_scores.view(-1).topk(max_num) - labels = indexs % self.num_classes - bbox_index = indexs // self.num_classes - bbox_preds = bbox_preds[bbox_index] - - final_box_preds = denormalize_bbox(bbox_preds, self.pc_range) - final_scores = scores - final_preds = labels - - # use score threshold - if self.score_threshold is not None: - thresh_mask = final_scores > self.score_threshold - tmp_score = self.score_threshold - while thresh_mask.sum() == 0: - tmp_score *= 0.9 - if tmp_score < 0.01: - thresh_mask = final_scores > -1 - break - thresh_mask = final_scores >= tmp_score - - if self.post_center_range is not None: - self.post_center_range = torch.tensor( - self.post_center_range, device=scores.device) - mask = (final_box_preds[..., :3] >= - self.post_center_range[:3]).all(1) - mask &= (final_box_preds[..., :3] <= - self.post_center_range[3:]).all(1) - - if self.score_threshold: - mask &= thresh_mask - - boxes3d = final_box_preds[mask] - scores = final_scores[mask] - - labels = final_preds[mask] - predictions_dict = { - 'bboxes': boxes3d, - 'scores': scores, - 'labels': labels - } - - else: - raise NotImplementedError( - 'Need to reorganize output as a batch, only ' - 'support post_center_range is not None for now!') - return predictions_dict - - def decode(self, preds_dicts): - """Decode bboxes. - Args: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - Returns: - list[dict]: Decoded boxes. - """ - all_cls_scores = preds_dicts['all_cls_scores'][-1] - all_bbox_preds = preds_dicts['all_bbox_preds'][-1] - - batch_size = all_cls_scores.size()[0] - predictions_list = [] - for i in range(batch_size): - predictions_list.append(self.decode_single(all_cls_scores[i], all_bbox_preds[i])) - return predictions_list - - -@BBOX_CODERS.register_module() -class MapTRNMSFreeCoder(BaseBBoxCoder): - """Bbox coder for NMS-free detector. - Args: - pc_range (list[float]): Range of point cloud. - post_center_range (list[float]): Limit of the center. - Default: None. - max_num (int): Max number to be kept. Default: 100. - score_threshold (float): Threshold to filter boxes based on score. - Default: None. - code_size (int): Code size of bboxes. Default: 9 - """ - - def __init__(self, - pc_range, - z_cfg = dict( - pred_z_flag=False, - gt_z_flag=False, - ), - voxel_size=None, - post_center_range=None, - max_num=100, - score_threshold=None, - num_classes=10): - self.pc_range = pc_range - self.voxel_size = voxel_size - self.post_center_range = post_center_range - self.max_num = max_num - self.score_threshold = score_threshold - self.num_classes = num_classes - - self.z_cfg = z_cfg - - def encode(self): - - pass - - def decode_single(self, cls_scores, bbox_preds, pts_preds): - """Decode bboxes. - Args: - cls_scores (Tensor): Outputs from the classification head, \ - shape [num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - bbox_preds (Tensor): Outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [num_query, 9]. - pts_preds (Tensor): - Shape [num_query, fixed_num_pts, 2] - Returns: - list[dict]: Decoded boxes. - """ - max_num = self.max_num - - cls_scores = cls_scores.sigmoid() - scores, indexs = cls_scores.view(-1).topk(max_num) - labels = indexs % self.num_classes - bbox_index = indexs // self.num_classes - bbox_preds = bbox_preds[bbox_index] - pts_preds = pts_preds[bbox_index] - - final_box_preds = denormalize_2d_bbox(bbox_preds, self.pc_range) - #num_q,num_p,2 - final_pts_preds = denormalize_2d_pts(pts_preds, self.pc_range) if not self.z_cfg['gt_z_flag'] \ - else denormalize_3d_pts(pts_preds, self.pc_range) - # final_box_preds = bbox_preds - final_scores = scores - final_preds = labels - - # use score threshold - if self.score_threshold is not None: - thresh_mask = final_scores > self.score_threshold - tmp_score = self.score_threshold - while thresh_mask.sum() == 0: - tmp_score *= 0.9 - if tmp_score < 0.01: - thresh_mask = final_scores > -1 - break - thresh_mask = final_scores >= tmp_score - - if self.post_center_range is not None: - self.post_center_range = torch.tensor( - self.post_center_range, device=scores.device) - mask = (final_box_preds[..., :4] >= - self.post_center_range[:4]).all(1) - mask &= (final_box_preds[..., :4] <= - self.post_center_range[4:]).all(1) - - if self.score_threshold: - mask &= thresh_mask - - boxes3d = final_box_preds[mask] - scores = final_scores[mask] - pts = final_pts_preds[mask] - labels = final_preds[mask] - predictions_dict = { - 'bboxes': boxes3d, - 'scores': scores, - 'labels': labels, - 'pts': pts, - } - - else: - raise NotImplementedError( - 'Need to reorganize output as a batch, only ' - 'support post_center_range is not None for now!') - return predictions_dict - - def decode(self, preds_dicts): - """Decode bboxes. - Args: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - Returns: - list[dict]: Decoded boxes. - """ - all_cls_scores = preds_dicts['all_cls_scores'][-1] - all_bbox_preds = preds_dicts['all_bbox_preds'][-1] - all_pts_preds = preds_dicts['all_pts_preds'][-1] - batch_size = all_cls_scores.size()[0] - predictions_list = [] - for i in range(batch_size): - predictions_list.append(self.decode_single(all_cls_scores[i], all_bbox_preds[i],all_pts_preds[i])) - return predictions_list - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py deleted file mode 100644 index aac1a82a64f467a47e39d7e862357459e84abb84..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from mmdet.core.bbox.match_costs import build_match_cost -from .match_cost import BBox3DL1Cost - -__all__ = ['build_match_cost', 'BBox3DL1Cost'] \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py deleted file mode 100644 index d9678f3c7f666255540762d4064f0f7d82b920ed..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py +++ /dev/null @@ -1,27 +0,0 @@ -import torch -from mmdet.core.bbox.match_costs.builder import MATCH_COST - - -@MATCH_COST.register_module() -class BBox3DL1Cost(object): - """BBox3DL1Cost. - Args: - weight (int | float, optional): loss_weight - """ - - def __init__(self, weight=1.): - self.weight = weight - - def __call__(self, bbox_pred, gt_bboxes): - """ - Args: - bbox_pred (Tensor): Predicted boxes with normalized coordinates - (cx, cy, w, h), which are all in range [0, 1]. Shape - [num_query, 4]. - gt_bboxes (Tensor): Ground truth boxes with normalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - Returns: - torch.Tensor: bbox_cost value with weight - """ - bbox_cost = torch.cdist(bbox_pred, gt_bboxes, p=1) - return bbox_cost * self.weight \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/util.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/util.py deleted file mode 100644 index c54bd750246f3d6e2249b7d39888fffa6227beda..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/bbox/util.py +++ /dev/null @@ -1,53 +0,0 @@ -import torch - - -def normalize_bbox(bboxes, pc_range): - - cx = bboxes[..., 0:1] - cy = bboxes[..., 1:2] - cz = bboxes[..., 2:3] - w = bboxes[..., 3:4].log() - l = bboxes[..., 4:5].log() - h = bboxes[..., 5:6].log() - - rot = bboxes[..., 6:7] - if bboxes.size(-1) > 7: - vx = bboxes[..., 7:8] - vy = bboxes[..., 8:9] - normalized_bboxes = torch.cat( - (cx, cy, w, l, cz, h, rot.sin(), rot.cos(), vx, vy), dim=-1 - ) - else: - normalized_bboxes = torch.cat( - (cx, cy, w, l, cz, h, rot.sin(), rot.cos()), dim=-1 - ) - return normalized_bboxes - -def denormalize_bbox(normalized_bboxes, pc_range): - # rotation - rot_sine = normalized_bboxes[..., 6:7] - - rot_cosine = normalized_bboxes[..., 7:8] - rot = torch.atan2(rot_sine, rot_cosine) - - # center in the bev - cx = normalized_bboxes[..., 0:1] - cy = normalized_bboxes[..., 1:2] - cz = normalized_bboxes[..., 4:5] - - # size - w = normalized_bboxes[..., 2:3] - l = normalized_bboxes[..., 3:4] - h = normalized_bboxes[..., 5:6] - - w = w.exp() - l = l.exp() - h = h.exp() - if normalized_bboxes.size(-1) > 8: - # velocity - vx = normalized_bboxes[:, 8:9] - vy = normalized_bboxes[:, 9:10] - denormalized_bboxes = torch.cat([cx, cy, cz, w, l, h, rot, vx, vy], dim=-1) - else: - denormalized_bboxes = torch.cat([cx, cy, cz, w, l, h, rot], dim=-1) - return denormalized_bboxes \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/__init__.py deleted file mode 100644 index d92421c7e84fdc7a33e94aa10fddfccb332d6399..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .eval_hooks import CustomDistEvalHook \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py deleted file mode 100644 index 0477213bd3fe5874c7fe8c7c4fe2d861165e2d58..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py +++ /dev/null @@ -1,91 +0,0 @@ - -# Note: Considering that MMCV's EvalHook updated its interface in V1.3.16, -# in order to avoid strong version dependency, we did not directly -# inherit EvalHook but BaseDistEvalHook. - -import bisect -import os.path as osp - -import mmcv -import torch.distributed as dist -from mmcv.runner import DistEvalHook as BaseDistEvalHook -from mmcv.runner import EvalHook as BaseEvalHook -from torch.nn.modules.batchnorm import _BatchNorm -from mmdet.core.evaluation.eval_hooks import DistEvalHook - - -def _calc_dynamic_intervals(start_interval, dynamic_interval_list): - assert mmcv.is_list_of(dynamic_interval_list, tuple) - - dynamic_milestones = [0] - dynamic_milestones.extend( - [dynamic_interval[0] for dynamic_interval in dynamic_interval_list]) - dynamic_intervals = [start_interval] - dynamic_intervals.extend( - [dynamic_interval[1] for dynamic_interval in dynamic_interval_list]) - return dynamic_milestones, dynamic_intervals - - -class CustomDistEvalHook(BaseDistEvalHook): - - def __init__(self, *args, dynamic_intervals=None, **kwargs): - super(CustomDistEvalHook, self).__init__(*args, **kwargs) - self.use_dynamic_intervals = dynamic_intervals is not None - if self.use_dynamic_intervals: - self.dynamic_milestones, self.dynamic_intervals = \ - _calc_dynamic_intervals(self.interval, dynamic_intervals) - - def _decide_interval(self, runner): - if self.use_dynamic_intervals: - progress = runner.epoch if self.by_epoch else runner.iter - step = bisect.bisect(self.dynamic_milestones, (progress + 1)) - # Dynamically modify the evaluation interval - self.interval = self.dynamic_intervals[step - 1] - - def before_train_epoch(self, runner): - """Evaluate the model only at the start of training by epoch.""" - self._decide_interval(runner) - super().before_train_epoch(runner) - - def before_train_iter(self, runner): - self._decide_interval(runner) - super().before_train_iter(runner) - - def _do_evaluate(self, runner): - """perform evaluation and save ckpt.""" - # Synchronization of BatchNorm's buffer (running_mean - # and running_var) is not supported in the DDP of pytorch, - # which may cause the inconsistent performance of models in - # different ranks, so we broadcast BatchNorm's buffers - # of rank 0 to other ranks to avoid this. - if self.broadcast_bn_buffer: - model = runner.model - for name, module in model.named_modules(): - if isinstance(module, - _BatchNorm) and module.track_running_stats: - dist.broadcast(module.running_var, 0) - dist.broadcast(module.running_mean, 0) - - if not self._should_evaluate(runner): - return - - tmpdir = self.tmpdir - if tmpdir is None: - tmpdir = osp.join(runner.work_dir, '.eval_hook') - - from projects.mmdet3d_plugin.bevformer.apis.test import custom_multi_gpu_test # to solve circlur import - - results = custom_multi_gpu_test( - runner.model, - self.dataloader, - tmpdir=tmpdir, - gpu_collect=self.gpu_collect) - if runner.rank == 0: - print('\n') - runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) - - key_score = self.evaluate(runner, results) - - if self.save_best: - self._save_ckpt(runner, key_score) - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py deleted file mode 100644 index f816974544b57c1561a1fc09b9cf9e48dde03e38..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/core/evaluation/kitti2waymo.py +++ /dev/null @@ -1,251 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -r"""Adapted from `Waymo to KITTI converter - `_. -""" - -try: - from waymo_open_dataset import dataset_pb2 as open_dataset - import mmcv - import numpy as np - import tensorflow as tf - from glob import glob - from os.path import join - from waymo_open_dataset import label_pb2 - from waymo_open_dataset.protos import metrics_pb2 -except ImportError: - #pass - raise ImportError( - 'Please run "pip install waymo-open-dataset-tf-2-1-0==1.2.0" ' - 'to install the official devkit first.') - - - - -class KITTI2Waymo(object): - """KITTI predictions to Waymo converter. - This class serves as the converter to change predictions from KITTI to - Waymo format. - Args: - kitti_result_files (list[dict]): Predictions in KITTI format. - waymo_tfrecords_dir (str): Directory to load waymo raw data. - waymo_results_save_dir (str): Directory to save converted predictions - in waymo format (.bin files). - waymo_results_final_path (str): Path to save combined - predictions in waymo format (.bin file), like 'a/b/c.bin'. - prefix (str): Prefix of filename. In general, 0 for training, 1 for - validation and 2 for testing. - workers (str): Number of parallel processes. - """ - - def __init__(self, - kitti_result_files, - waymo_tfrecords_dir, - waymo_results_save_dir, - waymo_results_final_path, - prefix, - workers=64): - - self.kitti_result_files = kitti_result_files - self.waymo_tfrecords_dir = waymo_tfrecords_dir - self.waymo_results_save_dir = waymo_results_save_dir - self.waymo_results_final_path = waymo_results_final_path - self.prefix = prefix - self.workers = int(workers) - self.name2idx = {} - for idx, result in enumerate(kitti_result_files): - if len(result['sample_idx']) > 0: - self.name2idx[str(result['sample_idx'][0])] = idx - - # turn on eager execution for older tensorflow versions - if int(tf.__version__.split('.')[0]) < 2: - tf.enable_eager_execution() - - self.k2w_cls_map = { - 'Car': label_pb2.Label.TYPE_VEHICLE, - 'Pedestrian': label_pb2.Label.TYPE_PEDESTRIAN, - 'Sign': label_pb2.Label.TYPE_SIGN, - 'Cyclist': label_pb2.Label.TYPE_CYCLIST, - } - - self.T_ref_to_front_cam = np.array([[0.0, 0.0, 1.0, 0.0], - [-1.0, 0.0, 0.0, 0.0], - [0.0, -1.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 1.0]]) - - self.get_file_names() - self.create_folder() - - def get_file_names(self): - """Get file names of waymo raw data.""" - self.waymo_tfrecord_pathnames = sorted( - glob(join(self.waymo_tfrecords_dir, '*.tfrecord'))) - print(len(self.waymo_tfrecord_pathnames), 'tfrecords found.') - - def create_folder(self): - """Create folder for data conversion.""" - mmcv.mkdir_or_exist(self.waymo_results_save_dir) - - def parse_objects(self, kitti_result, T_k2w, context_name, - frame_timestamp_micros): - """Parse one prediction with several instances in kitti format and - convert them to `Object` proto. - Args: - kitti_result (dict): Predictions in kitti format. - - name (np.ndarray): Class labels of predictions. - - dimensions (np.ndarray): Height, width, length of boxes. - - location (np.ndarray): Bottom center of boxes (x, y, z). - - rotation_y (np.ndarray): Orientation of boxes. - - score (np.ndarray): Scores of predictions. - T_k2w (np.ndarray): Transformation matrix from kitti to waymo. - context_name (str): Context name of the frame. - frame_timestamp_micros (int): Frame timestamp. - Returns: - :obj:`Object`: Predictions in waymo dataset Object proto. - """ - - def parse_one_object(instance_idx): - """Parse one instance in kitti format and convert them to `Object` - proto. - Args: - instance_idx (int): Index of the instance to be converted. - Returns: - :obj:`Object`: Predicted instance in waymo dataset \ - Object proto. - """ - cls = kitti_result['name'][instance_idx] - length = round(kitti_result['dimensions'][instance_idx, 0], 4) - height = round(kitti_result['dimensions'][instance_idx, 1], 4) - width = round(kitti_result['dimensions'][instance_idx, 2], 4) - x = round(kitti_result['location'][instance_idx, 0], 4) - y = round(kitti_result['location'][instance_idx, 1], 4) - z = round(kitti_result['location'][instance_idx, 2], 4) - rotation_y = round(kitti_result['rotation_y'][instance_idx], 4) - score = round(kitti_result['score'][instance_idx], 4) - - # y: downwards; move box origin from bottom center (kitti) to - # true center (waymo) - y -= height / 2 - # frame transformation: kitti -> waymo - x, y, z = self.transform(T_k2w, x, y, z) - - # different conventions - heading = -(rotation_y + np.pi / 2) - while heading < -np.pi: - heading += 2 * np.pi - while heading > np.pi: - heading -= 2 * np.pi - - box = label_pb2.Label.Box() - box.center_x = x - box.center_y = y - box.center_z = z - box.length = length - box.width = width - box.height = height - box.heading = heading - - o = metrics_pb2.Object() - o.object.box.CopyFrom(box) - o.object.type = self.k2w_cls_map[cls] - o.score = score - - o.context_name = context_name - o.frame_timestamp_micros = frame_timestamp_micros - - return o - - objects = metrics_pb2.Objects() - - for instance_idx in range(len(kitti_result['name'])): - o = parse_one_object(instance_idx) - objects.objects.append(o) - - return objects - - def convert_one(self, file_idx): - """Convert action for single file. - Args: - file_idx (int): Index of the file to be converted. - """ - file_pathname = self.waymo_tfrecord_pathnames[file_idx] - file_data = tf.data.TFRecordDataset(file_pathname, compression_type='') - - for frame_num, frame_data in enumerate(file_data): - frame = open_dataset.Frame() - frame.ParseFromString(bytearray(frame_data.numpy())) - filename = f'{self.prefix}{file_idx:03d}{frame_num:03d}' - - for camera in frame.context.camera_calibrations: - # FRONT = 1, see dataset.proto for details - if camera.name == 1: - T_front_cam_to_vehicle = np.array( - camera.extrinsic.transform).reshape(4, 4) - - T_k2w = T_front_cam_to_vehicle @ self.T_ref_to_front_cam - - context_name = frame.context.name - frame_timestamp_micros = frame.timestamp_micros - - if filename in self.name2idx: - kitti_result = \ - self.kitti_result_files[self.name2idx[filename]] - objects = self.parse_objects(kitti_result, T_k2w, context_name, - frame_timestamp_micros) - else: - print(filename, 'not found.(bevformer)') - objects = metrics_pb2.Objects() - - with open( - join(self.waymo_results_save_dir, f'{filename}.bin'), - 'wb') as f: - f.write(objects.SerializeToString()) - - def convert(self): - """Convert action.""" - print('Start converting ...') - mmcv.track_parallel_progress(self.convert_one, range(len(self)), - self.workers) - print('\nFinished ...') - - # combine all files into one .bin - pathnames = sorted(glob(join(self.waymo_results_save_dir, '*.bin'))) - combined = self.combine(pathnames) - - with open(self.waymo_results_final_path, 'wb') as f: - f.write(combined.SerializeToString()) - - def __len__(self): - """Length of the filename list.""" - return len(self.waymo_tfrecord_pathnames) - - def transform(self, T, x, y, z): - """Transform the coordinates with matrix T. - Args: - T (np.ndarray): Transformation matrix. - x(float): Coordinate in x axis. - y(float): Coordinate in y axis. - z(float): Coordinate in z axis. - Returns: - list: Coordinates after transformation. - """ - pt_bef = np.array([x, y, z, 1.0]).reshape(4, 1) - pt_aft = np.matmul(T, pt_bef) - return pt_aft[:3].flatten().tolist() - - def combine(self, pathnames): - """Combine predictions in waymo format for each sample together. - Args: - pathnames (str): Paths to save predictions. - Returns: - :obj:`Objects`: Combined predictions in Objects proto. - """ - combined = metrics_pb2.Objects() - - for pathname in pathnames: - objects = metrics_pb2.Objects() - with open(pathname, 'rb') as f: - objects.ParseFromString(f.read()) - for o in objects.objects: - combined.objects.append(o) - - return combined \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_map_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_map_dataset.py deleted file mode 100644 index 0b23a8d330f8c2dbc2544451f0ab6b7ac61bcf27..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_map_dataset.py +++ /dev/null @@ -1,1526 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -import os -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - -from .nuscenes_dataset import CustomNuScenesDataset -from nuscenes.map_expansion.map_api import NuScenesMap, NuScenesMapExplorer -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from shapely import affinity, ops -from shapely.geometry import Polygon, LineString, box, MultiPolygon, MultiLineString -from mmdet.datasets.pipelines import to_tensor -import json - -from pathlib import Path -from av2.datasets.sensor.av2_sensor_dataloader import AV2SensorDataLoader -from av2.map.lane_segment import LaneMarkType, LaneSegment -from av2.map.map_api import ArgoverseStaticMap -from av2.geometry.se3 import SE3 -import av2.geometry.interpolate as interp_utils - - -class LiDARInstanceLines(object): - """Line instance in LIDAR coordinates - - """ - def __init__(self, - instance_line_list, - sample_dist=1, - num_samples=250, - padding=False, - fixed_num=-1, - padding_value=-10000, - patch_size=None): - assert isinstance(instance_line_list, list) - assert patch_size is not None - if len(instance_line_list) != 0: - assert isinstance(instance_line_list[0], LineString) - self.patch_size = patch_size - self.max_x = self.patch_size[1] / 2 - self.max_y = self.patch_size[0] / 2 - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_num - self.padding_value = padding_value - - self.instance_list = instance_line_list - - @property - def start_end_points(self): - """ - return torch.Tensor([N,4]), in xstart, ystart, xend, yend form - """ - assert len(self.instance_list) != 0 - instance_se_points_list = [] - for instance in self.instance_list: - se_points = [] - se_points.extend(instance.coords[0]) - se_points.extend(instance.coords[-1]) - instance_se_points_list.append(se_points) - instance_se_points_array = np.array(instance_se_points_list) - instance_se_points_tensor = to_tensor(instance_se_points_array) - instance_se_points_tensor = instance_se_points_tensor.to( - dtype=torch.float32) - instance_se_points_tensor[:,0] = torch.clamp(instance_se_points_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,1] = torch.clamp(instance_se_points_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_se_points_tensor[:,2] = torch.clamp(instance_se_points_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,3] = torch.clamp(instance_se_points_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_se_points_tensor - - @property - def bbox(self): - """ - return torch.Tensor([N,4]), in xmin, ymin, xmax, ymax form - """ - assert len(self.instance_list) != 0 - instance_bbox_list = [] - for instance in self.instance_list: - # bounds is bbox: [xmin, ymin, xmax, ymax] - instance_bbox_list.append(instance.bounds) - instance_bbox_array = np.array(instance_bbox_list) - instance_bbox_tensor = to_tensor(instance_bbox_array) - instance_bbox_tensor = instance_bbox_tensor.to( - dtype=torch.float32) - instance_bbox_tensor[:,0] = torch.clamp(instance_bbox_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,1] = torch.clamp(instance_bbox_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_bbox_tensor[:,2] = torch.clamp(instance_bbox_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,3] = torch.clamp(instance_bbox_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_bbox_tensor - - @property - def fixed_num_sampled_points(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # instance_array = np.array(list(instance.coords)) - # interpolated_instance = interp_utils.interp_arc(t=self.fixed_num, points=instance_array) - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]) - if instance.has_z: - sampled_points = sampled_points.reshape(-1,3) - else: - sampled_points = sampled_points.reshape(-1,2) - # import pdb;pdb.set_trace() - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def fixed_num_sampled_points_ambiguity(self): - """ - return torch.Tensor([N,fixed_num,3]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - if instance.has_z: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor = instance_points_tensor if is_3d else instance_points_tensor[:,:,:2] - instance_points_tensor = instance_points_tensor.unsqueeze(1) - return instance_points_tensor - - @property - def fixed_num_sampled_points_torch(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # distances = np.linspace(0, instance.length, self.fixed_num) - # sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - poly_pts = to_tensor(np.array(list(instance.coords))) - poly_pts = poly_pts.unsqueeze(0).permute(0,2,1) - sampled_pts = torch.nn.functional.interpolate(poly_pts,size=(self.fixed_num),mode='linear',align_corners=True) - sampled_pts = sampled_pts.permute(0,2,1).squeeze(0) - instance_points_list.append(sampled_pts) - # instance_points_array = np.array(instance_points_list) - # instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = torch.stack(instance_points_list,dim=0) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def shift_fixed_num_sampled_points(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - # import pdb;pdb.set_trace() - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v1(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num-shift_pts.shape[0],pts_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v2(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - - if shifts_num > final_shift_num: - index = np.random.choice(multi_shifts_pts.shape[0], final_shift_num, replace=False) - multi_shifts_pts = multi_shifts_pts[index] - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < final_shift_num: - padding = torch.full([final_shift_num-multi_shifts_pts_tensor.shape[0],self.fixed_num,multi_shifts_pts_tensor.shape[-1]], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v3(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - flip_pts_to_shift = np.flip(pts_to_shift, axis=0) - for shift_right_i in range(shift_num): - shift_pts = np.roll(flip_pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - # import pdb;pdb.set_trace() - if shifts_num > 2*final_shift_num: - index = np.random.choice(shift_num, final_shift_num, replace=False) - flip0_shifts_pts = multi_shifts_pts[index] - flip1_shifts_pts = multi_shifts_pts[index+shift_num] - multi_shifts_pts = np.concatenate((flip0_shifts_pts,flip1_shifts_pts),axis=0) - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < 2*final_shift_num: - padding = torch.full([final_shift_num*2-multi_shifts_pts_tensor.shape[0],self.fixed_num,multi_shifts_pts_tensor.shape[-1]], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v4(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - shift_pts_list = [] - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - flip_pts_to_shift = pts_to_shift.flip(0) - for shift_right_i in range(shift_num): - shift_pts_list.append(flip_pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num*2, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num*2-shift_pts.shape[0],pts_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_torch(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points_torch - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - # import pdb;pdb.set_trace() - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - # @property - # def polyline_points(self): - # """ - # return [[x0,y0],[x1,y1],...] - # """ - # assert len(self.instance_list) != 0 - # for instance in self.instance_list: - - -class VectorizedAV2LocalMap(object): - CLASS2LABEL = { - 'road_divider': 0, - 'lane_divider': 0, - 'divider': 0, - 'ped_crossing': 1, - 'boundary': 2, - 'others': -1 - } - def __init__(self, - dataroot, - patch_size, - test_mode=False, - map_classes=['divider','ped_crossing','boundary'], - line_classes=['road_divider', 'lane_divider'], - ped_crossing_classes=['ped_crossing'], - contour_classes=['road_segment', 'lane'], - sample_dist=1, - num_samples=250, - padding=False, - fixed_ptsnum_per_line=-1, - padding_value=-10000,): - ''' - Args: - fixed_ptsnum_per_line = -1 : no fixed num - ''' - super().__init__() - # self.data_root = dataroot - self.test_mode = test_mode - if self.test_mode: - self.data_root = osp.join(dataroot, "val") - else: - self.data_root = osp.join(dataroot, "train") - - self.loader = AV2SensorDataLoader(data_dir=Path(dataroot), labels_dir=Path(dataroot)) - - - - self.vec_classes = map_classes - self.line_classes = line_classes - self.ped_crossing_classes = ped_crossing_classes - self.polygon_classes = contour_classes - - - self.patch_size = patch_size - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_ptsnum_per_line - self.padding_value = padding_value - - def gen_vectorized_samples(self, location, map_elements, lidar2global_translation, lidar2global_rotation): - ''' - use lidar2global to get gt map layers - av2 lidar2global the same as ego2global - location the same as log_id - ''' - # avm = ArgoverseStaticMap.from_map_dir(log_map_dirpath, build_raster=False) - - map_pose = lidar2global_translation[:2] - rotation = Quaternion._from_matrix(lidar2global_rotation) - - patch_box = (map_pose[0], map_pose[1], self.patch_size[0], self.patch_size[1]) - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - # import pdb;pdb.set_trace() - vectors = [] - city_SE2_ego = SE3(lidar2global_rotation, lidar2global_translation) - ego_SE3_city = city_SE2_ego.inverse() - for vec_class in self.vec_classes: - if vec_class == 'divider': - line_geom = self.get_map_divider_geom(patch_box, patch_angle, map_elements[vec_class], ego_SE3_city) - line_instances_list = self.line_geoms_to_instances(line_geom) - for divider in line_instances_list: - vectors.append((divider, self.CLASS2LABEL.get('divider', -1))) - elif vec_class == 'ped_crossing': - ped_geom = self.get_map_ped_geom(patch_box, patch_angle, map_elements[vec_class], ego_SE3_city) - ped_instance_list = self.ped_poly_geoms_to_instances(ped_geom) - for instance in ped_instance_list: - vectors.append((instance, self.CLASS2LABEL.get('ped_crossing', -1))) - elif vec_class == 'boundary': - polygon_geom = self.get_map_boundary_geom(patch_box, patch_angle, map_elements[vec_class], ego_SE3_city) - poly_bound_list = self.bound_poly_geoms_to_instances(polygon_geom) - for bound in poly_bound_list: - vectors.append((bound, self.CLASS2LABEL.get('boundary', -1))) - else: - raise ValueError(f'WRONG vec_class: {vec_class}') - - # filter out -1 - filtered_vectors = [] - gt_pts_loc_3d = [] - gt_pts_num_3d = [] - gt_labels = [] - gt_instance = [] - for instance, type in vectors: - if type != -1: - gt_instance.append(instance) - gt_labels.append(type) - # import pdb;pdb.set_trace() - gt_instance = LiDARInstanceLines(gt_instance,self.sample_dist, - self.num_samples, self.padding, self.fixed_num,self.padding_value, patch_size=self.patch_size) - - anns_results = dict( - gt_vecs_pts_loc=gt_instance, - gt_vecs_label=gt_labels, - - ) - # import pdb;pdb.set_trace() - return anns_results - def proc_polygon(self, polygon, ego_SE3_city): - # import pdb;pdb.set_trace() - interiors = [] - exterior_cityframe = np.array(list(polygon.exterior.coords)) - exterior_egoframe = ego_SE3_city.transform_point_cloud(exterior_cityframe) - for inter in polygon.interiors: - inter_cityframe = np.array(list(inter.coords)) - inter_egoframe = ego_SE3_city.transform_point_cloud(inter_cityframe) - interiors.append(inter_egoframe[:,:2]) - - new_polygon = Polygon(exterior_egoframe[:,:2], interiors) - return new_polygon - - def get_map_boundary_geom(self, patch_box, patch_angle, avm, ego_SE3_city): - map_boundary_geom = [] - patch_x = patch_box[0] - patch_y = patch_box[1] - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - # import pdb;pdb.set_trace() - polygon_list = [] - for da in avm: - exterior_coords = da - # import pdb;pdb.set_trace() - interiors = [] - # import pdb;pdb.set_trace() - is_polygon = np.array_equal(exterior_coords[0],exterior_coords[-1]) - if is_polygon: - polygon = Polygon(exterior_coords, interiors) - else: - import pdb;pdb.set_trace() - polygon = LineString(exterior_coords) - raise ValueError(f'WRONG type: line in boundary') - if is_polygon: - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - # import pdb;pdb.set_trace() - if new_polygon.geom_type is 'Polygon': - if not new_polygon.is_valid: - continue - new_polygon = self.proc_polygon(new_polygon,ego_SE3_city) - if not new_polygon.is_valid: - continue - elif new_polygon.geom_type is 'MultiPolygon': - polygons = [] - for single_polygon in new_polygon.geoms: - if not single_polygon.is_valid or single_polygon.is_empty: - continue - new_single_polygon = self.proc_polygon(single_polygon,ego_SE3_city) - if not new_single_polygon.is_valid: - continue - polygons.append(new_single_polygon) - if len(polygons) == 0: - continue - new_polygon = MultiPolygon(polygons) - if not new_polygon.is_valid: - continue - else: - raise ValueError('{} is not valid'.format(new_polygon.geom_type)) - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - else: - raise ValueError(f'WRONG type: line in boundary') - map_boundary_geom.append(('boundary',polygon_list)) - return map_boundary_geom - - def get_map_ped_geom(self, patch_box, patch_angle, avm, ego_SE3_city): - map_ped_geom = [] - patch_x = patch_box[0] - patch_y = patch_box[1] - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - # import pdb;pdb.set_trace() - polygon_list = [] - for pc in avm: - exterior_coords = pc - interiors = [] - polygon = Polygon(exterior_coords, interiors) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - if new_polygon.geom_type is 'Polygon': - if not new_polygon.is_valid: - continue - new_polygon = self.proc_polygon(new_polygon,ego_SE3_city) - if not new_polygon.is_valid: - continue - elif new_polygon.geom_type is 'MultiPolygon': - polygons = [] - for single_polygon in new_polygon.geoms: - if not single_polygon.is_valid or single_polygon.is_empty: - continue - new_single_polygon = self.proc_polygon(single_polygon,ego_SE3_city) - if not new_single_polygon.is_valid: - continue - polygons.append(new_single_polygon) - if len(polygons) == 0: - continue - new_polygon = MultiPolygon(polygons) - if not new_polygon.is_valid: - continue - else: - raise ValueError('{} is not valid'.format(new_polygon.geom_type)) - - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - map_ped_geom.append(('ped_crossing',polygon_list)) - return map_ped_geom - - def proc_line(self, line,ego_SE3_city): - # import pdb;pdb.set_trace() - new_line_pts_cityframe = np.array(list(line.coords)) - new_line_pts_egoframe = ego_SE3_city.transform_point_cloud(new_line_pts_cityframe) - line = LineString(new_line_pts_egoframe[:,:2]) #TODO - return line - - def get_map_divider_geom(self, patch_box, patch_angle, avm, ego_SE3_city): - map_divider_geom = [] - patch_x = patch_box[0] - patch_y = patch_box[1] - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - line_list = [] - for ls in avm: - line = LineString(ls) - if line.is_empty: # Skip lines without nodes. - continue - new_line = line.intersection(patch) - if not new_line.is_empty: - # import pdb;pdb.set_trace() - if new_line.geom_type == 'MultiLineString': - for single_line in new_line.geoms: - if single_line.is_empty: - continue - - single_line = self.proc_line(single_line,ego_SE3_city) - line_list.append(single_line) - else: - new_line = self.proc_line(new_line, ego_SE3_city) - line_list.append(new_line) - map_divider_geom.append(('divider',line_list)) - return map_divider_geom - - - def _one_type_line_geom_to_instances(self, line_geom): - line_instances = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_instances.append(single_line) - elif line.geom_type == 'LineString': - line_instances.append(line) - else: - raise NotImplementedError - return line_instances - - - def ped_poly_geoms_to_instances(self, ped_geom): - ped = ped_geom[0][1] - # union_segments = ops.unary_union(ped) - # union_segments = MultiPolygon(ped) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - # local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - local_patch = box(-max_x - 0.2, -max_y - 0.2, max_x + 0.2, max_y + 0.2) - exteriors = [] - interiors = [] - # if union_segments.geom_type != 'MultiPolygon': - # union_segments = MultiPolygon([union_segments]) - for segments in ped: - if segments.geom_type != 'MultiPolygon': - segments = MultiPolygon([segments]) - for poly in segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - def bound_poly_geoms_to_instances(self, polygon_geom): - # roads = polygon_geom[0][1] - # lanes = polygon_geom[1][1] - # union_roads = ops.unary_union(roads) - # union_lanes = ops.unary_union(lanes) - # union_segments = ops.unary_union([union_roads, union_lanes]) - # import pdb;pdb.set_trace() - bounds = polygon_geom[0][1] - - union_segments = ops.unary_union(bounds) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - def line_geoms_to_instances(self, line_geom): - lines = line_geom[0][1] - multiline = MultiLineString(lines) - union_lines = ops.unary_union(multiline) - if union_lines.geom_type == 'LineString': - return self._one_type_line_geom_to_instances([union_lines]) - before_num = len(union_lines.geoms) - # import pdb;pdb.set_trace() - merged_lines = ops.linemerge(union_lines) - if merged_lines.geom_type == 'LineString': - return self._one_type_line_geom_to_instances([merged_lines]) - after_num = len(merged_lines.geoms) - # import pdb;pdb.set_trace() - while after_num != before_num: - before_num = len(merged_lines.geoms) - merged_lines = ops.unary_union(merged_lines) - if merged_lines.geom_type == 'LineString': - break - merged_lines = ops.linemerge(merged_lines) - if merged_lines.geom_type == 'LineString': - break - after_num = len(merged_lines.geoms) - - return self._one_type_line_geom_to_instances([merged_lines]) - - - - def sample_pts_from_line(self, line): - if self.fixed_num < 0: - distances = np.arange(0, line.length, self.sample_dist) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / self.fixed_num - distances = np.linspace(0, line.length, self.fixed_num) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - - num_valid = len(sampled_points) - - if not self.padding or self.fixed_num > 0: - # fixed num sample can return now! - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if self.fixed_num < 0: - if num_valid < self.num_samples: - padding = np.zeros((self.num_samples - len(sampled_points), 2)) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:self.num_samples, :] - num_valid = self.num_samples - - - return sampled_points, num_valid - - -@DATASETS.register_module() -class CustomAV2LocalMapDataset(CustomNuScenesDataset): - r"""NuScenes Dataset. - - This datset add static map elements - """ - MAPCLASSES = ('divider',) - def __init__(self, - map_ann_file=None, - queue_length=4, - code_size=2, - bev_size=(200, 200), - pc_range=[-51.2, -51.2, -5.0, 51.2, 51.2, 3.0], - overlap_test=False, - fixed_ptsnum_per_line=-1, - eval_use_same_gt_sample_num_flag=False, - padding_value=-10000, - map_classes=None, - *args, - **kwargs): - super().__init__(*args, **kwargs) - self.map_ann_file = map_ann_file - - self.code_size = code_size - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - self.MAPCLASSES = self.get_map_classes(map_classes) - self.NUM_MAPCLASSES = len(self.MAPCLASSES) - self.pc_range = pc_range - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - self.patch_size = (patch_h, patch_w) - self.padding_value = padding_value - self.fixed_num = fixed_ptsnum_per_line - self.eval_use_same_gt_sample_num_flag = eval_use_same_gt_sample_num_flag - self.vector_map = VectorizedAV2LocalMap(kwargs['data_root'], - patch_size=self.patch_size, test_mode=self.test_mode, - map_classes=self.MAPCLASSES, - fixed_ptsnum_per_line=fixed_ptsnum_per_line, - padding_value=self.padding_value) - self.is_vis_on_test = False - - def load_annotations(self, ann_file): - """Load annotations from ann_file. - - Args: - ann_file (str): Path of the annotation file. - - Returns: - list[dict]: List of annotations sorted by timestamps. - """ - # import pdb;pdb.set_trace() - data = mmcv.load(ann_file) - # import pdb;pdb.set_trace() - data_infos = list(sorted(data['samples'], key=lambda e: e['timestamp'])) - data_infos = data_infos[::self.load_interval] - # data_infos = [ data_info.update(dict(token= str(data_info['timestamp']+data_info['log_id']))) for data_info in data_infos] - self.id2map = data['id2map'] - self.metadata = None - self.version = None - return data_infos - - @classmethod - def get_map_classes(cls, map_classes=None): - """Get class names of current dataset. - - Args: - classes (Sequence[str] | str | None): If classes is None, use - default CLASSES defined by builtin dataset. If classes is a - string, take it as a file name. The file contains the name of - classes where each line contains one class name. If classes is - a tuple or list, override the CLASSES defined by the dataset. - - Return: - list[str]: A list of class names. - """ - if map_classes is None: - return cls.MAPCLASSES - - if isinstance(map_classes, str): - # take it as a file path - class_names = mmcv.list_from_file(map_classes) - elif isinstance(map_classes, (tuple, list)): - class_names = map_classes - else: - raise ValueError(f'Unsupported type {type(map_classes)} of map classes.') - - return class_names - def vectormap_pipeline(self, example, input_dict): - ''' - `example` type: - keys: 'img_metas', 'gt_bboxes_3d', 'gt_labels_3d', 'img'; - all keys type is 'DataContainer'; - 'img_metas' cpu_only=True, type is dict, others are false; - 'gt_labels_3d' shape torch.size([num_samples]), stack=False, - padding_value=0, cpu_only=False - 'gt_bboxes_3d': stack=False, cpu_only=True - ''' - # import pdb;pdb.set_trace() - location = input_dict['log_id'] - e2g_translation = input_dict['e2g_translation'] - e2g_rotation = input_dict['e2g_rotation'] - map_elements = self.id2map[location] - anns_results = self.vector_map.gen_vectorized_samples(location, map_elements, e2g_translation, e2g_rotation) - - ''' - anns_results, type: dict - 'gt_vecs_pts_loc': list[num_vecs], vec with num_points*2 coordinates - 'gt_vecs_pts_num': list[num_vecs], vec with num_points - 'gt_vecs_label': list[num_vecs], vec with cls index - ''' - gt_vecs_label = to_tensor(anns_results['gt_vecs_label']) - if isinstance(anns_results['gt_vecs_pts_loc'], LiDARInstanceLines): - gt_vecs_pts_loc = anns_results['gt_vecs_pts_loc'] - else: - gt_vecs_pts_loc = to_tensor(anns_results['gt_vecs_pts_loc']) - try: - gt_vecs_pts_loc = gt_vecs_pts_loc.flatten(1).to(dtype=torch.float32) - except: - # empty tensor, will be passed in train, - # but we preserve it for test - - # import pdb;pdb.set_trace() - gt_vecs_pts_loc = gt_vecs_pts_loc - # import ipdb;ipdb.set_trace() - example['gt_labels_3d'] = DC(gt_vecs_label, cpu_only=False) - example['gt_bboxes_3d'] = DC(gt_vecs_pts_loc, cpu_only=True) - # import pdb;pdb.set_trace() - # if self.is_vis_on_test: - # lidar2global_translation = to_tensor(lidar2global_translation) - # example['lidar2global_translation'] = DC(lidar2global_translation, cpu_only=True) - # else: - # example['img_metas'].data['lidar2global_translation'] = lidar2global_translation - return example - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = [] - - # temporal aug - prev_indexs_list = list(range(index-self.queue_length, index)) - random.shuffle(prev_indexs_list) - prev_indexs_list = sorted(prev_indexs_list[1:], reverse=True) - ## - - input_dict = self.get_data_info(index) - if input_dict is None: - return None - frame_idx = input_dict['timestamp'] - scene_token = input_dict['log_id'] - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - # import pdb;pdb.set_trace() - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - data_queue.insert(0, example) - return self.union2one(data_queue) - - def union2one(self, queue): - """ - convert sample queue into one single sample. - """ - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if i == 0: - metas_map[i]['prev_bev'] = False - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - else: - metas_map[i]['prev_bev'] = True - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - - queue[-1]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - timestamp=info['timestamp'], - e2g_translation=info['e2g_translation'], - e2g_rotation=info['e2g_rotation'], - log_id=info['log_id'], - scene_token=info['log_id'], - ) - if self.modality['use_camera']: - image_paths = [] - cam_intrinsics = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_types = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['img_fpath']) - # camera intrinsics - camera_intrinsics = np.eye(4).astype(np.float32) - camera_intrinsics[:3, :3] = cam_info["intrinsics"] - # input_dict["camera_intrinsics"].append(camera_intrinsics) - - # ego2img, ego = lidar - lidar2cam_rt = cam_info['extrinsics'] - intrinsic = cam_info['intrinsics'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt) - lidar2img_rts.append(lidar2img_rt) - lidar2cam_rts.append(lidar2cam_rt) - cam_intrinsics.append(viewpad) - cam_types.append(cam_type) - - - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam_intrinsic=cam_intrinsics, - lidar2cam=lidar2cam_rts, - cam_type=cam_types, - )) - - if not self.test_mode: - # annos = self.get_ann_info(index) - input_dict['ann_info'] = dict() - - translation = input_dict['e2g_translation'] - can_bus = np.ones(18) - # can_bus.extend(translation.tolist()) - can_bus[:3] = translation - rotation = Quaternion._from_matrix(input_dict['e2g_rotation']) - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - input_dict['can_bus'] = can_bus - # import pdb;pdb.set_trace() - return input_dict - - def prepare_test_data(self, index): - """Prepare data for testing. - - Args: - index (int): Index for accessing the target data. - - Returns: - dict: Testing data dict of the corresponding index. - """ - input_dict = self.get_data_info(index) - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.is_vis_on_test: - example = self.vectormap_pipeline(example, input_dict) - return example - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - def _format_gt(self): - gt_annos = [] - # import pdb;pdb.set_trace() - print('Start to convert gt map format...') - assert self.map_ann_file is not None - if (not os.path.exists(self.map_ann_file)) : - dataset_length = len(self) - prog_bar = mmcv.ProgressBar(dataset_length) - mapped_class_names = self.MAPCLASSES - for sample_id in range(dataset_length): - sample_token = self.data_infos[sample_id]['token'] - gt_anno = {} - gt_anno['sample_token'] = sample_token - # gt_sample_annos = [] - gt_sample_dict = {} - gt_sample_dict = self.vectormap_pipeline(gt_sample_dict, self.data_infos[sample_id]) - gt_labels = gt_sample_dict['gt_labels_3d'].data.numpy() - gt_vecs = gt_sample_dict['gt_bboxes_3d'].data.instance_list - # import pdb;pdb.set_trace() - gt_vec_list = [] - for i, (gt_label, gt_vec) in enumerate(zip(gt_labels, gt_vecs)): - name = mapped_class_names[gt_label] - anno = dict( - pts=np.array(list(gt_vec.coords))[:,:self.code_size], - pts_num=len(list(gt_vec.coords)), - cls_name=name, - type=gt_label, - ) - gt_vec_list.append(anno) - gt_anno['vectors']=gt_vec_list - gt_annos.append(gt_anno) - - prog_bar.update() - nusc_submissions = { - 'GTs': gt_annos - } - print('\n GT anns writes to', self.map_ann_file) - mmcv.dump(nusc_submissions, self.map_ann_file) - else: - print(f'{self.map_ann_file} exist, not update') - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - - Returns: - str: Path of the output json file. - """ - assert self.map_ann_file is not None - pred_annos = [] - mapped_class_names = self.MAPCLASSES - # import pdb;pdb.set_trace() - print('Start to convert map detection format...') - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - pred_anno = {} - vecs = output_to_vecs(det) - sample_token = self.data_infos[sample_id]['token'] - pred_anno['sample_token'] = sample_token - pred_vec_list=[] - for i, vec in enumerate(vecs): - name = mapped_class_names[vec['label']] - anno = dict( - # sample_token=sample_token, - pts=vec['pts'], - pts_num=len(vec['pts']), - cls_name=name, - type=vec['label'], - confidence_level=vec['score']) - pred_vec_list.append(anno) - # annos.append(nusc_anno) - # nusc_annos[sample_token] = annos - pred_anno['vectors'] = pred_vec_list - pred_annos.append(pred_anno) - - - if not os.path.exists(self.map_ann_file): - self._format_gt() - else: - print(f'{self.map_ann_file} exist, not update') - # with open(self.map_ann_file,'r') as f: - # GT_anns = json.load(f) - # gt_annos = GT_anns['GTs'] - nusc_submissions = { - 'meta': self.modality, - 'results': pred_annos, - # 'GTs': gt_annos - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'nuscmap_results.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def to_gt_vectors(self, - gt_dict): - # import pdb;pdb.set_trace() - gt_labels = gt_dict['gt_labels_3d'].data - gt_instances = gt_dict['gt_bboxes_3d'].data.instance_list - - gt_vectors = [] - - for gt_instance, gt_label in zip(gt_instances, gt_labels): - pts, pts_num = sample_pts_from_line(gt_instance, patch_size=self.patch_size) - gt_vectors.append({ - 'pts': pts, - 'pts_num': pts_num, - 'type': int(gt_label) - }) - vector_num_list = {} - for i in range(self.NUM_MAPCLASSES): - vector_num_list[i] = [] - for vec in gt_vectors: - if vector['pts_num'] >= 2: - vector_num_list[vector['type']].append((LineString(vector['pts'][:vector['pts_num']]), vector.get('confidence_level', 1))) - return gt_vectors - - def _evaluate_single(self, - result_path, - logger=None, - metric='chamfer', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import eval_map - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import format_res_gt_by_classes - result_path = osp.abspath(result_path) - # import pdb;pdb.set_trace() - detail = dict() - - print('Formating results & gts by classes') - with open(result_path,'r') as f: - pred_results = json.load(f) - gen_results = pred_results['results'] - with open(self.map_ann_file,'r') as ann_f: - gt_anns = json.load(ann_f) - annotations = gt_anns['GTs'] - cls_gens, cls_gts = format_res_gt_by_classes(result_path, - gen_results, - annotations, - cls_names=self.MAPCLASSES, - num_pred_pts_per_instance=self.fixed_num, - eval_use_same_gt_sample_num_flag=self.eval_use_same_gt_sample_num_flag, - pc_range=self.pc_range) - - metrics = metric if isinstance(metric, list) else [metric] - allowed_metrics = ['chamfer', 'iou'] - for metric in metrics: - if metric not in allowed_metrics: - raise KeyError(f'metric {metric} is not supported') - - for metric in metrics: - print('-*'*10+f'use metric:{metric}'+'-*'*10) - - if metric == 'chamfer': - thresholds = [0.5,1.0,1.5] - elif metric == 'iou': - thresholds= np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) - cls_aps = np.zeros((len(thresholds),self.NUM_MAPCLASSES)) - - for i, thr in enumerate(thresholds): - print('-*'*10+f'threshhold:{thr}'+'-*'*10) - mAP, cls_ap = eval_map( - gen_results, - annotations, - cls_gens, - cls_gts, - threshold=thr, - cls_names=self.MAPCLASSES, - logger=logger, - num_pred_pts_per_instance=self.fixed_num, - pc_range=self.pc_range, - metric=metric) - for j in range(self.NUM_MAPCLASSES): - cls_aps[i, j] = cls_ap[j]['ap'] - - for i, name in enumerate(self.MAPCLASSES): - print('{}: {}'.format(name, cls_aps.mean(0)[i])) - detail['AV2Map_{}/{}_AP'.format(metric,name)] = cls_aps.mean(0)[i] - print('map: {}'.format(cls_aps.mean(0).mean())) - detail['AV2Map_{}/mAP'.format(metric)] = cls_aps.mean(0).mean() - - for i, name in enumerate(self.MAPCLASSES): - for j, thr in enumerate(thresholds): - if metric == 'chamfer': - detail['AV2Map_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - elif metric == 'iou': - if thr == 0.5 or thr == 0.75: - detail['AV2Map_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - - return detail - - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['pts_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - - Returns: - dict[str, float]: Results of each evaluation metric. - """ - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name], metric=metric) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files, metric=metric) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - -def output_to_vecs(detection): - box3d = detection['boxes_3d'].numpy() - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - pts = detection['pts_3d'].numpy() - - vec_list = [] - # import pdb;pdb.set_trace() - for i in range(box3d.shape[0]): - vec = dict( - bbox = box3d[i], # xyxy - label=labels[i], - score=scores[i], - pts=pts[i], - ) - vec_list.append(vec) - return vec_list - -def sample_pts_from_line(line, - fixed_num=-1, - sample_dist=1, - normalize=False, - patch_size=None, - padding=False, - num_samples=250,): - if fixed_num < 0: - distances = np.arange(0, line.length, sample_dist) - if line.has_z: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / fixed_num - distances = np.linspace(0, line.length, fixed_num) - if line.has_z: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - if normalize: - sampled_points[:,:2] = sampled_points[:,:2] / np.array([patch_size[1], patch_size[0]]) - - num_valid = len(sampled_points) - - if not padding or fixed_num > 0: - # fixed num sample can return now! - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if fixed_num < 0: - if num_valid < num_samples: - padding = np.zeros((num_samples - len(sampled_points), sampled_points.shape[-1])) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:num_samples, :] - num_valid = num_samples - - if normalize: - sampled_points[:,:2] = sampled_points[:,:2] / np.array([patch_size[1], patch_size[0]]) - num_valid = len(sampled_points) - - return sampled_points[:,:2], num_valid \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_offlinemap_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_offlinemap_dataset.py deleted file mode 100644 index 739c17d5ead62e91d21a32c123c162c59d2193e9..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/av2_offlinemap_dataset.py +++ /dev/null @@ -1,1379 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -import os -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - -from .nuscenes_dataset import CustomNuScenesDataset -from nuscenes.map_expansion.map_api import NuScenesMap, NuScenesMapExplorer -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from shapely import affinity, ops -from shapely.geometry import Polygon, LineString, box, MultiPolygon, MultiLineString -from mmdet.datasets.pipelines import to_tensor -import json - -from pathlib import Path -from av2.datasets.sensor.av2_sensor_dataloader import AV2SensorDataLoader -from av2.map.lane_segment import LaneMarkType, LaneSegment -from av2.map.map_api import ArgoverseStaticMap -from av2.geometry.se3 import SE3 -import av2.geometry.interpolate as interp_utils -import cv2 - -def perspective(cam_coords, proj_mat): - pix_coords = proj_mat @ cam_coords - valid_idx = pix_coords[2, :] > 0 - pix_coords = pix_coords[:, valid_idx] - pix_coords = pix_coords[:2, :] / (pix_coords[2, :] + 1e-7) - pix_coords = pix_coords.transpose(1, 0) - return pix_coords - -class LiDARInstanceLines(object): - """Line instance in LIDAR coordinates - - """ - def __init__(self, - instance_line_list, - instance_labels, - sample_dist=1, - num_samples=250, - padding=False, - fixed_num=-1, - padding_value=-10000, - patch_size=None, - code_size=2, - min_z=-5, - max_z=3,): - assert isinstance(instance_line_list, list) - assert patch_size is not None - if len(instance_line_list) != 0: - assert isinstance(instance_line_list[0], LineString) - self.patch_size = patch_size - self.max_x = self.patch_size[1] / 2 - self.max_y = self.patch_size[0] / 2 - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_num - self.padding_value = padding_value - - self.instance_list = instance_line_list - self.code_size = code_size - self.min_z = min_z - self.max_z = max_z - self.instance_labels = instance_labels - - - @property - def start_end_points(self): - """ - return torch.Tensor([N,4]), in xstart, ystart, xend, yend form - """ - assert len(self.instance_list) != 0 - instance_se_points_list = [] - for instance in self.instance_list: - se_points = [] - se_points.extend(instance.coords[0]) - se_points.extend(instance.coords[-1]) - instance_se_points_list.append(se_points) - instance_se_points_array = np.array(instance_se_points_list) - instance_se_points_tensor = to_tensor(instance_se_points_array) - instance_se_points_tensor = instance_se_points_tensor.to( - dtype=torch.float32) - instance_se_points_tensor[:,0] = torch.clamp(instance_se_points_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,1] = torch.clamp(instance_se_points_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_se_points_tensor[:,2] = torch.clamp(instance_se_points_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,3] = torch.clamp(instance_se_points_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_se_points_tensor - - @property - def bbox(self): - """ - return torch.Tensor([N,4]), in xmin, ymin, xmax, ymax form - """ - assert len(self.instance_list) != 0 - instance_bbox_list = [] - for instance in self.instance_list: - # bounds is bbox: [xmin, ymin, xmax, ymax] - instance_bbox_list.append(instance.bounds) - instance_bbox_array = np.array(instance_bbox_list) - instance_bbox_tensor = to_tensor(instance_bbox_array) - instance_bbox_tensor = instance_bbox_tensor.to( - dtype=torch.float32) - instance_bbox_tensor[:,0] = torch.clamp(instance_bbox_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,1] = torch.clamp(instance_bbox_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_bbox_tensor[:,2] = torch.clamp(instance_bbox_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,3] = torch.clamp(instance_bbox_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_bbox_tensor - - @property - def fixed_num_sampled_points(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # instance_array = np.array(list(instance.coords)) - # interpolated_instance = interp_utils.interp_arc(t=self.fixed_num, points=instance_array) - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]) - if instance.has_z: - sampled_points = sampled_points.reshape(-1,3) - else: - sampled_points = sampled_points.reshape(-1,2) - # import pdb;pdb.set_trace() - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor[:,:,2] = torch.clamp(instance_points_tensor[:,:,2], min=self.min_z,max=self.max_z) - return instance_points_tensor - - @property - def fixed_num_sampled_points_ambiguity(self): - """ - return torch.Tensor([N,fixed_num,3]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - if instance.has_z: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor[:,:,2] = torch.clamp(instance_points_tensor[:,:,2], min=self.min_z,max=self.max_z) - instance_points_tensor = instance_points_tensor if is_3d else instance_points_tensor[:,:,:2] - instance_points_tensor = instance_points_tensor.unsqueeze(1) - return instance_points_tensor - - @property - def fixed_num_sampled_points_torch(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # distances = np.linspace(0, instance.length, self.fixed_num) - # sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - poly_pts = to_tensor(np.array(list(instance.coords))) - poly_pts = poly_pts.unsqueeze(0).permute(0,2,1) - sampled_pts = torch.nn.functional.interpolate(poly_pts,size=(self.fixed_num),mode='linear',align_corners=True) - sampled_pts = sampled_pts.permute(0,2,1).squeeze(0) - instance_points_list.append(sampled_pts) - # instance_points_array = np.array(instance_points_list) - # instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = torch.stack(instance_points_list,dim=0) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor[:,:,2] = torch.clamp(instance_points_tensor[:,:,2], min=self.min_z,max=self.max_z) - return instance_points_tensor - - @property - def shift_fixed_num_sampled_points(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - # import pdb;pdb.set_trace() - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - shift_pts[:,:,2] = torch.clamp(shift_pts[:,:,2], min=self.min_z,max=self.max_z) - - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v1(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - shift_pts[:,:,2] = torch.clamp(shift_pts[:,:,2], min=self.min_z,max=self.max_z) - - if not is_poly: - padding = torch.full([shift_num-shift_pts.shape[0],pts_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v2(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for idx, instance in enumerate(self.instance_list): - instance_label = self.instance_labels[idx] - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if instance_label == 3: - # import ipdb;ipdb.set_trace() - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(sampled_points) - else: - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - - if shifts_num > final_shift_num: - index = np.random.choice(multi_shifts_pts.shape[0], final_shift_num, replace=False) - multi_shifts_pts = multi_shifts_pts[index] - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - multi_shifts_pts_tensor[:,:,2] = torch.clamp(multi_shifts_pts_tensor[:,:,2], min=self.min_z,max=self.max_z) - - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < final_shift_num: - padding = torch.full([final_shift_num-multi_shifts_pts_tensor.shape[0],self.fixed_num,multi_shifts_pts_tensor.shape[-1]], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor[...,:self.code_size] - - @property - def shift_fixed_num_sampled_points_v3(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - flip_pts_to_shift = np.flip(pts_to_shift, axis=0) - for shift_right_i in range(shift_num): - shift_pts = np.roll(flip_pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, coords_num) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - # import pdb;pdb.set_trace() - if shifts_num > 2*final_shift_num: - index = np.random.choice(shift_num, final_shift_num, replace=False) - flip0_shifts_pts = multi_shifts_pts[index] - flip1_shifts_pts = multi_shifts_pts[index+shift_num] - multi_shifts_pts = np.concatenate((flip0_shifts_pts,flip1_shifts_pts),axis=0) - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - multi_shifts_pts_tensor[:,:,2] = torch.clamp(multi_shifts_pts_tensor[:,:,2], min=self.min_z,max=self.max_z) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < 2*final_shift_num: - padding = torch.full([final_shift_num*2-multi_shifts_pts_tensor.shape[0],self.fixed_num,multi_shifts_pts_tensor.shape[-1]], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v4(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - shift_pts_list = [] - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - flip_pts_to_shift = pts_to_shift.flip(0) - for shift_right_i in range(shift_num): - shift_pts_list.append(flip_pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num*2, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - shift_pts[:,:,2] = torch.clamp(shift_pts[:,:,2], min=self.min_z,max=self.max_z) - - - if not is_poly: - padding = torch.full([shift_num*2-shift_pts.shape[0],pts_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_torch(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points_torch - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - # import pdb;pdb.set_trace() - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - shift_pts[:,:,2] = torch.clamp(shift_pts[:,:,2], min=self.min_z,max=self.max_z) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,shift_pts.shape[-1]], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - # @property - # def polyline_points(self): - # """ - # return [[x0,y0],[x1,y1],...] - # """ - # assert len(self.instance_list) != 0 - # for instance in self.instance_list: - - -class VectorizedAV2LocalMap(object): - CLASS2LABEL = { - 'divider': 0, - 'ped_crossing': 1, - 'boundary': 2, - 'centerline': 3, - 'others': -1 - } - def __init__(self, - canvas_size, - patch_size, - map_classes=['divider','ped_crossing','boundary'], - sample_dist=1, - num_samples=250, - padding=False, - fixed_ptsnum_per_line=-1, - padding_value=-10000, - code_size=2, - min_z=-2, - max_z=2, - thickness=3, - aux_seg = dict( - use_aux_seg=False, - bev_seg=False, - pv_seg=False, - seg_classes=1, - feat_down_sample=32)): - ''' - Args: - fixed_ptsnum_per_line = -1 : no fixed num - ''' - super().__init__() - - self.vec_classes = map_classes - - - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_ptsnum_per_line - self.padding_value = padding_value - - # for semantic mask - self.patch_size = patch_size - self.canvas_size = canvas_size - self.thickness = thickness - self.scale_x = self.canvas_size[1] / self.patch_size[1] - self.scale_y = self.canvas_size[0] / self.patch_size[0] - # self.auxseg_use_sem = auxseg_use_sem - self.aux_seg = aux_seg - self.code_size =code_size - - def gen_vectorized_samples(self, map_annotation, example=None, feat_down_sample=32): - ''' - use lidar2global to get gt map layers - ''' - # avm = ArgoverseStaticMap.from_map_dir(log_map_dirpath, build_raster=False) - - vectors = [] - for vec_class in self.vec_classes: - instance_list = map_annotation[vec_class] - for instance in instance_list: - if instance.shape[0] < 2: - # print('class : {}, instance : {}, instance_list : {}'.format(vec_class, instance, instance_list)) - continue - vectors.append((LineString(np.array(instance)), self.CLASS2LABEL.get(vec_class, -1))) - filtered_vectors = [] - gt_pts_loc_3d = [] - gt_pts_num_3d = [] - gt_labels = [] - gt_instance = [] - # import ipdb;ipdb.set_trace() - if self.aux_seg['use_aux_seg']: - if self.aux_seg['seg_classes'] == 1: - if self.aux_seg['bev_seg']: - gt_semantic_mask = np.zeros((1, self.canvas_size[0], self.canvas_size[1]), dtype=np.uint8) - else: - gt_semantic_mask = None - # import ipdb;ipdb.set_trace() - if self.aux_seg['pv_seg']: - num_cam = len(example['img_metas'].data['pad_shape']) - img_shape = example['img_metas'].data['pad_shape'][0] - # import ipdb;ipdb.set_trace() - gt_pv_semantic_mask = np.zeros((num_cam, 1, img_shape[0] // feat_down_sample, img_shape[1] // feat_down_sample), dtype=np.uint8) - lidar2img = example['img_metas'].data['lidar2img'] - scale_factor = np.eye(4) - scale_factor[0, 0] *= 1/32 - scale_factor[1, 1] *= 1/32 - lidar2feat = [scale_factor @ l2i for l2i in lidar2img] - else: - gt_pv_semantic_mask = None - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - if instance.geom_type == 'LineString': - if self.aux_seg['bev_seg']: - self.line_ego_to_mask(instance, gt_semantic_mask[0], color=1, thickness=self.thickness) - if self.aux_seg['pv_seg']: - for cam_index in range(num_cam): - self.line_ego_to_pvmask(instance, gt_pv_semantic_mask[cam_index][0], lidar2feat[cam_index],color=1, thickness=self.aux_seg['pv_thickness']) - else: - print(instance.geom_type) - else: - if self.aux_seg['bev_seg']: - gt_semantic_mask = np.zeros((len(self.vec_classes), self.canvas_size[0], self.canvas_size[1]), dtype=np.uint8) - else: - gt_semantic_mask = None - if self.aux_seg['pv_seg']: - num_cam = len(example['img_metas'].data['pad_shape']) - gt_pv_semantic_mask = np.zeros((num_cam, len(self.vec_classes), img_shape[0] // feat_down_sample, img_shape[1] // feat_down_sample), dtype=np.uint8) - lidar2img = example['img_metas'].data['lidar2img'] - scale_factor = np.eye(4) - scale_factor[0, 0] *= 1/32 - scale_factor[1, 1] *= 1/32 - lidar2feat = [scale_factor @ l2i for l2i in lidar2img] - else: - gt_pv_semantic_mask = None - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - if instance.geom_type == 'LineString': - if self.aux_seg['bev_seg']: - self.line_ego_to_mask(instance, gt_semantic_mask[instance_type], color=1, thickness=self.thickness) - if self.aux_seg['pv_seg']: - for cam_index in range(num_cam): - self.line_ego_to_pvmask(instance, gt_pv_semantic_mask[cam_index][instance_type], lidar2feat[cam_index],color=1, thickness=self.aux_seg['pv_thickness']) - else: - print(instance.geom_type) - else: - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - gt_semantic_mask=None - gt_pv_semantic_mask=None - gt_instance = LiDARInstanceLines(gt_instance, gt_labels, self.sample_dist, - self.num_samples, self.padding, self.fixed_num,self.padding_value, patch_size=self.patch_size, code_size=self.code_size) - - - anns_results = dict( - gt_vecs_pts_loc=gt_instance, - gt_vecs_label=gt_labels, - gt_semantic_mask=gt_semantic_mask, - gt_pv_semantic_mask=gt_pv_semantic_mask, - ) - return anns_results - def line_ego_to_pvmask(self, - line_ego, - mask, - lidar2feat, - color=1, - thickness=1): - distances = np.linspace(0, line_ego.length, 200) - coords = np.array([list(line_ego.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - pts_num = coords.shape[0] - ones = np.ones((pts_num,1)) - lidar_coords = np.concatenate([coords,ones], axis=1).transpose(1,0) - pix_coords = perspective(lidar_coords, lidar2feat) - cv2.polylines(mask, np.int32([pix_coords]), False, color=color, thickness=thickness) - - def line_ego_to_mask(self, - line_ego, - mask, - color=1, - thickness=3): - ''' Rasterize a single line to mask. - - Args: - line_ego (LineString): line - mask (array): semantic mask to paint on - color (int): positive label, default: 1 - thickness (int): thickness of rasterized lines, default: 3 - ''' - - trans_x = self.canvas_size[1] / 2 - trans_y = self.canvas_size[0] / 2 - line_ego = affinity.scale(line_ego, self.scale_x, self.scale_y, origin=(0, 0)) - line_ego = affinity.affine_transform(line_ego, [1.0, 0.0, 0.0, 1.0, trans_x, trans_y]) - # print(np.array(list(line_ego.coords), dtype=np.int32).shape) - coords = np.array(list(line_ego.coords), dtype=np.int32)[:, :2] - coords = coords.reshape((-1, 2)) - assert len(coords) >= 2 - - cv2.polylines(mask, np.int32([coords]), False, color=color, thickness=thickness) - - -@DATASETS.register_module() -class CustomAV2OfflineLocalMapDataset(CustomNuScenesDataset): - r"""NuScenes Dataset. - - This datset add static map elements - """ - MAPCLASSES = ('divider',) - def __init__(self, - map_ann_file=None, - queue_length=4, - z_cfg = dict( - pred_z_flag=True, - gt_z_flag=True, - ), - bev_size=(200, 200), - pc_range=[-51.2, -51.2, -5.0, 51.2, 51.2, 3.0], - overlap_test=False, - fixed_ptsnum_per_line=-1, - eval_use_same_gt_sample_num_flag=False, - padding_value=-10000, - map_classes=None, - aux_seg = dict( - use_aux_seg=False, - bev_seg=False, - pv_seg=False, - seg_classes=1, - feat_down_sample=32, - ), - *args, - **kwargs): - super().__init__(*args, **kwargs) - self.map_ann_file = map_ann_file - self.z_cfg = z_cfg - if z_cfg['gt_z_flag']: - self.code_size = 3 - else: - self.code_size = 2 - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - self.MAPCLASSES = self.get_map_classes(map_classes) - self.NUM_MAPCLASSES = len(self.MAPCLASSES) - self.pc_range = pc_range - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - self.patch_size = (patch_h, patch_w) - self.min_z = pc_range[2] - self.max_z = pc_range[5] - self.padding_value = padding_value - self.fixed_num = fixed_ptsnum_per_line - self.eval_use_same_gt_sample_num_flag = eval_use_same_gt_sample_num_flag - self.aux_seg = aux_seg - self.vector_map = VectorizedAV2LocalMap(canvas_size=bev_size, - patch_size=self.patch_size, - map_classes=self.MAPCLASSES, - fixed_ptsnum_per_line=fixed_ptsnum_per_line, - padding_value=self.padding_value, - code_size=self.code_size, - min_z=self.min_z, - max_z=self.max_z, - aux_seg=aux_seg) - self.is_vis_on_test = False - - def load_annotations(self, ann_file): - """Load annotations from ann_file. - - Args: - ann_file (str): Path of the annotation file. - - Returns: - list[dict]: List of annotations sorted by timestamps. - """ - - data = mmcv.load(ann_file, file_format='pkl') - # import pdb;pdb.set_trace() - data_infos = list(sorted(data['samples'], key=lambda e: e['timestamp'])) - data_infos = data_infos[::self.load_interval] - # data_infos = [ data_info.update(dict(token= str(data_info['timestamp']+data_info['log_id']))) for data_info in data_infos] - self.metadata = None - self.version = None - return data_infos - - @classmethod - def get_map_classes(cls, map_classes=None): - """Get class names of current dataset. - - Args: - classes (Sequence[str] | str | None): If classes is None, use - default CLASSES defined by builtin dataset. If classes is a - string, take it as a file name. The file contains the name of - classes where each line contains one class name. If classes is - a tuple or list, override the CLASSES defined by the dataset. - - Return: - list[str]: A list of class names. - """ - if map_classes is None: - return cls.MAPCLASSES - - if isinstance(map_classes, str): - # take it as a file path - class_names = mmcv.list_from_file(map_classes) - elif isinstance(map_classes, (tuple, list)): - class_names = map_classes - else: - raise ValueError(f'Unsupported type {type(map_classes)} of map classes.') - - return class_names - def vectormap_pipeline(self, example, input_dict): - ''' - `example` type: - keys: 'img_metas', 'gt_bboxes_3d', 'gt_labels_3d', 'img'; - all keys type is 'DataContainer'; - 'img_metas' cpu_only=True, type is dict, others are false; - 'gt_labels_3d' shape torch.size([num_samples]), stack=False, - padding_value=0, cpu_only=False - 'gt_bboxes_3d': stack=False, cpu_only=True - ''' - # import ipdb;ipdb.set_trace() - - anns_results = self.vector_map.gen_vectorized_samples(input_dict['annotation'] if 'annotation' in input_dict.keys() else input_dict['ann_info'], - example=example, feat_down_sample=self.aux_seg['feat_down_sample']) - - ''' - anns_results, type: dict - 'gt_vecs_pts_loc': list[num_vecs], vec with num_points*2 coordinates - 'gt_vecs_pts_num': list[num_vecs], vec with num_points - 'gt_vecs_label': list[num_vecs], vec with cls index - ''' - gt_vecs_label = to_tensor(anns_results['gt_vecs_label']) - if isinstance(anns_results['gt_vecs_pts_loc'], LiDARInstanceLines): - gt_vecs_pts_loc = anns_results['gt_vecs_pts_loc'] - else: - gt_vecs_pts_loc = to_tensor(anns_results['gt_vecs_pts_loc']) - try: - gt_vecs_pts_loc = gt_vecs_pts_loc.flatten(1).to(dtype=torch.float32) - except: - # empty tensor, will be passed in train, - # but we preserve it for test - gt_vecs_pts_loc = gt_vecs_pts_loc - example['gt_labels_3d'] = DC(gt_vecs_label, cpu_only=False) - example['gt_bboxes_3d'] = DC(gt_vecs_pts_loc, cpu_only=True) - # import pdb;pdb.set_trace() - # if self.is_vis_on_test: - # lidar2global_translation = to_tensor(lidar2global_translation) - # example['lidar2global_translation'] = DC(lidar2global_translation, cpu_only=True) - # else: - # example['img_metas'].data['lidar2global_translation'] = lidar2global_translation - if anns_results['gt_semantic_mask'] is not None: - example['gt_seg_mask'] = DC(to_tensor(anns_results['gt_semantic_mask']), cpu_only=False) - if anns_results['gt_pv_semantic_mask'] is not None: - example['gt_pv_seg_mask'] = DC(to_tensor(anns_results['gt_pv_semantic_mask']), cpu_only=False) - return example - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = [] - - # temporal aug - prev_indexs_list = list(range(index-self.queue_length, index)) - random.shuffle(prev_indexs_list) - prev_indexs_list = sorted(prev_indexs_list[1:], reverse=True) - ## - - input_dict = self.get_data_info(index) - if input_dict is None: - return None - frame_idx = input_dict['timestamp'] - scene_token = input_dict['log_id'] - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - # self.vis_gt(example) - data_queue.insert(0, example) - return self.union2one(data_queue) - - def union2one(self, queue): - """ - convert sample queue into one single sample. - """ - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if i == 0: - metas_map[i]['prev_bev'] = False - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - else: - metas_map[i]['prev_bev'] = True - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - - queue[-1]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - timestamp=info['timestamp'], - pts_filename=info['lidar_path'], - lidar_path=info['lidar_path'], - ego2global_translation=info['e2g_translation'], - ego2global_rotation=info['e2g_rotation'], - log_id=info['log_id'], - scene_token=info['log_id'], - ) - if self.modality['use_camera']: - image_paths = [] - cam_intrinsics = [] - ego2img_rts = [] - ego2cam_rts = [] - cam_types = [] - cam2ego_rts = [] - input_dict["camego2global"] = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['img_fpath']) - # camera intrinsics - camera_intrinsics = np.eye(4).astype(np.float32) - camera_intrinsics[:3, :3] = cam_info["intrinsics"] - # input_dict["camera_intrinsics"].append(camera_intrinsics) - - # ego2img, ego = lidar - ego2cam_rt = cam_info['extrinsics'] - cam2ego_rts.append(np.matrix(ego2cam_rt).I) - - intrinsic = cam_info['intrinsics'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - ego2img_rt = (viewpad @ ego2cam_rt) - ego2img_rts.append(ego2img_rt) - ego2cam_rts.append(ego2cam_rt) - cam_intrinsics.append(viewpad) - cam_types.append(cam_type) - - camego2global = np.eye(4, dtype=np.float32) - camego2global[:3, :3] = cam_info['e2g_rotation'] - camego2global[:3, 3] = cam_info['e2g_translation'] - camego2global = torch.from_numpy(camego2global) - - input_dict["camego2global"].append(camego2global) - - lidar2ego = np.eye(4).astype(np.float32) - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=ego2img_rts, # 认为lidar和ego是同一个坐标系 - camera_intrinsics=cam_intrinsics, - ego2cam=ego2cam_rts, - camera2ego=cam2ego_rts, - cam_type=cam_types, - lidar2ego=lidar2ego, - )) - - # if not self.test_mode: - # # annos = self.get_ann_info(index) - # input_dict['ann_info'] = dict() - input_dict['ann_info'] = info['annotation'] - - translation = input_dict['ego2global_translation'] - can_bus = np.ones(18) - # can_bus.extend(translation.tolist()) - can_bus[:3] = translation - rotation = Quaternion._from_matrix(input_dict['ego2global_rotation']) - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - input_dict['can_bus'] = can_bus - # import pdb;pdb.set_trace() - return input_dict - - def prepare_test_data(self, index): - """Prepare data for testing. - - Args: - index (int): Index for accessing the target data. - - Returns: - dict: Testing data dict of the corresponding index. - """ - input_dict = self.get_data_info(index) - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.is_vis_on_test: - example = self.vectormap_pipeline(example, input_dict) - return example - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - - def _format_gt(self): - gt_annos = [] - # import ipdb;ipdb.set_trace() - print('Start to convert gt map format...') - assert self.map_ann_file is not None - if (not os.path.exists(self.map_ann_file)) : - dataset_length = len(self) - prog_bar = mmcv.ProgressBar(dataset_length) - mapped_class_names = self.MAPCLASSES - for sample_id in range(dataset_length): - sample_token = self.data_infos[sample_id]['token'] - gt_anno = {} - gt_anno['sample_token'] = sample_token - # gt_sample_annos = [] - gt_sample_dict = {} - gt_sample_dict = self.vectormap_pipeline(gt_sample_dict, self.data_infos[sample_id]) - gt_labels = gt_sample_dict['gt_labels_3d'].data.numpy() - gt_vecs = gt_sample_dict['gt_bboxes_3d'].data.instance_list - # import pdb;pdb.set_trace() - gt_vec_list = [] - for i, (gt_label, gt_vec) in enumerate(zip(gt_labels, gt_vecs)): - name = mapped_class_names[gt_label] - anno = dict( - pts=np.array(list(gt_vec.coords))[:,:self.code_size], - pts_num=len(list(gt_vec.coords)), - cls_name=name, - type=gt_label, - ) - gt_vec_list.append(anno) - gt_anno['vectors']=gt_vec_list - gt_annos.append(gt_anno) - - prog_bar.update() - nusc_submissions = { - 'GTs': gt_annos - } - print('\n GT anns writes to', self.map_ann_file) - mmcv.dump(nusc_submissions, self.map_ann_file) - else: - print(f'{self.map_ann_file} exist, not update') - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - - Returns: - str: Path of the output json file. - """ - assert self.map_ann_file is not None - pred_annos = [] - mapped_class_names = self.MAPCLASSES - # import ipdb;ipdb.set_trace() - print('Start to convert map detection format...') - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - pred_anno = {} - vecs = output_to_vecs(det) - sample_token = self.data_infos[sample_id]['token'] - pred_anno['sample_token'] = sample_token - pred_vec_list=[] - for i, vec in enumerate(vecs): - name = mapped_class_names[vec['label']] - anno = dict( - # sample_token=sample_token, - pts=vec['pts'], - pts_num=len(vec['pts']), - cls_name=name, - type=vec['label'], - confidence_level=vec['score']) - pred_vec_list.append(anno) - # annos.append(nusc_anno) - # nusc_annos[sample_token] = annos - pred_anno['vectors'] = pred_vec_list - pred_annos.append(pred_anno) - - - if not os.path.exists(self.map_ann_file): - self._format_gt() - else: - print(f'{self.map_ann_file} exist, not update') - # with open(self.map_ann_file,'r') as f: - # GT_anns = json.load(f) - # gt_annos = GT_anns['GTs'] - nusc_submissions = { - 'meta': self.modality, - 'results': pred_annos, - # 'GTs': gt_annos - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'av2map_results.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def to_gt_vectors(self, - gt_dict): - # import pdb;pdb.set_trace() - gt_labels = gt_dict['gt_labels_3d'].data - gt_instances = gt_dict['gt_bboxes_3d'].data.instance_list - - gt_vectors = [] - - for gt_instance, gt_label in zip(gt_instances, gt_labels): - pts, pts_num = sample_pts_from_line(gt_instance, patch_size=self.patch_size) - gt_vectors.append({ - 'pts': pts, - 'pts_num': pts_num, - 'type': int(gt_label) - }) - vector_num_list = {} - for i in range(self.NUM_MAPCLASSES): - vector_num_list[i] = [] - for vec in gt_vectors: - if vector['pts_num'] >= 2: - vector_num_list[vector['type']].append((LineString(vector['pts'][:vector['pts_num']]), vector.get('confidence_level', 1))) - return gt_vectors - - def _evaluate_single(self, - result_path, - logger=None, - metric='chamfer', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import eval_map - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import format_res_gt_by_classes - result_path = osp.abspath(result_path) - # import pdb;pdb.set_trace() - detail = dict() - - print('Formating results & gts by classes') - with open(result_path,'r') as f: - pred_results = json.load(f) - gen_results = pred_results['results'] - with open(self.map_ann_file,'r') as ann_f: - gt_anns = json.load(ann_f) - annotations = gt_anns['GTs'] - cls_gens, cls_gts = format_res_gt_by_classes(result_path, - gen_results, - annotations, - cls_names=self.MAPCLASSES, - num_pred_pts_per_instance=self.fixed_num, - eval_use_same_gt_sample_num_flag=self.eval_use_same_gt_sample_num_flag, - pc_range=self.pc_range, - code_size=self.code_size) - - metrics = metric if isinstance(metric, list) else [metric] - allowed_metrics = ['chamfer', 'iou'] - for metric in metrics: - if metric not in allowed_metrics: - raise KeyError(f'metric {metric} is not supported') - - for metric in metrics: - print('-*'*10+f'use metric:{metric}'+'-*'*10) - - if metric == 'chamfer': - thresholds = [0.5,1.0,1.5] - elif metric == 'iou': - thresholds= np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) - cls_aps = np.zeros((len(thresholds),self.NUM_MAPCLASSES)) - - for i, thr in enumerate(thresholds): - print('-*'*10+f'threshhold:{thr}'+'-*'*10) - mAP, cls_ap = eval_map( - gen_results, - annotations, - cls_gens, - cls_gts, - threshold=thr, - cls_names=self.MAPCLASSES, - logger=logger, - num_pred_pts_per_instance=self.fixed_num, - pc_range=self.pc_range, - metric=metric, - code_size=self.code_size) - for j in range(self.NUM_MAPCLASSES): - cls_aps[i, j] = cls_ap[j]['ap'] - - for i, name in enumerate(self.MAPCLASSES): - print('{}: {}'.format(name, cls_aps.mean(0)[i])) - detail['AV2Map_{}/{}_AP'.format(metric,name)] = cls_aps.mean(0)[i] - print('map: {}'.format(cls_aps.mean(0).mean())) - detail['AV2Map_{}/mAP'.format(metric)] = cls_aps.mean(0).mean() - - for i, name in enumerate(self.MAPCLASSES): - for j, thr in enumerate(thresholds): - if metric == 'chamfer': - detail['AV2Map_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - elif metric == 'iou': - if thr == 0.5 or thr == 0.75: - detail['AV2Map_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - - return detail - - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['pts_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - - Returns: - dict[str, float]: Results of each evaluation metric. - """ - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name], metric=metric) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files, metric=metric) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - -def output_to_vecs(detection): - box3d = detection['boxes_3d'].numpy() - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - pts = detection['pts_3d'].numpy() - - vec_list = [] - # import pdb;pdb.set_trace() - for i in range(box3d.shape[0]): - vec = dict( - bbox = box3d[i], # xyxy - label=labels[i], - score=scores[i], - pts=pts[i], - ) - vec_list.append(vec) - return vec_list - -def sample_pts_from_line(line, - fixed_num=-1, - sample_dist=1, - normalize=False, - patch_size=None, - padding=False, - num_samples=250,): - if fixed_num < 0: - distances = np.arange(0, line.length, sample_dist) - if line.has_z: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / fixed_num - distances = np.linspace(0, line.length, fixed_num) - if line.has_z: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 3) - else: - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - if normalize: - sampled_points[:,:2] = sampled_points[:,:2] / np.array([patch_size[1], patch_size[0]]) - - num_valid = len(sampled_points) - - if not padding or fixed_num > 0: - # fixed num sample can return now! - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if fixed_num < 0: - if num_valid < num_samples: - padding = np.zeros((num_samples - len(sampled_points), sampled_points.shape[-1])) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:num_samples, :] - num_valid = num_samples - - if normalize: - sampled_points[:,:2] = sampled_points[:,:2] / np.array([patch_size[1], patch_size[0]]) - num_valid = len(sampled_points) - - return sampled_points[:,:2], num_valid \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/__init__.py deleted file mode 100644 index 82db209d7a4017ee5cc9740180931416a8724f85..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# from .CD_loss import MyChamferDistance \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/mean_ap.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/mean_ap.py deleted file mode 100644 index da40bb0fb23d6f42346086a19a6c648fc4397803..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/mean_ap.py +++ /dev/null @@ -1,397 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from multiprocessing import Pool -from shapely.geometry import LineString, Polygon -import mmcv -import numpy as np -from mmcv.utils import print_log -from terminaltables import AsciiTable -import json -from os import path as osp -import os -from functools import partial -from .tpfp import custom_tpfp_gen - -def average_precision(recalls, precisions, mode='area'): - """Calculate average precision (for single or multiple scales). - - Args: - recalls (ndarray): shape (num_scales, num_dets) or (num_dets, ) - precisions (ndarray): shape (num_scales, num_dets) or (num_dets, ) - mode (str): 'area' or '11points', 'area' means calculating the area - under precision-recall curve, '11points' means calculating - the average precision of recalls at [0, 0.1, ..., 1] - - Returns: - float or ndarray: calculated average precision - """ - no_scale = False - if recalls.ndim == 1: - no_scale = True - recalls = recalls[np.newaxis, :] - precisions = precisions[np.newaxis, :] - assert recalls.shape == precisions.shape and recalls.ndim == 2 - num_scales = recalls.shape[0] - ap = np.zeros(num_scales, dtype=np.float32) - if mode == 'area': - zeros = np.zeros((num_scales, 1), dtype=recalls.dtype) - ones = np.ones((num_scales, 1), dtype=recalls.dtype) - mrec = np.hstack((zeros, recalls, ones)) - mpre = np.hstack((zeros, precisions, zeros)) - for i in range(mpre.shape[1] - 1, 0, -1): - mpre[:, i - 1] = np.maximum(mpre[:, i - 1], mpre[:, i]) - for i in range(num_scales): - ind = np.where(mrec[i, 1:] != mrec[i, :-1])[0] - ap[i] = np.sum( - (mrec[i, ind + 1] - mrec[i, ind]) * mpre[i, ind + 1]) - elif mode == '11points': - for i in range(num_scales): - for thr in np.arange(0, 1 + 1e-3, 0.1): - precs = precisions[i, recalls[i, :] >= thr] - prec = precs.max() if precs.size > 0 else 0 - ap[i] += prec - ap /= 11 - else: - raise ValueError( - 'Unrecognized mode, only "area" and "11points" are supported') - if no_scale: - ap = ap[0] - return ap - -def get_cls_results(gen_results, - annotations, - num_sample=100, - num_pred_pts_per_instance=30, - eval_use_same_gt_sample_num_flag=False, - class_id=0, - fix_interval=False, - code_size=2): - """Get det results and gt information of a certain class. - - Args: - gen_results (list[list]): Same as `eval_map()`. - annotations (list[dict]): Same as `eval_map()`. - class_id (int): ID of a specific class. - - Returns: - tuple[list[np.ndarray]]: detected bboxes, gt bboxes - """ - # if len(gen_results) == 0 or - - cls_gens, cls_scores = [], [] - for res in gen_results['vectors']: - if res['type'] == class_id: - if len(res['pts']) < 2: - continue - if not eval_use_same_gt_sample_num_flag: - sampled_points = np.array(res['pts']) - else: - line = res['pts'] - line = LineString(line) - - if fix_interval: - distances = list(np.arange(1., line.length, 1.)) - distances = [0,] + distances + [line.length,] - sampled_points = np.array([list(line.interpolate(distance).coords) - for distance in distances]).reshape(-1, code_size) - else: - line_pts = np.array(line.coords) - if line_pts.shape[0] == num_sample: - sampled_points = line_pts - else: - distances = np.linspace(0, line.length, num_sample) - sampled_points = np.array([list(line.interpolate(distance).coords) - for distance in distances]).reshape(-1, code_size) - - cls_gens.append(sampled_points) - cls_scores.append(res['confidence_level']) - num_res = len(cls_gens) - if num_res > 0: - cls_gens = np.stack(cls_gens).reshape(num_res,-1) - cls_scores = np.array(cls_scores)[:,np.newaxis] - cls_gens = np.concatenate([cls_gens,cls_scores],axis=-1) - # print(f'for class {i}, cls_gens has shape {cls_gens.shape}') - else: - if not eval_use_same_gt_sample_num_flag: - cls_gens = np.zeros((0,num_pred_pts_per_instance*code_size+1)) - else: - cls_gens = np.zeros((0,num_sample*code_size+1)) - # print(f'for class {i}, cls_gens has shape {cls_gens.shape}') - - cls_gts = [] - for ann in annotations['vectors']: - if ann['type'] == class_id: - # line = ann['pts'] + np.array((1,1)) # for hdmapnet - line = ann['pts'] - # line = ann['pts'].cumsum(0) - line = LineString(line) - distances = np.linspace(0, line.length, num_sample) - sampled_points = np.array([list(line.interpolate(distance).coords) - for distance in distances]).reshape(-1, code_size) - - cls_gts.append(sampled_points) - num_gts = len(cls_gts) - if num_gts > 0: - cls_gts = np.stack(cls_gts).reshape(num_gts,-1) - else: - cls_gts = np.zeros((0,num_sample*code_size)) - return cls_gens, cls_gts - # ones = np.ones((num_gts,1)) - # tmp_cls_gens = np.concatenate([cls_gts,ones],axis=-1) - # return tmp_cls_gens, cls_gts - -def format_res_gt_by_classes(result_path, - gen_results, - annotations, - cls_names=None, - num_pred_pts_per_instance=30, - eval_use_same_gt_sample_num_flag=False, - pc_range=[-15.0, -30.0, -5.0, 15.0, 30.0, 3.0], - code_size=2, - nproc=24): - assert cls_names is not None - timer = mmcv.Timer() - num_fixed_sample_pts = 100 - fix_interval = False - print('results path: {}'.format(result_path)) - - output_dir = osp.join(*osp.split(result_path)[:-1]) - assert len(gen_results) == len(annotations) - - pool = Pool(nproc) - cls_gens, cls_gts = {}, {} - print('Formatting ...') - formatting_file = 'cls_formatted.pkl' - formatting_file = osp.join(output_dir,formatting_file) - - # for vis - if False: - from PIL import Image - import matplotlib.pyplot as plt - from matplotlib import transforms - from matplotlib.patches import Rectangle - - show_dir = osp.join(output_dir,'vis_json') - mmcv.mkdir_or_exist(osp.abspath(show_dir)) - # import pdb;pdb.set_trace() - car_img = Image.open('./figs/lidar_car.png') - colors_plt = ['r', 'b', 'g'] - for i in range(20): - - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - - for line in gen_results[i]['vectors']: - l = np.array(line['pts']) - plt.plot(l[:,0],l[:,1],'-', - # color=colors[line['type']] - color = 'red', - ) - - for line in annotations[i]['vectors']: - # l = np.array(line['pts']) + np.array((1,1)) - l = np.array(line['pts']) - # l = line['pts'] - plt.plot(l[:,0],l[:,1],'-', - # color=colors[line['type']], - color = 'blue', - ) - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - map_path = osp.join(show_dir, 'COMPARE_MAP_{}.jpg'.format(i)) - plt.savefig(map_path, bbox_inches='tight', dpi=400) - plt.close() - - for i, clsname in enumerate(cls_names): - - gengts = pool.starmap( - partial(get_cls_results, num_sample=num_fixed_sample_pts, - num_pred_pts_per_instance=num_pred_pts_per_instance, - eval_use_same_gt_sample_num_flag=eval_use_same_gt_sample_num_flag,class_id=i,fix_interval=fix_interval, - code_size=code_size), - zip(gen_results, annotations)) - # gengts = map(partial(get_cls_results, num_sample=num_fixed_sample_pts, class_id=i,fix_interval=fix_interval), - # zip(gen_results, annotations)) - # import pdb;pdb.set_trace() - gens, gts = tuple(zip(*gengts)) - cls_gens[clsname] = gens - cls_gts[clsname] = gts - - mmcv.dump([cls_gens, cls_gts],formatting_file) - print('Cls data formatting done in {:2f}s!! with {}'.format(float(timer.since_start()),formatting_file)) - pool.close() - return cls_gens, cls_gts - -def eval_map(gen_results, - annotations, - cls_gens, - cls_gts, - threshold=0.5, - cls_names=None, - logger=None, - tpfp_fn=None, - pc_range=[-15.0, -30.0, -5.0, 15.0, 30.0, 3.0], - metric=None, - num_pred_pts_per_instance=30, - code_size=2, - nproc=24): - timer = mmcv.Timer() - pool = Pool(nproc) - - eval_results = [] - - for i, clsname in enumerate(cls_names): - - # get gt and det bboxes of this class - cls_gen = cls_gens[clsname] - cls_gt = cls_gts[clsname] - # choose proper function according to datasets to compute tp and fp - # XXX - # func_name = cls2func[clsname] - # tpfp_fn = tpfp_fn_dict[tpfp_fn_name] - tpfp_fn = custom_tpfp_gen - # Trick for serialized - # only top-level function can be serized - # somehow use partitial the return function is defined - # at the top level. - - # tpfp = tpfp_fn(cls_gen[i], cls_gt[i],threshold=threshold, metric=metric) - # import pdb; pdb.set_trace() - # TODO this is a hack - tpfp_fn = partial(tpfp_fn, threshold=threshold, metric=metric, code_size=code_size) - args = [] - # compute tp and fp for each image with multiple processes - tpfp = pool.starmap( - tpfp_fn, - zip(cls_gen, cls_gt, *args)) - # import pdb;pdb.set_trace() - tp, fp = tuple(zip(*tpfp)) - - - - # map_results = map( - # tpfp_fn, - # cls_gen, cls_gt) - # tp, fp = tuple(map(list, zip(*map_results))) - - - # debug and testing - # for i in range(len(cls_gen)): - # # print(i) - # tpfp = tpfp_fn(cls_gen[i], cls_gt[i],threshold=threshold) - # print(i) - # tpfp = (tpfp,) - # print(tpfp) - # i = 0 - # tpfp = tpfp_fn(cls_gen[i], cls_gt[i],threshold=threshold) - # import pdb; pdb.set_trace() - - # XXX - - num_gts = 0 - for j, bbox in enumerate(cls_gt): - num_gts += bbox.shape[0] - - # sort all det bboxes by score, also sort tp and fp - # import pdb;pdb.set_trace() - cls_gen = np.vstack(cls_gen) - num_dets = cls_gen.shape[0] - sort_inds = np.argsort(-cls_gen[:, -1]) #descending, high score front - tp = np.hstack(tp)[sort_inds] - fp = np.hstack(fp)[sort_inds] - - # calculate recall and precision with tp and fp - # num_det*num_res - tp = np.cumsum(tp, axis=0) - fp = np.cumsum(fp, axis=0) - eps = np.finfo(np.float32).eps - recalls = tp / np.maximum(num_gts, eps) - precisions = tp / np.maximum((tp + fp), eps) - - # calculate AP - # if dataset != 'voc07' else '11points' - mode = 'area' - ap = average_precision(recalls, precisions, mode) - eval_results.append({ - 'num_gts': num_gts, - 'num_dets': num_dets, - 'recall': recalls, - 'precision': precisions, - 'ap': ap - }) - print('cls:{} done in {:2f}s!!'.format(clsname,float(timer.since_last_check()))) - pool.close() - aps = [] - for cls_result in eval_results: - if cls_result['num_gts'] > 0: - aps.append(cls_result['ap']) - mean_ap = np.array(aps).mean().item() if len(aps) else 0.0 - - print_map_summary( - mean_ap, eval_results, class_name=cls_names, logger=logger) - - return mean_ap, eval_results - - - -def print_map_summary(mean_ap, - results, - class_name=None, - scale_ranges=None, - logger=None): - """Print mAP and results of each class. - - A table will be printed to show the gts/dets/recall/AP of each class and - the mAP. - - Args: - mean_ap (float): Calculated from `eval_map()`. - results (list[dict]): Calculated from `eval_map()`. - dataset (list[str] | str | None): Dataset name or dataset classes. - scale_ranges (list[tuple] | None): Range of scales to be evaluated. - logger (logging.Logger | str | None): The way to print the mAP - summary. See `mmcv.utils.print_log()` for details. Default: None. - """ - - if logger == 'silent': - return - - if isinstance(results[0]['ap'], np.ndarray): - num_scales = len(results[0]['ap']) - else: - num_scales = 1 - - if scale_ranges is not None: - assert len(scale_ranges) == num_scales - - num_classes = len(results) - - recalls = np.zeros((num_scales, num_classes), dtype=np.float32) - aps = np.zeros((num_scales, num_classes), dtype=np.float32) - num_gts = np.zeros((num_scales, num_classes), dtype=int) - for i, cls_result in enumerate(results): - if cls_result['recall'].size > 0: - recalls[:, i] = np.array(cls_result['recall'], ndmin=2)[:, -1] - aps[:, i] = cls_result['ap'] - num_gts[:, i] = cls_result['num_gts'] - - label_names = class_name - - if not isinstance(mean_ap, list): - mean_ap = [mean_ap] - - header = ['class', 'gts', 'dets', 'recall', 'ap'] - for i in range(num_scales): - if scale_ranges is not None: - print_log(f'Scale range {scale_ranges[i]}', logger=logger) - table_data = [header] - for j in range(num_classes): - row_data = [ - label_names[j], num_gts[i, j], results[j]['num_dets'], - f'{recalls[i, j]:.3f}', f'{aps[i, j]:.3f}' - ] - table_data.append(row_data) - table_data.append(['mAP', '', '', '', f'{mean_ap[i]:.3f}']) - table = AsciiTable(table_data) - table.inner_footing_row_border = True - print_log('\n' + table.table, logger=logger) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp.py deleted file mode 100644 index 4c31f2b1bb45915768e64601509b439d4f352eb7..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp.py +++ /dev/null @@ -1,82 +0,0 @@ -import mmcv -import numpy as np - -from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps -from .tpfp_chamfer import custom_polyline_score -from shapely.geometry import LineString, Polygon - - -def custom_tpfp_gen(gen_lines, - gt_lines, - threshold=0.5, - metric='chamfer', - code_size=2): - """Check if detected bboxes are true positive or false positive. - - Args: - det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). - gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). - gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, - of shape (k, 4). Default: None - iou_thr (float): IoU threshold to be considered as matched. - Default: 0.5. - use_legacy_coordinate (bool): Whether to use coordinate system in - mmdet v1.x. which means width, height should be - calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. - Default: False. - - Returns: - tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of - each array is (num_scales, m). - """ - if metric == 'chamfer': - if threshold >0: - threshold= -threshold - # else: - # raise NotImplementedError - - # import pdb;pdb.set_trace() - num_gens = gen_lines.shape[0] - num_gts = gt_lines.shape[0] - - # tp and fp - tp = np.zeros((num_gens), dtype=np.float32) - fp = np.zeros((num_gens), dtype=np.float32) - - # if there is no gt bboxes in this image, then all det bboxes - # within area range are false positives - if num_gts == 0: - fp[...] = 1 - return tp, fp - - if num_gens == 0: - return tp, fp - - gen_scores = gen_lines[:,-1] # n - # distance matrix: n x m - - matrix = custom_polyline_score( - gen_lines[:,:-1].reshape(num_gens,-1,code_size), - gt_lines.reshape(num_gts,-1,code_size),linewidth=2.,metric=metric) - # for each det, the max iou with all gts - matrix_max = matrix.max(axis=1) - # for each det, which gt overlaps most with it - matrix_argmax = matrix.argmax(axis=1) - # sort all dets in descending order by scores - sort_inds = np.argsort(-gen_scores) - - gt_covered = np.zeros(num_gts, dtype=bool) - - # tp = 0 and fp = 0 means ignore this detected bbox, - for i in sort_inds: - if matrix_max[i] >= threshold: - matched_gt = matrix_argmax[i] - if not gt_covered[matched_gt]: - gt_covered[matched_gt] = True - tp[i] = 1 - else: - fp[i] = 1 - else: - fp[i] = 1 - - return tp, fp diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp_chamfer.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp_chamfer.py deleted file mode 100644 index 47c2ebc6dfba616365ed333c14f6e63d8f349304..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/map_utils/tpfp_chamfer.py +++ /dev/null @@ -1,127 +0,0 @@ -# from ..chamfer_dist import ChamferDistance -import numpy as np -from shapely.geometry import LineString, Polygon -from shapely.strtree import STRtree -from shapely.geometry import CAP_STYLE, JOIN_STYLE -from scipy.spatial import distance - - -def custom_polyline_score(pred_lines, gt_lines, linewidth=1., metric='chamfer'): - ''' - each line with 1 meter width - pred_lines: num_preds, List [npts, 2] - gt_lines: num_gts, npts, 2 - gt_mask: num_gts, npts, 2 - ''' - if metric == 'iou': - linewidth = 1.0 - positive_threshold = 1. - num_preds = len(pred_lines) - num_gts = len(gt_lines) - line_length = pred_lines.shape[1] - - # gt_lines = gt_lines + np.array((1.,1.)) - - pred_lines_shapely = \ - [LineString(i).buffer(linewidth, - cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) - for i in pred_lines] - gt_lines_shapely =\ - [LineString(i).buffer(linewidth, - cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) - for i in gt_lines] - - # construct tree - tree = STRtree(pred_lines_shapely) - index_by_id = dict((id(pt), i) for i, pt in enumerate(pred_lines_shapely)) - - - if metric=='chamfer': - iou_matrix = np.full((num_preds, num_gts), -100.) - elif metric=='iou': - iou_matrix = np.zeros((num_preds, num_gts),dtype=np.float64) - else: - raise NotImplementedError - - for i, pline in enumerate(gt_lines_shapely): - - for o in tree.query(pline): - if o.intersects(pline): - pred_id = index_by_id[id(o)] - - if metric=='chamfer': - dist_mat = distance.cdist( - pred_lines[pred_id], gt_lines[i], 'euclidean') - # import pdb;pdb.set_trace() - valid_ab = dist_mat.min(-1).mean() - valid_ba = dist_mat.min(-2).mean() - - iou_matrix[pred_id, i] = -(valid_ba+valid_ab)/2 - elif metric=='iou': - inter = o.intersection(pline).area - union = o.union(pline).area - iou_matrix[pred_id, i] = inter / union - - return iou_matrix - -if __name__ == '__main__': - import torch - - line1 = torch.tensor([ - [1, 5,-1], [3, 5,-1], [5, 5,-1] - ]) - - line0 = torch.tensor([ - [3, 6,-1], [4, 8,-2], [5, 6,-1] - ]) - - line2 = torch.tensor([ - [1, 4,-1], [3, 4,-1], [5, 4,-1] - ]) - - line3 = torch.tensor([ - [4, 4,-1], [3, 3,-2], [5, 3,-3] - ]) - - gt = torch.stack((line2, line3), dim=0).type(torch.float32) - pred = torch.stack((line0, line1), dim=0).type(torch.float32) - - import ipdb; ipdb.set_trace() - # import mmcv - # with mmcv.Timer(): - # gt = upsampler(gt, pts=10) - # pred = upsampler(pred, pts=10) - - import matplotlib.pyplot as plt - from shapely.geometry import LineString - from descartes import PolygonPatch - - iou_matrix = vec_iou(pred,gt) - print(iou_matrix) - # import pdb;pdb.set_trace() - score_matrix = custom_polyline_score(pred, gt, linewidth=1., metric='chamfer') - print(score_matrix) - fig, ax = plt.subplots() - for i in gt: - i = i.numpy() - plt.plot(i[:, 0], i[:, 1], 'o', color='red') - plt.plot(i[:, 0], i[:, 1], '-', color='red') - - dilated = LineString(i).buffer(1, cap_style=CAP_STYLE.round, join_style=JOIN_STYLE.round) - patch1 = PolygonPatch(dilated, fc='red', ec='red', alpha=0.5, zorder=-1) - ax.add_patch(patch1) - - for i in pred: - i = i.numpy() - plt.plot(i[:, 0], i[:, 1], 'o', color='blue') - plt.plot(i[:, 0], i[:, 1], '-', color='blue') - - dilated = LineString(i).buffer(1, cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) - patch1 = PolygonPatch(dilated, fc='blue', ec='blue', alpha=0.5, zorder=-1) - ax.add_patch(patch1) - - - ax.axis('equal') - - - plt.savefig('test3.png') \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py deleted file mode 100644 index 02913ab15d03e8762d6eb4eec3b72b2890dd7432..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_dataset.py +++ /dev/null @@ -1,258 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - - -@DATASETS.register_module() -class CustomNuScenesDataset(NuScenesDataset): - r"""NuScenes Dataset. - - This datset only add camera intrinsics and extrinsics to the results. - """ - - def __init__(self, queue_length=4, bev_size=(200, 200), overlap_test=False, *args, **kwargs): - super().__init__(*args, **kwargs) - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = [] - - # temporal aug - prev_indexs_list = list(range(index-self.queue_length, index)) - random.shuffle(prev_indexs_list) - prev_indexs_list = sorted(prev_indexs_list[1:], reverse=True) - ## - - input_dict = self.get_data_info(index) - if input_dict is None: - return None - frame_idx = input_dict['frame_idx'] - scene_token = input_dict['scene_token'] - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - data_queue.insert(0, example) - for i in prev_indexs_list: - i = max(0, i) - input_dict = self.get_data_info(i) - if input_dict is None: - return None - if input_dict['frame_idx'] < frame_idx and input_dict['scene_token'] == scene_token: - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - frame_idx = input_dict['frame_idx'] - data_queue.insert(0, copy.deepcopy(example)) - return self.union2one(data_queue) - - def union2one(self, queue): - """ - convert sample queue into one single sample. - """ - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if i == 0: - metas_map[i]['prev_bev'] = False - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - else: - metas_map[i]['prev_bev'] = True - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - - queue[-1]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - sample_idx=info['token'], - pts_filename=info['lidar_path'], - sweeps=info['sweeps'], - ego2global_translation=info['ego2global_translation'], - ego2global_rotation=info['ego2global_rotation'], - prev_idx=info['prev'], - next_idx=info['next'], - scene_token=info['scene_token'], - can_bus=info['can_bus'], - frame_idx=info['frame_idx'], - timestamp=info['timestamp'] / 1e6, - ) - - if self.modality['use_camera']: - image_paths = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_intrinsics = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['data_path']) - # obtain lidar to image transformation matrix - lidar2cam_r = np.linalg.inv(cam_info['sensor2lidar_rotation']) - lidar2cam_t = cam_info[ - 'sensor2lidar_translation'] @ lidar2cam_r.T - lidar2cam_rt = np.eye(4) - lidar2cam_rt[:3, :3] = lidar2cam_r.T - lidar2cam_rt[3, :3] = -lidar2cam_t - intrinsic = cam_info['cam_intrinsic'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt.T) - lidar2img_rts.append(lidar2img_rt) - - cam_intrinsics.append(viewpad) - lidar2cam_rts.append(lidar2cam_rt.T) - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam_intrinsic=cam_intrinsics, - lidar2cam=lidar2cam_rts, - )) - - if not self.test_mode: - annos = self.get_ann_info(index) - input_dict['ann_info'] = annos - - rotation = Quaternion(input_dict['ego2global_rotation']) - translation = input_dict['ego2global_translation'] - can_bus = input_dict['can_bus'] - can_bus[:3] = translation - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - - return input_dict - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - - def _evaluate_single(self, - result_path, - logger=None, - metric='bbox', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from nuscenes import NuScenes - self.nusc = NuScenes(version=self.version, dataroot=self.data_root, - verbose=True) - - output_dir = osp.join(*osp.split(result_path)[:-1]) - - eval_set_map = { - 'v1.0-mini': 'mini_val', - 'v1.0-trainval': 'val', - } - self.nusc_eval = NuScenesEval_custom( - self.nusc, - config=self.eval_detection_configs, - result_path=result_path, - eval_set=eval_set_map[self.version], - output_dir=output_dir, - verbose=True, - overlap_test=self.overlap_test, - data_infos=self.data_infos - ) - self.nusc_eval.main(plot_examples=0, render_curves=False) - # record metrics - metrics = mmcv.load(osp.join(output_dir, 'metrics_summary.json')) - detail = dict() - metric_prefix = f'{result_name}_NuScenes' - for name in self.CLASSES: - for k, v in metrics['label_aps'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_AP_dist_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['label_tp_errors'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['tp_errors'].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}'.format(metric_prefix, - self.ErrNameMapping[k])] = val - detail['{}/NDS'.format(metric_prefix)] = metrics['nd_score'] - detail['{}/mAP'.format(metric_prefix)] = metrics['mean_ap'] - return detail diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_map_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_map_dataset.py deleted file mode 100644 index a96dac95e0738e1b4fb79acee0dd2caef73ca671..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_map_dataset.py +++ /dev/null @@ -1,1552 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -import os -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - -from .nuscenes_dataset import CustomNuScenesDataset -from nuscenes.map_expansion.map_api import NuScenesMap, NuScenesMapExplorer -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from shapely import affinity, ops -from shapely.geometry import LineString, box, MultiPolygon, MultiLineString -from mmdet.datasets.pipelines import to_tensor -import json - - -def add_rotation_noise(extrinsics, std=0.01, mean=0.0): - #n = extrinsics.shape[0] - noise_angle = torch.normal(mean, std=std, size=(3,)) - # extrinsics[:, 0:3, 0:3] *= (1 + noise) - sin_noise = torch.sin(noise_angle) - cos_noise = torch.cos(noise_angle) - rotation_matrix = torch.eye(4).view(4, 4) - # rotation_matrix[] - rotation_matrix_x = rotation_matrix.clone() - rotation_matrix_x[1, 1] = cos_noise[0] - rotation_matrix_x[1, 2] = sin_noise[0] - rotation_matrix_x[2, 1] = -sin_noise[0] - rotation_matrix_x[2, 2] = cos_noise[0] - - rotation_matrix_y = rotation_matrix.clone() - rotation_matrix_y[0, 0] = cos_noise[1] - rotation_matrix_y[0, 2] = -sin_noise[1] - rotation_matrix_y[2, 0] = sin_noise[1] - rotation_matrix_y[2, 2] = cos_noise[1] - - rotation_matrix_z = rotation_matrix.clone() - rotation_matrix_z[0, 0] = cos_noise[2] - rotation_matrix_z[0, 1] = sin_noise[2] - rotation_matrix_z[1, 0] = -sin_noise[2] - rotation_matrix_z[1, 1] = cos_noise[2] - - rotation_matrix = rotation_matrix_x @ rotation_matrix_y @ rotation_matrix_z - - rotation = torch.from_numpy(extrinsics.astype(np.float32)) - rotation[:3, -1] = 0.0 - # import pdb;pdb.set_trace() - rotation = rotation_matrix @ rotation - extrinsics[:3, :3] = rotation[:3, :3].numpy() - return extrinsics - - -def add_translation_noise(extrinsics, std=0.01, mean=0.0): - # n = extrinsics.shape[0] - noise = torch.normal(mean, std=std, size=(3,)) - extrinsics[0:3, -1] += noise.numpy() - return extrinsics - -class LiDARInstanceLines(object): - """Line instance in LIDAR coordinates - - """ - def __init__(self, - instance_line_list, - sample_dist=1, - num_samples=250, - padding=False, - fixed_num=-1, - padding_value=-10000, - patch_size=None): - assert isinstance(instance_line_list, list) - assert patch_size is not None - if len(instance_line_list) != 0: - assert isinstance(instance_line_list[0], LineString) - self.patch_size = patch_size - self.max_x = self.patch_size[1] / 2 - self.max_y = self.patch_size[0] / 2 - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_num - self.padding_value = padding_value - - self.instance_list = instance_line_list - - @property - def start_end_points(self): - """ - return torch.Tensor([N,4]), in xstart, ystart, xend, yend form - """ - assert len(self.instance_list) != 0 - instance_se_points_list = [] - for instance in self.instance_list: - se_points = [] - se_points.extend(instance.coords[0]) - se_points.extend(instance.coords[-1]) - instance_se_points_list.append(se_points) - instance_se_points_array = np.array(instance_se_points_list) - instance_se_points_tensor = to_tensor(instance_se_points_array) - instance_se_points_tensor = instance_se_points_tensor.to( - dtype=torch.float32) - instance_se_points_tensor[:,0] = torch.clamp(instance_se_points_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,1] = torch.clamp(instance_se_points_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_se_points_tensor[:,2] = torch.clamp(instance_se_points_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,3] = torch.clamp(instance_se_points_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_se_points_tensor - - @property - def bbox(self): - """ - return torch.Tensor([N,4]), in xmin, ymin, xmax, ymax form - """ - assert len(self.instance_list) != 0 - instance_bbox_list = [] - for instance in self.instance_list: - # bounds is bbox: [xmin, ymin, xmax, ymax] - instance_bbox_list.append(instance.bounds) - instance_bbox_array = np.array(instance_bbox_list) - instance_bbox_tensor = to_tensor(instance_bbox_array) - instance_bbox_tensor = instance_bbox_tensor.to( - dtype=torch.float32) - instance_bbox_tensor[:,0] = torch.clamp(instance_bbox_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,1] = torch.clamp(instance_bbox_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_bbox_tensor[:,2] = torch.clamp(instance_bbox_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,3] = torch.clamp(instance_bbox_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_bbox_tensor - - @property - def fixed_num_sampled_points(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def fixed_num_sampled_points_ambiguity(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor = instance_points_tensor.unsqueeze(1) - return instance_points_tensor - - @property - def fixed_num_sampled_points_torch(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # distances = np.linspace(0, instance.length, self.fixed_num) - # sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - poly_pts = to_tensor(np.array(list(instance.coords))) - poly_pts = poly_pts.unsqueeze(0).permute(0,2,1) - sampled_pts = torch.nn.functional.interpolate(poly_pts,size=(self.fixed_num),mode='linear',align_corners=True) - sampled_pts = sampled_pts.permute(0,2,1).squeeze(0) - instance_points_list.append(sampled_pts) - # instance_points_array = np.array(instance_points_list) - # instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = torch.stack(instance_points_list,dim=0) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def shift_fixed_num_sampled_points(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - # import pdb;pdb.set_trace() - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v1(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num-shift_pts.shape[0],pts_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v2(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - - if shifts_num > final_shift_num: - index = np.random.choice(multi_shifts_pts.shape[0], final_shift_num, replace=False) - multi_shifts_pts = multi_shifts_pts[index] - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < final_shift_num: - padding = torch.full([final_shift_num-multi_shifts_pts_tensor.shape[0],self.fixed_num,2], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v3(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - flip_pts_to_shift = np.flip(pts_to_shift, axis=0) - for shift_right_i in range(shift_num): - shift_pts = np.roll(flip_pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - if shifts_num > 2*final_shift_num: - index = np.random.choice(shift_num, final_shift_num, replace=False) - flip0_shifts_pts = multi_shifts_pts[index] - flip1_shifts_pts = multi_shifts_pts[index+shift_num] - multi_shifts_pts = np.concatenate((flip0_shifts_pts,flip1_shifts_pts),axis=0) - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - if multi_shifts_pts_tensor.shape[0] < 2*final_shift_num: - padding = torch.full([final_shift_num*2-multi_shifts_pts_tensor.shape[0],self.fixed_num,2], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v4(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - for fixed_num_pts in fixed_num_sampled_points: - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - shift_pts_list = [] - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - flip_pts_to_shift = pts_to_shift.flip(0) - for shift_right_i in range(shift_num): - shift_pts_list.append(flip_pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num*2, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num*2-shift_pts.shape[0],pts_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_torch(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points_torch - instances_list = [] - is_poly = False - - for fixed_num_pts in fixed_num_sampled_points: - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - - -class VectorizedLocalMap(object): - CLASS2LABEL = { - 'road_divider': 0, - 'lane_divider': 0, - 'ped_crossing': 1, - 'contours': 2, - 'others': -1 - } - def __init__(self, - dataroot, - patch_size, - map_classes=['divider','ped_crossing','boundary'], - line_classes=['road_divider', 'lane_divider'], - ped_crossing_classes=['ped_crossing'], - contour_classes=['road_segment', 'lane'], - sample_dist=1, - num_samples=250, - padding=False, - fixed_ptsnum_per_line=-1, - padding_value=-10000,): - ''' - Args: - fixed_ptsnum_per_line = -1 : no fixed num - ''' - super().__init__() - self.data_root = dataroot - self.MAPS = ['boston-seaport', 'singapore-hollandvillage', - 'singapore-onenorth', 'singapore-queenstown'] - self.vec_classes = map_classes - self.line_classes = line_classes - self.ped_crossing_classes = ped_crossing_classes - self.polygon_classes = contour_classes - self.nusc_maps = {} - self.map_explorer = {} - for loc in self.MAPS: - self.nusc_maps[loc] = NuScenesMap(dataroot=self.data_root, map_name=loc) - self.map_explorer[loc] = NuScenesMapExplorer(self.nusc_maps[loc]) - - self.patch_size = patch_size - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_ptsnum_per_line - self.padding_value = padding_value - - def gen_vectorized_samples(self, location, lidar2global_translation, lidar2global_rotation): - ''' - use lidar2global to get gt map layers - ''' - - map_pose = lidar2global_translation[:2] - rotation = Quaternion(lidar2global_rotation) - - patch_box = (map_pose[0], map_pose[1], self.patch_size[0], self.patch_size[1]) - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - vectors = [] - for vec_class in self.vec_classes: - if vec_class == 'divider': - line_geom = self.get_map_geom(patch_box, patch_angle, self.line_classes, location) - line_instances_dict = self.line_geoms_to_instances(line_geom) - for line_type, instances in line_instances_dict.items(): - for instance in instances: - vectors.append((instance, self.CLASS2LABEL.get(line_type, -1))) - elif vec_class == 'ped_crossing': - ped_geom = self.get_map_geom(patch_box, patch_angle, self.ped_crossing_classes, location) - ped_instance_list = self.ped_poly_geoms_to_instances(ped_geom) - for instance in ped_instance_list: - vectors.append((instance, self.CLASS2LABEL.get('ped_crossing', -1))) - elif vec_class == 'boundary': - polygon_geom = self.get_map_geom(patch_box, patch_angle, self.polygon_classes, location) - poly_bound_list = self.poly_geoms_to_instances(polygon_geom) - for contour in poly_bound_list: - vectors.append((contour, self.CLASS2LABEL.get('contours', -1))) - else: - raise ValueError(f'WRONG vec_class: {vec_class}') - - filtered_vectors = [] - gt_pts_loc_3d = [] - gt_pts_num_3d = [] - gt_labels = [] - gt_instance = [] - for instance, type in vectors: - if type != -1: - gt_instance.append(instance) - gt_labels.append(type) - - gt_instance = LiDARInstanceLines(gt_instance,self.sample_dist, - self.num_samples, self.padding, self.fixed_num,self.padding_value, patch_size=self.patch_size) - - anns_results = dict( - gt_vecs_pts_loc=gt_instance, - gt_vecs_label=gt_labels, - - ) - return anns_results - - def get_map_geom(self, patch_box, patch_angle, layer_names, location): - map_geom = [] - for layer_name in layer_names: - if layer_name in self.line_classes: - geoms = self.get_divider_line(patch_box, patch_angle, layer_name, location) - map_geom.append((layer_name, geoms)) - elif layer_name in self.polygon_classes: - geoms = self.get_contour_line(patch_box, patch_angle, layer_name, location) - map_geom.append((layer_name, geoms)) - elif layer_name in self.ped_crossing_classes: - geoms = self.get_ped_crossing_line(patch_box, patch_angle, location) - map_geom.append((layer_name, geoms)) - return map_geom - - def _one_type_line_geom_to_vectors(self, line_geom): - line_vectors = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_vectors.append(self.sample_pts_from_line(single_line)) - elif line.geom_type == 'LineString': - line_vectors.append(self.sample_pts_from_line(line)) - else: - raise NotImplementedError - return line_vectors - - def _one_type_line_geom_to_instances(self, line_geom): - line_instances = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_instances.append(single_line) - elif line.geom_type == 'LineString': - line_instances.append(line) - else: - raise NotImplementedError - return line_instances - - def poly_geoms_to_vectors(self, polygon_geom): - roads = polygon_geom[0][1] - lanes = polygon_geom[1][1] - union_roads = ops.unary_union(roads) - union_lanes = ops.unary_union(lanes) - union_segments = ops.unary_union([union_roads, union_lanes]) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_vectors(results) - - def ped_poly_geoms_to_instances(self, ped_geom): - ped = ped_geom[0][1] - union_segments = ops.unary_union(ped) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x - 0.2, -max_y - 0.2, max_x + 0.2, max_y + 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - - def poly_geoms_to_instances(self, polygon_geom): - roads = polygon_geom[0][1] - lanes = polygon_geom[1][1] - union_roads = ops.unary_union(roads) - union_lanes = ops.unary_union(lanes) - union_segments = ops.unary_union([union_roads, union_lanes]) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - def line_geoms_to_vectors(self, line_geom): - line_vectors_dict = dict() - for line_type, a_type_of_lines in line_geom: - one_type_vectors = self._one_type_line_geom_to_vectors(a_type_of_lines) - line_vectors_dict[line_type] = one_type_vectors - - return line_vectors_dict - def line_geoms_to_instances(self, line_geom): - line_instances_dict = dict() - for line_type, a_type_of_lines in line_geom: - one_type_instances = self._one_type_line_geom_to_instances(a_type_of_lines) - line_instances_dict[line_type] = one_type_instances - - return line_instances_dict - - def ped_geoms_to_vectors(self, ped_geom): - ped_geom = ped_geom[0][1] - union_ped = ops.unary_union(ped_geom) - if union_ped.geom_type != 'MultiPolygon': - union_ped = MultiPolygon([union_ped]) - - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - results = [] - for ped_poly in union_ped: - # rect = ped_poly.minimum_rotated_rectangle - ext = ped_poly.exterior - if not ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - results.append(lines) - - return self._one_type_line_geom_to_vectors(results) - - def get_contour_line(self,patch_box,patch_angle,layer_name,location): - if layer_name not in self.map_explorer[location].map_api.non_geometric_polygon_layers: - raise ValueError('{} is not a polygonal layer'.format(layer_name)) - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - - records = getattr(self.map_explorer[location].map_api, layer_name) - - polygon_list = [] - if layer_name == 'drivable_area': - for record in records: - polygons = [self.map_explorer[location].map_api.extract_polygon(polygon_token) for polygon_token in record['polygon_tokens']] - - for polygon in polygons: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - else: - for record in records: - polygon = self.map_explorer[location].map_api.extract_polygon(record['polygon_token']) - - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - def get_divider_line(self,patch_box,patch_angle,layer_name,location): - if layer_name not in self.map_explorer[location].map_api.non_geometric_line_layers: - raise ValueError("{} is not a line layer".format(layer_name)) - - if layer_name is 'traffic_light': - return None - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - - line_list = [] - records = getattr(self.map_explorer[location].map_api, layer_name) - for record in records: - line = self.map_explorer[location].map_api.extract_line(record['line_token']) - if line.is_empty: # Skip lines without nodes. - continue - - new_line = line.intersection(patch) - if not new_line.is_empty: - new_line = affinity.rotate(new_line, -patch_angle, origin=(patch_x, patch_y), use_radians=False) - new_line = affinity.affine_transform(new_line, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - line_list.append(new_line) - - return line_list - - def get_ped_crossing_line(self, patch_box, patch_angle, location): - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - polygon_list = [] - records = getattr(self.map_explorer[location].map_api, 'ped_crossing') - # records = getattr(self.nusc_maps[location], 'ped_crossing') - for record in records: - polygon = self.map_explorer[location].map_api.extract_polygon(record['polygon_token']) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - def sample_pts_from_line(self, line): - if self.fixed_num < 0: - distances = np.arange(0, line.length, self.sample_dist) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / self.fixed_num - distances = np.linspace(0, line.length, self.fixed_num) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - - num_valid = len(sampled_points) - - if not self.padding or self.fixed_num > 0: - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if self.fixed_num < 0: - if num_valid < self.num_samples: - padding = np.zeros((self.num_samples - len(sampled_points), 2)) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:self.num_samples, :] - num_valid = self.num_samples - - - return sampled_points, num_valid - - -@DATASETS.register_module() -class CustomNuScenesLocalMapDataset(CustomNuScenesDataset): - r"""NuScenes Dataset. - - This datset add static map elements - """ - MAPCLASSES = ('divider',) - def __init__(self, - map_ann_file=None, - queue_length=4, - bev_size=(200, 200), - pc_range=[-51.2, -51.2, -5.0, 51.2, 51.2, 3.0], - overlap_test=False, - fixed_ptsnum_per_line=-1, - eval_use_same_gt_sample_num_flag=False, - padding_value=-10000, - map_classes=None, - noise='None', - noise_std=0, - *args, - **kwargs): - super().__init__(*args, **kwargs) - self.map_ann_file = map_ann_file - - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - self.MAPCLASSES = self.get_map_classes(map_classes) - self.NUM_MAPCLASSES = len(self.MAPCLASSES) - self.pc_range = pc_range - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - self.patch_size = (patch_h, patch_w) - self.padding_value = padding_value - self.fixed_num = fixed_ptsnum_per_line - self.eval_use_same_gt_sample_num_flag = eval_use_same_gt_sample_num_flag - self.vector_map = VectorizedLocalMap(kwargs['data_root'], - patch_size=self.patch_size, map_classes=self.MAPCLASSES, - fixed_ptsnum_per_line=fixed_ptsnum_per_line, - padding_value=self.padding_value) - self.is_vis_on_test = False - self.noise = noise - self.noise_std = noise_std - @classmethod - def get_map_classes(cls, map_classes=None): - """Get class names of current dataset. - - Args: - classes (Sequence[str] | str | None): If classes is None, use - default CLASSES defined by builtin dataset. If classes is a - string, take it as a file name. The file contains the name of - classes where each line contains one class name. If classes is - a tuple or list, override the CLASSES defined by the dataset. - - Return: - list[str]: A list of class names. - """ - if map_classes is None: - return cls.MAPCLASSES - - if isinstance(map_classes, str): - # take it as a file path - class_names = mmcv.list_from_file(map_classes) - elif isinstance(map_classes, (tuple, list)): - class_names = map_classes - else: - raise ValueError(f'Unsupported type {type(map_classes)} of map classes.') - - return class_names - def vectormap_pipeline(self, example, input_dict): - ''' - `example` type: - keys: 'img_metas', 'gt_bboxes_3d', 'gt_labels_3d', 'img'; - all keys type is 'DataContainer'; - 'img_metas' cpu_only=True, type is dict, others are false; - 'gt_labels_3d' shape torch.size([num_samples]), stack=False, - padding_value=0, cpu_only=False - 'gt_bboxes_3d': stack=False, cpu_only=True - ''' - # import pdb;pdb.set_trace() - lidar2ego = np.eye(4) - lidar2ego[:3,:3] = Quaternion(input_dict['lidar2ego_rotation']).rotation_matrix - lidar2ego[:3, 3] = input_dict['lidar2ego_translation'] - ego2global = np.eye(4) - ego2global[:3,:3] = Quaternion(input_dict['ego2global_rotation']).rotation_matrix - ego2global[:3, 3] = input_dict['ego2global_translation'] - - lidar2global = ego2global @ lidar2ego - - lidar2global_translation = list(lidar2global[:3,3]) - lidar2global_rotation = list(Quaternion(matrix=lidar2global).q) - - location = input_dict['map_location'] - ego2global_translation = input_dict['ego2global_translation'] - ego2global_rotation = input_dict['ego2global_rotation'] - anns_results = self.vector_map.gen_vectorized_samples(location, lidar2global_translation, lidar2global_rotation) - - ''' - anns_results, type: dict - 'gt_vecs_pts_loc': list[num_vecs], vec with num_points*2 coordinates - 'gt_vecs_pts_num': list[num_vecs], vec with num_points - 'gt_vecs_label': list[num_vecs], vec with cls index - ''' - gt_vecs_label = to_tensor(anns_results['gt_vecs_label']) - if isinstance(anns_results['gt_vecs_pts_loc'], LiDARInstanceLines): - gt_vecs_pts_loc = anns_results['gt_vecs_pts_loc'] - else: - gt_vecs_pts_loc = to_tensor(anns_results['gt_vecs_pts_loc']) - try: - gt_vecs_pts_loc = gt_vecs_pts_loc.flatten(1).to(dtype=torch.float32) - except: - # empty tensor, will be passed in train, - # but we preserve it for test - gt_vecs_pts_loc = gt_vecs_pts_loc - example['gt_labels_3d'] = DC(gt_vecs_label, cpu_only=False) - example['gt_bboxes_3d'] = DC(gt_vecs_pts_loc, cpu_only=True) - return example - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = [] - - # temporal aug - prev_indexs_list = list(range(index-self.queue_length, index)) - random.shuffle(prev_indexs_list) - prev_indexs_list = sorted(prev_indexs_list[1:], reverse=True) - ## - - input_dict = self.get_data_info(index) - if input_dict is None: - return None - frame_idx = input_dict['frame_idx'] - scene_token = input_dict['scene_token'] - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - data_queue.insert(0, example) - for i in prev_indexs_list: - i = max(0, i) - input_dict = self.get_data_info(i) - if input_dict is None: - return None - if input_dict['frame_idx'] < frame_idx and input_dict['scene_token'] == scene_token: - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - frame_idx = input_dict['frame_idx'] - data_queue.insert(0, copy.deepcopy(example)) - return self.union2one(data_queue) - - def union2one(self, queue): - """ - convert sample queue into one single sample. - """ - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if i == 0: - metas_map[i]['prev_bev'] = False - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - else: - metas_map[i]['prev_bev'] = True - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - - queue[-1]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - sample_idx=info['token'], - pts_filename=info['lidar_path'], - lidar_path=info["lidar_path"], - sweeps=info['sweeps'], - ego2global_translation=info['ego2global_translation'], - ego2global_rotation=info['ego2global_rotation'], - lidar2ego_translation=info['lidar2ego_translation'], - lidar2ego_rotation=info['lidar2ego_rotation'], - prev_idx=info['prev'], - next_idx=info['next'], - scene_token=info['scene_token'], - can_bus=info['can_bus'], - frame_idx=info['frame_idx'], - timestamp=info['timestamp'], - map_location = info['map_location'], - ) - # lidar to ego transform - lidar2ego = np.eye(4).astype(np.float32) - lidar2ego[:3, :3] = Quaternion(info["lidar2ego_rotation"]).rotation_matrix - lidar2ego[:3, 3] = info["lidar2ego_translation"] - input_dict["lidar2ego"] = lidar2ego - if self.modality['use_camera']: - image_paths = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_intrinsics = [] - input_dict["camera2ego"] = [] - input_dict["camera_intrinsics"] = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['data_path']) - # obtain lidar to image transformation matrix - lidar2cam_r = np.linalg.inv(cam_info['sensor2lidar_rotation']) - lidar2cam_t = cam_info[ - 'sensor2lidar_translation'] @ lidar2cam_r.T - lidar2cam_rt = np.eye(4) - lidar2cam_rt[:3, :3] = lidar2cam_r.T - lidar2cam_rt[3, :3] = -lidar2cam_t - lidar2cam_rt_t = lidar2cam_rt.T - - if self.noise == 'rotation': - lidar2cam_rt_t = add_rotation_noise(lidar2cam_rt_t, std=self.noise_std) - elif self.noise == 'translation': - lidar2cam_rt_t = add_translation_noise( - lidar2cam_rt_t, std=self.noise_std) - - intrinsic = cam_info['cam_intrinsic'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt_t) - lidar2img_rts.append(lidar2img_rt) - - cam_intrinsics.append(viewpad) - lidar2cam_rts.append(lidar2cam_rt_t) - - # camera to ego transform - camera2ego = np.eye(4).astype(np.float32) - camera2ego[:3, :3] = Quaternion( - cam_info["sensor2ego_rotation"] - ).rotation_matrix - camera2ego[:3, 3] = cam_info["sensor2ego_translation"] - input_dict["camera2ego"].append(camera2ego) - - # camera intrinsics - camera_intrinsics = np.eye(4).astype(np.float32) - camera_intrinsics[:3, :3] = cam_info["cam_intrinsic"] - input_dict["camera_intrinsics"].append(camera_intrinsics) - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam_intrinsic=cam_intrinsics, - lidar2cam=lidar2cam_rts, - )) - - if not self.test_mode: - annos = self.get_ann_info(index) - input_dict['ann_info'] = annos - - rotation = Quaternion(input_dict['ego2global_rotation']) - translation = input_dict['ego2global_translation'] - can_bus = input_dict['can_bus'] - can_bus[:3] = translation - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - - - lidar2ego = np.eye(4) - lidar2ego[:3,:3] = Quaternion(input_dict['lidar2ego_rotation']).rotation_matrix - lidar2ego[:3, 3] = input_dict['lidar2ego_translation'] - ego2global = np.eye(4) - ego2global[:3,:3] = Quaternion(input_dict['ego2global_rotation']).rotation_matrix - ego2global[:3, 3] = input_dict['ego2global_translation'] - lidar2global = ego2global @ lidar2ego - input_dict['lidar2global'] = lidar2global - return input_dict - - def prepare_test_data(self, index): - """Prepare data for testing. - - Args: - index (int): Index for accessing the target data. - - Returns: - dict: Testing data dict of the corresponding index. - """ - input_dict = self.get_data_info(index) - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.is_vis_on_test: - example = self.vectormap_pipeline(example, input_dict) - return example - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - def _format_gt(self): - gt_annos = [] - print('Start to convert gt map format...') - assert self.map_ann_file is not None - if (not os.path.exists(self.map_ann_file)) : - dataset_length = len(self) - prog_bar = mmcv.ProgressBar(dataset_length) - mapped_class_names = self.MAPCLASSES - for sample_id in range(dataset_length): - sample_token = self.data_infos[sample_id]['token'] - gt_anno = {} - gt_anno['sample_token'] = sample_token - # gt_sample_annos = [] - gt_sample_dict = {} - gt_sample_dict = self.vectormap_pipeline(gt_sample_dict, self.data_infos[sample_id]) - gt_labels = gt_sample_dict['gt_labels_3d'].data.numpy() - gt_vecs = gt_sample_dict['gt_bboxes_3d'].data.instance_list - gt_vec_list = [] - for i, (gt_label, gt_vec) in enumerate(zip(gt_labels, gt_vecs)): - name = mapped_class_names[gt_label] - anno = dict( - pts=np.array(list(gt_vec.coords)), - pts_num=len(list(gt_vec.coords)), - cls_name=name, - type=gt_label, - ) - gt_vec_list.append(anno) - gt_anno['vectors']=gt_vec_list - gt_annos.append(gt_anno) - - prog_bar.update() - nusc_submissions = { - 'GTs': gt_annos - } - print('\n GT anns writes to', self.map_ann_file) - mmcv.dump(nusc_submissions, self.map_ann_file) - else: - print(f'{self.map_ann_file} exist, not update') - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - - Returns: - str: Path of the output json file. - """ - assert self.map_ann_file is not None - pred_annos = [] - mapped_class_names = self.MAPCLASSES - # import pdb;pdb.set_trace() - print('Start to convert map detection format...') - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - pred_anno = {} - vecs = output_to_vecs(det) - sample_token = self.data_infos[sample_id]['token'] - pred_anno['sample_token'] = sample_token - pred_vec_list=[] - for i, vec in enumerate(vecs): - name = mapped_class_names[vec['label']] - anno = dict( - pts=vec['pts'], - pts_num=len(vec['pts']), - cls_name=name, - type=vec['label'], - confidence_level=vec['score']) - pred_vec_list.append(anno) - - pred_anno['vectors'] = pred_vec_list - pred_annos.append(pred_anno) - - - if not os.path.exists(self.map_ann_file): - self._format_gt() - else: - print(f'{self.map_ann_file} exist, not update') - - nusc_submissions = { - 'meta': self.modality, - 'results': pred_annos, - - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'nuscmap_results.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def to_gt_vectors(self, - gt_dict): - # import pdb;pdb.set_trace() - gt_labels = gt_dict['gt_labels_3d'].data - gt_instances = gt_dict['gt_bboxes_3d'].data.instance_list - - gt_vectors = [] - - for gt_instance, gt_label in zip(gt_instances, gt_labels): - pts, pts_num = sample_pts_from_line(gt_instance, patch_size=self.patch_size) - gt_vectors.append({ - 'pts': pts, - 'pts_num': pts_num, - 'type': int(gt_label) - }) - vector_num_list = {} - for i in range(self.NUM_MAPCLASSES): - vector_num_list[i] = [] - for vec in gt_vectors: - if vector['pts_num'] >= 2: - vector_num_list[vector['type']].append((LineString(vector['pts'][:vector['pts_num']]), vector.get('confidence_level', 1))) - return gt_vectors - - def _evaluate_single(self, - result_path, - logger=None, - metric='chamfer', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import eval_map - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import format_res_gt_by_classes - result_path = osp.abspath(result_path) - detail = dict() - - print('Formating results & gts by classes') - with open(result_path,'r') as f: - pred_results = json.load(f) - gen_results = pred_results['results'] - with open(self.map_ann_file,'r') as ann_f: - gt_anns = json.load(ann_f) - annotations = gt_anns['GTs'] - cls_gens, cls_gts = format_res_gt_by_classes(result_path, - gen_results, - annotations, - cls_names=self.MAPCLASSES, - num_pred_pts_per_instance=self.fixed_num, - eval_use_same_gt_sample_num_flag=self.eval_use_same_gt_sample_num_flag, - pc_range=self.pc_range) - - metrics = metric if isinstance(metric, list) else [metric] - allowed_metrics = ['chamfer', 'iou'] - for metric in metrics: - if metric not in allowed_metrics: - raise KeyError(f'metric {metric} is not supported') - - for metric in metrics: - print('-*'*10+f'use metric:{metric}'+'-*'*10) - - if metric == 'chamfer': - thresholds = [0.5,1.0,1.5] - elif metric == 'iou': - thresholds= np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) - cls_aps = np.zeros((len(thresholds),self.NUM_MAPCLASSES)) - - for i, thr in enumerate(thresholds): - print('-*'*10+f'threshhold:{thr}'+'-*'*10) - mAP, cls_ap = eval_map( - gen_results, - annotations, - cls_gens, - cls_gts, - threshold=thr, - cls_names=self.MAPCLASSES, - logger=logger, - num_pred_pts_per_instance=self.fixed_num, - pc_range=self.pc_range, - metric=metric) - for j in range(self.NUM_MAPCLASSES): - cls_aps[i, j] = cls_ap[j]['ap'] - - for i, name in enumerate(self.MAPCLASSES): - print('{}: {}'.format(name, cls_aps.mean(0)[i])) - detail['NuscMap_{}/{}_AP'.format(metric,name)] = cls_aps.mean(0)[i] - print('map: {}'.format(cls_aps.mean(0).mean())) - detail['NuscMap_{}/mAP'.format(metric)] = cls_aps.mean(0).mean() - - for i, name in enumerate(self.MAPCLASSES): - for j, thr in enumerate(thresholds): - if metric == 'chamfer': - detail['NuscMap_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - elif metric == 'iou': - if thr == 0.5 or thr == 0.75: - detail['NuscMap_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - - return detail - - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['pts_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - - Returns: - dict[str, float]: Results of each evaluation metric. - """ - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name], metric=metric) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files, metric=metric) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - -def output_to_vecs(detection): - box3d = detection['boxes_3d'].numpy() - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - pts = detection['pts_3d'].numpy() - - vec_list = [] - for i in range(box3d.shape[0]): - vec = dict( - bbox = box3d[i], # xyxy - label=labels[i], - score=scores[i], - pts=pts[i], - ) - vec_list.append(vec) - return vec_list - -def sample_pts_from_line(line, - fixed_num=-1, - sample_dist=1, - normalize=False, - patch_size=None, - padding=False, - num_samples=250,): - if fixed_num < 0: - distances = np.arange(0, line.length, sample_dist) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / fixed_num - distances = np.linspace(0, line.length, fixed_num) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - if normalize: - sampled_points = sampled_points / np.array([patch_size[1], patch_size[0]]) - - num_valid = len(sampled_points) - - if not padding or fixed_num > 0: - # fixed num sample can return now! - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if fixed_num < 0: - if num_valid < num_samples: - padding = np.zeros((num_samples - len(sampled_points), 2)) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:num_samples, :] - num_valid = num_samples - - if normalize: - sampled_points = sampled_points / np.array([patch_size[1], patch_size[0]]) - num_valid = len(sampled_points) - - return sampled_points, num_valid diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py deleted file mode 100644 index b036b87b8b89e2e31ac06f4917b89f8f7682f426..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_mono_dataset.py +++ /dev/null @@ -1,777 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import copy -import mmcv -import numpy as np -import pyquaternion -import tempfile -import torch -import warnings -from nuscenes.utils.data_classes import Box as NuScenesBox -from os import path as osp - -from mmdet3d.core import bbox3d2result, box3d_multiclass_nms, xywhr2xyxyr -from mmdet.datasets import DATASETS, CocoDataset -from mmdet3d.core import show_multi_modality_result -from mmdet3d.core.bbox import CameraInstance3DBoxes, get_box_type -from mmdet3d.datasets.pipelines import Compose -from mmdet3d.datasets.utils import extract_result_dict, get_loading_pipeline - - -@DATASETS.register_module() -class CustomNuScenesMonoDataset(CocoDataset): - r"""Monocular 3D detection on NuScenes Dataset. - This class serves as the API for experiments on the NuScenes Dataset. - Please refer to `NuScenes Dataset `_ - for data downloading. - Args: - ann_file (str): Path of annotation file. - data_root (str): Path of dataset root. - load_interval (int, optional): Interval of loading the dataset. It is - used to uniformly sample the dataset. Defaults to 1. - with_velocity (bool, optional): Whether include velocity prediction - into the experiments. Defaults to True. - modality (dict, optional): Modality to specify the sensor data used - as input. Defaults to None. - box_type_3d (str, optional): Type of 3D box of this dataset. - Based on the `box_type_3d`, the dataset will encapsulate the box - to its original format then converted them to `box_type_3d`. - Defaults to 'Camera' in this class. Available options includes. - - 'LiDAR': Box in LiDAR coordinates. - - 'Depth': Box in depth coordinates, usually for indoor dataset. - - 'Camera': Box in camera coordinates. - eval_version (str, optional): Configuration version of evaluation. - Defaults to 'detection_cvpr_2019'. - use_valid_flag (bool): Whether to use `use_valid_flag` key in the info - file as mask to filter gt_boxes and gt_names. Defaults to False. - version (str, optional): Dataset version. Defaults to 'v1.0-trainval'. - """ - CLASSES = ('car', 'truck', 'trailer', 'bus', 'construction_vehicle', - 'bicycle', 'motorcycle', 'pedestrian', 'traffic_cone', - 'barrier') - DefaultAttribute = { - 'car': 'vehicle.parked', - 'pedestrian': 'pedestrian.moving', - 'trailer': 'vehicle.parked', - 'truck': 'vehicle.parked', - 'bus': 'vehicle.moving', - 'motorcycle': 'cycle.without_rider', - 'construction_vehicle': 'vehicle.parked', - 'bicycle': 'cycle.without_rider', - 'barrier': '', - 'traffic_cone': '', - } - # https://github.com/nutonomy/nuscenes-devkit/blob/57889ff20678577025326cfc24e57424a829be0a/python-sdk/nuscenes/eval/detection/evaluate.py#L222 # noqa - ErrNameMapping = { - 'trans_err': 'mATE', - 'scale_err': 'mASE', - 'orient_err': 'mAOE', - 'vel_err': 'mAVE', - 'attr_err': 'mAAE' - } - - def __init__(self, - data_root, - load_interval=1, - with_velocity=True, - modality=None, - box_type_3d='Camera', - eval_version='detection_cvpr_2019', - use_valid_flag=False, - overlap_test=False, - version='v1.0-trainval', - **kwargs): - super().__init__(**kwargs) - # overlap_test = True - self.data_root = data_root - self.overlap_test = overlap_test - self.load_interval = load_interval - self.with_velocity = with_velocity - self.modality = modality - self.box_type_3d, self.box_mode_3d = get_box_type(box_type_3d) - self.eval_version = eval_version - self.use_valid_flag = use_valid_flag - self.bbox_code_size = 9 - self.version = version - if self.eval_version is not None: - from nuscenes.eval.detection.config import config_factory - self.eval_detection_configs = config_factory(self.eval_version) - if self.modality is None: - self.modality = dict( - use_camera=True, - use_lidar=False, - use_radar=False, - use_map=False, - use_external=False) - - def pre_pipeline(self, results): - """Initialization before data preparation. - Args: - results (dict): Dict before data preprocessing. - - img_fields (list): Image fields. - - bbox3d_fields (list): 3D bounding boxes fields. - - pts_mask_fields (list): Mask fields of points. - - pts_seg_fields (list): Mask fields of point segments. - - bbox_fields (list): Fields of bounding boxes. - - mask_fields (list): Fields of masks. - - seg_fields (list): Segment fields. - - box_type_3d (str): 3D box type. - - box_mode_3d (str): 3D box mode. - """ - results['img_prefix'] = '' # self.img_prefix - # print('img_prefix', self.img_prefix) - results['seg_prefix'] = self.seg_prefix - results['proposal_file'] = self.proposal_file - results['img_fields'] = [] - results['bbox3d_fields'] = [] - results['pts_mask_fields'] = [] - results['pts_seg_fields'] = [] - results['bbox_fields'] = [] - results['mask_fields'] = [] - results['seg_fields'] = [] - results['box_type_3d'] = self.box_type_3d - results['box_mode_3d'] = self.box_mode_3d - - def _parse_ann_info(self, img_info, ann_info): - """Parse bbox annotation. - Args: - img_info (list[dict]): Image info. - ann_info (list[dict]): Annotation info of an image. - Returns: - dict: A dict containing the following keys: bboxes, labels, \ - gt_bboxes_3d, gt_labels_3d, attr_labels, centers2d, \ - depths, bboxes_ignore, masks, seg_map - """ - gt_bboxes = [] - gt_labels = [] - attr_labels = [] - gt_bboxes_ignore = [] - gt_masks_ann = [] - gt_bboxes_cam3d = [] - centers2d = [] - depths = [] - for i, ann in enumerate(ann_info): - if ann.get('ignore', False): - continue - x1, y1, w, h = ann['bbox'] - inter_w = max(0, min(x1 + w, img_info['width']) - max(x1, 0)) - inter_h = max(0, min(y1 + h, img_info['height']) - max(y1, 0)) - if inter_w * inter_h == 0: - continue - if ann['area'] <= 0 or w < 1 or h < 1: - continue - if ann['category_id'] not in self.cat_ids: - continue - bbox = [x1, y1, x1 + w, y1 + h] - if ann.get('iscrowd', False): - gt_bboxes_ignore.append(bbox) - else: - gt_bboxes.append(bbox) - gt_labels.append(self.cat2label[ann['category_id']]) - attr_labels.append(ann['attribute_id']) - gt_masks_ann.append(ann.get('segmentation', None)) - # 3D annotations in camera coordinates - bbox_cam3d = np.array(ann['bbox_cam3d']).reshape(1, -1) - velo_cam3d = np.array(ann['velo_cam3d']).reshape(1, 2) - nan_mask = np.isnan(velo_cam3d[:, 0]) - velo_cam3d[nan_mask] = [0.0, 0.0] - bbox_cam3d = np.concatenate([bbox_cam3d, velo_cam3d], axis=-1) - gt_bboxes_cam3d.append(bbox_cam3d.squeeze()) - # 2.5D annotations in camera coordinates - center2d = ann['center2d'][:2] - depth = ann['center2d'][2] - centers2d.append(center2d) - depths.append(depth) - - if gt_bboxes: - gt_bboxes = np.array(gt_bboxes, dtype=np.float32) - gt_labels = np.array(gt_labels, dtype=np.int64) - attr_labels = np.array(attr_labels, dtype=np.int64) - else: - gt_bboxes = np.zeros((0, 4), dtype=np.float32) - gt_labels = np.array([], dtype=np.int64) - attr_labels = np.array([], dtype=np.int64) - - if gt_bboxes_cam3d: - gt_bboxes_cam3d = np.array(gt_bboxes_cam3d, dtype=np.float32) - centers2d = np.array(centers2d, dtype=np.float32) - depths = np.array(depths, dtype=np.float32) - else: - gt_bboxes_cam3d = np.zeros((0, self.bbox_code_size), - dtype=np.float32) - centers2d = np.zeros((0, 2), dtype=np.float32) - depths = np.zeros((0), dtype=np.float32) - - gt_bboxes_cam3d = CameraInstance3DBoxes( - gt_bboxes_cam3d, - box_dim=gt_bboxes_cam3d.shape[-1], - origin=(0.5, 0.5, 0.5)) - gt_labels_3d = copy.deepcopy(gt_labels) - - if gt_bboxes_ignore: - gt_bboxes_ignore = np.array(gt_bboxes_ignore, dtype=np.float32) - else: - gt_bboxes_ignore = np.zeros((0, 4), dtype=np.float32) - - seg_map = img_info['filename'].replace('jpg', 'png') - - ann = dict( - bboxes=gt_bboxes, - labels=gt_labels, - gt_bboxes_3d=gt_bboxes_cam3d, - gt_labels_3d=gt_labels_3d, - attr_labels=attr_labels, - centers2d=centers2d, - depths=depths, - bboxes_ignore=gt_bboxes_ignore, - masks=gt_masks_ann, - seg_map=seg_map) - - return ann - - def get_attr_name(self, attr_idx, label_name): - """Get attribute from predicted index. - This is a workaround to predict attribute when the predicted velocity - is not reliable. We map the predicted attribute index to the one - in the attribute set. If it is consistent with the category, we will - keep it. Otherwise, we will use the default attribute. - Args: - attr_idx (int): Attribute index. - label_name (str): Predicted category name. - Returns: - str: Predicted attribute name. - """ - # TODO: Simplify the variable name - AttrMapping_rev2 = [ - 'cycle.with_rider', 'cycle.without_rider', 'pedestrian.moving', - 'pedestrian.standing', 'pedestrian.sitting_lying_down', - 'vehicle.moving', 'vehicle.parked', 'vehicle.stopped', 'None' - ] - if label_name == 'car' or label_name == 'bus' \ - or label_name == 'truck' or label_name == 'trailer' \ - or label_name == 'construction_vehicle': - if AttrMapping_rev2[attr_idx] == 'vehicle.moving' or \ - AttrMapping_rev2[attr_idx] == 'vehicle.parked' or \ - AttrMapping_rev2[attr_idx] == 'vehicle.stopped': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - elif label_name == 'pedestrian': - if AttrMapping_rev2[attr_idx] == 'pedestrian.moving' or \ - AttrMapping_rev2[attr_idx] == 'pedestrian.standing' or \ - AttrMapping_rev2[attr_idx] == \ - 'pedestrian.sitting_lying_down': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - elif label_name == 'bicycle' or label_name == 'motorcycle': - if AttrMapping_rev2[attr_idx] == 'cycle.with_rider' or \ - AttrMapping_rev2[attr_idx] == 'cycle.without_rider': - return AttrMapping_rev2[attr_idx] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - else: - return CustomNuScenesMonoDataset.DefaultAttribute[label_name] - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - Returns: - str: Path of the output json file. - """ - nusc_annos = {} - mapped_class_names = self.CLASSES - - print('Start to convert detection format...') - - CAM_NUM = 6 - - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - - if sample_id % CAM_NUM == 0: - boxes_per_frame = [] - attrs_per_frame = [] - - # need to merge results from images of the same sample - annos = [] - boxes, attrs = output_to_nusc_box(det) - sample_token = self.data_infos[sample_id]['token'] - boxes, attrs = cam_nusc_box_to_global(self.data_infos[sample_id], - boxes, attrs, - mapped_class_names, - self.eval_detection_configs, - self.eval_version) - - boxes_per_frame.extend(boxes) - attrs_per_frame.extend(attrs) - # Remove redundant predictions caused by overlap of images - if (sample_id + 1) % CAM_NUM != 0: - continue - boxes = global_nusc_box_to_cam( - self.data_infos[sample_id + 1 - CAM_NUM], boxes_per_frame, - mapped_class_names, self.eval_detection_configs, - self.eval_version) - cam_boxes3d, scores, labels = nusc_box_to_cam_box3d(boxes) - # box nms 3d over 6 images in a frame - # TODO: move this global setting into config - nms_cfg = dict( - use_rotate_nms=True, - nms_across_levels=False, - nms_pre=4096, - nms_thr=0.05, - score_thr=0.01, - min_bbox_size=0, - max_per_frame=500) - from mmcv import Config - nms_cfg = Config(nms_cfg) - cam_boxes3d_for_nms = xywhr2xyxyr(cam_boxes3d.bev) - boxes3d = cam_boxes3d.tensor - # generate attr scores from attr labels - attrs = labels.new_tensor([attr for attr in attrs_per_frame]) - boxes3d, scores, labels, attrs = box3d_multiclass_nms( - boxes3d, - cam_boxes3d_for_nms, - scores, - nms_cfg.score_thr, - nms_cfg.max_per_frame, - nms_cfg, - mlvl_attr_scores=attrs) - cam_boxes3d = CameraInstance3DBoxes(boxes3d, box_dim=9) - det = bbox3d2result(cam_boxes3d, scores, labels, attrs) - boxes, attrs = output_to_nusc_box(det) - boxes, attrs = cam_nusc_box_to_global( - self.data_infos[sample_id + 1 - CAM_NUM], boxes, attrs, - mapped_class_names, self.eval_detection_configs, - self.eval_version) - - for i, box in enumerate(boxes): - name = mapped_class_names[box.label] - attr = self.get_attr_name(attrs[i], name) - nusc_anno = dict( - sample_token=sample_token, - translation=box.center.tolist(), - size=box.wlh.tolist(), - rotation=box.orientation.elements.tolist(), - velocity=box.velocity[:2].tolist(), - detection_name=name, - detection_score=box.score, - attribute_name=attr) - annos.append(nusc_anno) - # other views results of the same frame should be concatenated - if sample_token in nusc_annos: - nusc_annos[sample_token].extend(annos) - else: - nusc_annos[sample_token] = annos - - nusc_submissions = { - 'meta': self.modality, - 'results': nusc_annos, - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'results_nusc.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def _evaluate_single(self, - result_path, - logger=None, - metric='bbox', - result_name='img_bbox'): - """Evaluation for a single model in nuScenes protocol. - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'img_bbox'. - Returns: - dict: Dictionary of evaluation details. - """ - from nuscenes import NuScenes - #from nuscenes.eval.detection.evaluate import NuScenesEval - from .nuscnes_eval import NuScenesEval_custom - output_dir = osp.join(*osp.split(result_path)[:-1]) - self.nusc = NuScenes( - version=self.version, dataroot=self.data_root, verbose=False) - eval_set_map = { - 'v1.0-mini': 'mini_val', - 'v1.0-trainval': 'val', - } - # nusc_eval = NuScenesEval( - # nusc, - # config=self.eval_detection_configs, - # result_path=result_path, - # eval_set=eval_set_map[self.version], - # output_dir=output_dir, - # verbose=False) - self.nusc_eval = NuScenesEval_custom( - self.nusc, - config=self.eval_detection_configs, - result_path=result_path, - eval_set=eval_set_map[self.version], - output_dir=output_dir, - verbose=True, - overlap_test=self.overlap_test, - data_infos=self.data_infos - ) - - self.nusc_eval.main(render_curves=True) - - # record metrics - metrics = mmcv.load(osp.join(output_dir, 'metrics_summary.json')) - detail = dict() - metric_prefix = f'{result_name}_NuScenes' - for name in self.CLASSES: - for k, v in metrics['label_aps'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_AP_dist_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['label_tp_errors'][name].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}_{}'.format(metric_prefix, name, k)] = val - for k, v in metrics['tp_errors'].items(): - val = float('{:.4f}'.format(v)) - detail['{}/{}'.format(metric_prefix, - self.ErrNameMapping[k])] = val - - detail['{}/NDS'.format(metric_prefix)] = metrics['nd_score'] - detail['{}/mAP'.format(metric_prefix)] = metrics['mean_ap'] - return detail - - def format_results(self, results, jsonfile_prefix=None, **kwargs): - """Format the results to json (standard format for COCO evaluation). - Args: - results (list[tuple | numpy.ndarray]): Testing results of the - dataset. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - Returns: - tuple: (result_files, tmp_dir), result_files is a dict containing \ - the json filepaths, tmp_dir is the temporal directory created \ - for saving json files when jsonfile_prefix is not specified. - """ - assert isinstance(results, list), 'results must be a list' - assert len(results) == len(self), ( - 'The length of results is not equal to the dataset len: {} != {}'. - format(len(results), len(self))) - - if jsonfile_prefix is None: - tmp_dir = tempfile.TemporaryDirectory() - jsonfile_prefix = osp.join(tmp_dir.name, 'results') - else: - tmp_dir = None - - # currently the output prediction results could be in two formats - # 1. list of dict('boxes_3d': ..., 'scores_3d': ..., 'labels_3d': ...) - # 2. list of dict('pts_bbox' or 'img_bbox': - # dict('boxes_3d': ..., 'scores_3d': ..., 'labels_3d': ...)) - # this is a workaround to enable evaluation of both formats on nuScenes - # refer to https://github.com/open-mmlab/mmdetection3d/issues/449 - if not ('pts_bbox' in results[0] or 'img_bbox' in results[0]): - result_files = self._format_bbox(results, jsonfile_prefix) - else: - # should take the inner dict out of 'pts_bbox' or 'img_bbox' dict - result_files = dict() - for name in results[0]: - # not evaluate 2D predictions on nuScenes - if '2d' in name: - continue - print(f'\nFormating bboxes of {name}') - results_ = [out[name] for out in results] - tmp_file_ = osp.join(jsonfile_prefix, name) - result_files.update( - {name: self._format_bbox(results_, tmp_file_)}) - - return result_files, tmp_dir - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['img_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - Returns: - dict[str, float]: Results of each evaluation metric. - """ - - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name]) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - def _extract_data(self, index, pipeline, key, load_annos=False): - """Load data using input pipeline and extract data according to key. - Args: - index (int): Index for accessing the target data. - pipeline (:obj:`Compose`): Composed data loading pipeline. - key (str | list[str]): One single or a list of data key. - load_annos (bool): Whether to load data annotations. - If True, need to set self.test_mode as False before loading. - Returns: - np.ndarray | torch.Tensor | list[np.ndarray | torch.Tensor]: - A single or a list of loaded data. - """ - assert pipeline is not None, 'data loading pipeline is not provided' - img_info = self.data_infos[index] - input_dict = dict(img_info=img_info) - - if load_annos: - ann_info = self.get_ann_info(index) - input_dict.update(dict(ann_info=ann_info)) - - self.pre_pipeline(input_dict) - example = pipeline(input_dict) - - # extract data items according to keys - if isinstance(key, str): - data = extract_result_dict(example, key) - else: - data = [extract_result_dict(example, k) for k in key] - - return data - - def _get_pipeline(self, pipeline): - """Get data loading pipeline in self.show/evaluate function. - Args: - pipeline (list[dict] | None): Input pipeline. If None is given, \ - get from self.pipeline. - """ - if pipeline is None: - if not hasattr(self, 'pipeline') or self.pipeline is None: - warnings.warn( - 'Use default pipeline for data loading, this may cause ' - 'errors when data is on ceph') - return self._build_default_pipeline() - loading_pipeline = get_loading_pipeline(self.pipeline.transforms) - return Compose(loading_pipeline) - return Compose(pipeline) - - def _build_default_pipeline(self): - """Build the default pipeline for this dataset.""" - pipeline = [ - dict(type='LoadImageFromFileMono3D'), - dict( - type='DefaultFormatBundle3D', - class_names=self.CLASSES, - with_label=False), - dict(type='Collect3D', keys=['img']) - ] - return Compose(pipeline) - - def show(self, results, out_dir, show=True, pipeline=None): - """Results visualization. - Args: - results (list[dict]): List of bounding boxes results. - out_dir (str): Output directory of visualization result. - show (bool): Visualize the results online. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - """ - assert out_dir is not None, 'Expect out_dir, got none.' - pipeline = self._get_pipeline(pipeline) - for i, result in enumerate(results): - if 'img_bbox' in result.keys(): - result = result['img_bbox'] - data_info = self.data_infos[i] - img_path = data_info['file_name'] - file_name = osp.split(img_path)[-1].split('.')[0] - img, img_metas = self._extract_data(i, pipeline, - ['img', 'img_metas']) - # need to transpose channel to first dim - img = img.numpy().transpose(1, 2, 0) - gt_bboxes = self.get_ann_info(i)['gt_bboxes_3d'] - pred_bboxes = result['boxes_3d'] - show_multi_modality_result( - img, - gt_bboxes, - pred_bboxes, - img_metas['cam2img'], - out_dir, - file_name, - box_mode='camera', - show=show) - - -def output_to_nusc_box(detection): - """Convert the output to the box class in the nuScenes. - Args: - detection (dict): Detection results. - - boxes_3d (:obj:`BaseInstance3DBoxes`): Detection bbox. - - scores_3d (torch.Tensor): Detection scores. - - labels_3d (torch.Tensor): Predicted box labels. - - attrs_3d (torch.Tensor, optional): Predicted attributes. - Returns: - list[:obj:`NuScenesBox`]: List of standard NuScenesBoxes. - """ - box3d = detection['boxes_3d'] - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - attrs = None - if 'attrs_3d' in detection: - attrs = detection['attrs_3d'].numpy() - - box_gravity_center = box3d.gravity_center.numpy() - box_dims = box3d.dims.numpy() - box_yaw = box3d.yaw.numpy() - - # convert the dim/rot to nuscbox convention - box_dims[:, [0, 1, 2]] = box_dims[:, [2, 0, 1]] - box_yaw = -box_yaw - - box_list = [] - for i in range(len(box3d)): - q1 = pyquaternion.Quaternion(axis=[0, 0, 1], radians=box_yaw[i]) - q2 = pyquaternion.Quaternion(axis=[1, 0, 0], radians=np.pi / 2) - quat = q2 * q1 - velocity = (box3d.tensor[i, 7], 0.0, box3d.tensor[i, 8]) - box = NuScenesBox( - box_gravity_center[i], - box_dims[i], - quat, - label=labels[i], - score=scores[i], - velocity=velocity) - box_list.append(box) - return box_list, attrs - - -def cam_nusc_box_to_global(info, - boxes, - attrs, - classes, - eval_configs, - eval_version='detection_cvpr_2019'): - """Convert the box from camera to global coordinate. - Args: - info (dict): Info for a specific sample data, including the - calibration information. - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - classes (list[str]): Mapped classes in the evaluation. - eval_configs (object): Evaluation configuration object. - eval_version (str): Evaluation version. - Default: 'detection_cvpr_2019' - Returns: - list: List of standard NuScenesBoxes in the global - coordinate. - """ - box_list = [] - attr_list = [] - for (box, attr) in zip(boxes, attrs): - # Move box to ego vehicle coord system - box.rotate(pyquaternion.Quaternion(info['cam2ego_rotation'])) - box.translate(np.array(info['cam2ego_translation'])) - # filter det in ego. - cls_range_map = eval_configs.class_range - radius = np.linalg.norm(box.center[:2], 2) - det_range = cls_range_map[classes[box.label]] - if radius > det_range: - continue - # Move box to global coord system - box.rotate(pyquaternion.Quaternion(info['ego2global_rotation'])) - box.translate(np.array(info['ego2global_translation'])) - box_list.append(box) - attr_list.append(attr) - return box_list, attr_list - - -def global_nusc_box_to_cam(info, - boxes, - classes, - eval_configs, - eval_version='detection_cvpr_2019'): - """Convert the box from global to camera coordinate. - Args: - info (dict): Info for a specific sample data, including the - calibration information. - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - classes (list[str]): Mapped classes in the evaluation. - eval_configs (object): Evaluation configuration object. - eval_version (str): Evaluation version. - Default: 'detection_cvpr_2019' - Returns: - list: List of standard NuScenesBoxes in the global - coordinate. - """ - box_list = [] - for box in boxes: - # Move box to ego vehicle coord system - box.translate(-np.array(info['ego2global_translation'])) - box.rotate( - pyquaternion.Quaternion(info['ego2global_rotation']).inverse) - # filter det in ego. - cls_range_map = eval_configs.class_range - radius = np.linalg.norm(box.center[:2], 2) - det_range = cls_range_map[classes[box.label]] - if radius > det_range: - continue - # Move box to camera coord system - box.translate(-np.array(info['cam2ego_translation'])) - box.rotate(pyquaternion.Quaternion(info['cam2ego_rotation']).inverse) - box_list.append(box) - return box_list - - -def nusc_box_to_cam_box3d(boxes): - """Convert boxes from :obj:`NuScenesBox` to :obj:`CameraInstance3DBoxes`. - Args: - boxes (list[:obj:`NuScenesBox`]): List of predicted NuScenesBoxes. - Returns: - tuple (:obj:`CameraInstance3DBoxes` | torch.Tensor | torch.Tensor): \ - Converted 3D bounding boxes, scores and labels. - """ - locs = torch.Tensor([b.center for b in boxes]).view(-1, 3) - dims = torch.Tensor([b.wlh for b in boxes]).view(-1, 3) - rots = torch.Tensor([b.orientation.yaw_pitch_roll[0] - for b in boxes]).view(-1, 1) - velocity = torch.Tensor([b.velocity[:2] for b in boxes]).view(-1, 2) - - # convert nusbox to cambox convention - dims[:, [0, 1, 2]] = dims[:, [1, 2, 0]] - rots = -rots - - boxes_3d = torch.cat([locs, dims, rots, velocity], dim=1).cuda() - cam_boxes3d = CameraInstance3DBoxes( - boxes_3d, box_dim=9, origin=(0.5, 0.5, 0.5)) - scores = torch.Tensor([b.score for b in boxes]).cuda() - labels = torch.LongTensor([b.label for b in boxes]).cuda() - nms_scores = scores.new_zeros(scores.shape[0], 10 + 1) - indices = labels.new_tensor(list(range(scores.shape[0]))) - nms_scores[indices, labels] = scores - return cam_boxes3d, nms_scores, labels \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_offlinemap_dataset.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_offlinemap_dataset.py deleted file mode 100644 index 85b4842f754312ca5a3fc48803993c9511b54037..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/nuscenes_offlinemap_dataset.py +++ /dev/null @@ -1,1762 +0,0 @@ -import copy - -import numpy as np -from mmdet.datasets import DATASETS -from mmdet3d.datasets import NuScenesDataset -import mmcv -import os -from os import path as osp -from mmdet.datasets import DATASETS -import torch -import numpy as np -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from .nuscnes_eval import NuScenesEval_custom -from projects.mmdet3d_plugin.models.utils.visual import save_tensor -from mmcv.parallel import DataContainer as DC -import random - -from .nuscenes_dataset import CustomNuScenesDataset -from nuscenes.map_expansion.map_api import NuScenesMap, NuScenesMapExplorer -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from shapely import affinity, ops -from shapely.geometry import LineString, box, MultiPolygon, MultiLineString -from mmdet.datasets.pipelines import to_tensor -import json -import cv2 - -def add_rotation_noise(extrinsics, std=0.01, mean=0.0): - #n = extrinsics.shape[0] - noise_angle = torch.normal(mean, std=std, size=(3,)) - # extrinsics[:, 0:3, 0:3] *= (1 + noise) - sin_noise = torch.sin(noise_angle) - cos_noise = torch.cos(noise_angle) - rotation_matrix = torch.eye(4).view(4, 4) - # rotation_matrix[] - rotation_matrix_x = rotation_matrix.clone() - rotation_matrix_x[1, 1] = cos_noise[0] - rotation_matrix_x[1, 2] = sin_noise[0] - rotation_matrix_x[2, 1] = -sin_noise[0] - rotation_matrix_x[2, 2] = cos_noise[0] - - rotation_matrix_y = rotation_matrix.clone() - rotation_matrix_y[0, 0] = cos_noise[1] - rotation_matrix_y[0, 2] = -sin_noise[1] - rotation_matrix_y[2, 0] = sin_noise[1] - rotation_matrix_y[2, 2] = cos_noise[1] - - rotation_matrix_z = rotation_matrix.clone() - rotation_matrix_z[0, 0] = cos_noise[2] - rotation_matrix_z[0, 1] = sin_noise[2] - rotation_matrix_z[1, 0] = -sin_noise[2] - rotation_matrix_z[1, 1] = cos_noise[2] - - rotation_matrix = rotation_matrix_x @ rotation_matrix_y @ rotation_matrix_z - - rotation = torch.from_numpy(extrinsics.astype(np.float32)) - rotation[:3, -1] = 0.0 - # import pdb;pdb.set_trace() - rotation = rotation_matrix @ rotation - extrinsics[:3, :3] = rotation[:3, :3].numpy() - return extrinsics - - -def add_translation_noise(extrinsics, std=0.01, mean=0.0): - # n = extrinsics.shape[0] - noise = torch.normal(mean, std=std, size=(3,)) - extrinsics[0:3, -1] += noise.numpy() - return extrinsics - -def perspective(cam_coords, proj_mat): - pix_coords = proj_mat @ cam_coords - valid_idx = pix_coords[2, :] > 0 - pix_coords = pix_coords[:, valid_idx] - pix_coords = pix_coords[:2, :] / (pix_coords[2, :] + 1e-7) - pix_coords = pix_coords.transpose(1, 0) - return pix_coords - -class LiDARInstanceLines(object): - """Line instance in LIDAR coordinates - - """ - def __init__(self, - instance_line_list, - instance_labels, - sample_dist=1, - num_samples=250, - padding=False, - fixed_num=-1, - padding_value=-10000, - patch_size=None): - assert isinstance(instance_line_list, list) - assert patch_size is not None - if len(instance_line_list) != 0: - assert isinstance(instance_line_list[0], LineString) - self.patch_size = patch_size - self.max_x = self.patch_size[1] / 2 - self.max_y = self.patch_size[0] / 2 - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_num - self.padding_value = padding_value - - self.instance_list = instance_line_list - self.instance_labels = instance_labels - - @property - def start_end_points(self): - """ - return torch.Tensor([N,4]), in xstart, ystart, xend, yend form - """ - assert len(self.instance_list) != 0 - instance_se_points_list = [] - for instance in self.instance_list: - se_points = [] - se_points.extend(instance.coords[0]) - se_points.extend(instance.coords[-1]) - instance_se_points_list.append(se_points) - instance_se_points_array = np.array(instance_se_points_list) - instance_se_points_tensor = to_tensor(instance_se_points_array) - instance_se_points_tensor = instance_se_points_tensor.to( - dtype=torch.float32) - instance_se_points_tensor[:,0] = torch.clamp(instance_se_points_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,1] = torch.clamp(instance_se_points_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_se_points_tensor[:,2] = torch.clamp(instance_se_points_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_se_points_tensor[:,3] = torch.clamp(instance_se_points_tensor[:,3], min=-self.max_y,max=self.max_y) - return instance_se_points_tensor - - @property - def bbox(self): - """ - return torch.Tensor([N,4]), in xmin, ymin, xmax, ymax form - """ - assert len(self.instance_list) != 0 - instance_bbox_list = [] - for instance in self.instance_list: - # bounds is bbox: [xmin, ymin, xmax, ymax] - instance_bbox_list.append(instance.bounds) - instance_bbox_array = np.array(instance_bbox_list) - instance_bbox_tensor = to_tensor(instance_bbox_array) - instance_bbox_tensor = instance_bbox_tensor.to( - dtype=torch.float32) - instance_bbox_tensor[:,0] = torch.clamp(instance_bbox_tensor[:,0], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,1] = torch.clamp(instance_bbox_tensor[:,1], min=-self.max_y,max=self.max_y) - instance_bbox_tensor[:,2] = torch.clamp(instance_bbox_tensor[:,2], min=-self.max_x,max=self.max_x) - instance_bbox_tensor[:,3] = torch.clamp(instance_bbox_tensor[:,3], min=-self.max_y,max=self.max_y) - # print("instance_bbox_tensor:", instance_bbox_tensor.shape) - return instance_bbox_tensor - - @property - def fixed_num_sampled_points(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def fixed_num_sampled_points_ambiguity(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - instance_points_list.append(sampled_points) - instance_points_array = np.array(instance_points_list) - instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - instance_points_tensor = instance_points_tensor.unsqueeze(1) - return instance_points_tensor - - @property - def fixed_num_sampled_points_torch(self): - """ - return torch.Tensor([N,fixed_num,2]), in xmin, ymin, xmax, ymax form - N means the num of instances - """ - assert len(self.instance_list) != 0 - instance_points_list = [] - for instance in self.instance_list: - # distances = np.linspace(0, instance.length, self.fixed_num) - # sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - poly_pts = to_tensor(np.array(list(instance.coords))) - poly_pts = poly_pts.unsqueeze(0).permute(0,2,1) - sampled_pts = torch.nn.functional.interpolate(poly_pts,size=(self.fixed_num),mode='linear',align_corners=True) - sampled_pts = sampled_pts.permute(0,2,1).squeeze(0) - instance_points_list.append(sampled_pts) - # instance_points_array = np.array(instance_points_list) - # instance_points_tensor = to_tensor(instance_points_array) - instance_points_tensor = torch.stack(instance_points_list,dim=0) - instance_points_tensor = instance_points_tensor.to( - dtype=torch.float32) - instance_points_tensor[:,:,0] = torch.clamp(instance_points_tensor[:,:,0], min=-self.max_x,max=self.max_x) - instance_points_tensor[:,:,1] = torch.clamp(instance_points_tensor[:,:,1], min=-self.max_y,max=self.max_y) - return instance_points_tensor - - @property - def shift_fixed_num_sampled_points(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(sampled_points) - # if is_poly: - # pts_to_shift = poly_pts[:-1,:] - # for shift_right_i in range(shift_num): - # shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - # pts_to_concat = shift_pts[0] - # pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - # shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - # shift_instance = LineString(shift_pts) - # shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - # shift_pts_list.append(shift_sampled_points) - # # import pdb;pdb.set_trace() - # else: - # sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - # flip_sampled_points = np.flip(sampled_points, axis=0) - # shift_pts_list.append(sampled_points) - # shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - - if shifts_num > final_shift_num: - index = np.random.choice(multi_shifts_pts.shape[0], final_shift_num, replace=False) - multi_shifts_pts = multi_shifts_pts[index] - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < final_shift_num: - padding = torch.full([final_shift_num-multi_shifts_pts_tensor.shape[0],self.fixed_num,2], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v1(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - # is_line = False - # import pdb;pdb.set_trace() - for fixed_num_pts in fixed_num_sampled_points: - # [fixed_num, 2] - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num-shift_pts.shape[0],pts_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - # padding = np.zeros((self.num_samples - len(sampled_points), 2)) - # sampled_points = np.concatenate([sampled_points, padding], axis=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v2(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for idx, instance in enumerate(self.instance_list): - # import ipdb;ipdb.set_trace() - instance_label = self.instance_labels[idx] - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if instance_label == 3: - # import ipdb;ipdb.set_trace() - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(sampled_points) - else: - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - # import pdb;pdb.set_trace() - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - - if shifts_num > final_shift_num: - index = np.random.choice(multi_shifts_pts.shape[0], final_shift_num, replace=False) - multi_shifts_pts = multi_shifts_pts[index] - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - # if not is_poly: - if multi_shifts_pts_tensor.shape[0] < final_shift_num: - padding = torch.full([final_shift_num-multi_shifts_pts_tensor.shape[0],self.fixed_num,2], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - # print("instances_tensor:", instances_tensor.shape) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v3(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - assert len(self.instance_list) != 0 - instances_list = [] - for instance in self.instance_list: - distances = np.linspace(0, instance.length, self.fixed_num) - poly_pts = np.array(list(instance.coords)) - start_pts = poly_pts[0] - end_pts = poly_pts[-1] - is_poly = np.equal(start_pts, end_pts) - is_poly = is_poly.all() - shift_pts_list = [] - pts_num, coords_num = poly_pts.shape - shift_num = pts_num - 1 - final_shift_num = self.fixed_num - 1 - if is_poly: - pts_to_shift = poly_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts = np.roll(pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - flip_pts_to_shift = np.flip(pts_to_shift, axis=0) - for shift_right_i in range(shift_num): - shift_pts = np.roll(flip_pts_to_shift,shift_right_i,axis=0) - pts_to_concat = shift_pts[0] - pts_to_concat = np.expand_dims(pts_to_concat,axis=0) - shift_pts = np.concatenate((shift_pts,pts_to_concat),axis=0) - shift_instance = LineString(shift_pts) - shift_sampled_points = np.array([list(shift_instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - shift_pts_list.append(shift_sampled_points) - else: - sampled_points = np.array([list(instance.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - flip_sampled_points = np.flip(sampled_points, axis=0) - shift_pts_list.append(sampled_points) - shift_pts_list.append(flip_sampled_points) - - multi_shifts_pts = np.stack(shift_pts_list,axis=0) - shifts_num,_,_ = multi_shifts_pts.shape - if shifts_num > 2*final_shift_num: - index = np.random.choice(shift_num, final_shift_num, replace=False) - flip0_shifts_pts = multi_shifts_pts[index] - flip1_shifts_pts = multi_shifts_pts[index+shift_num] - multi_shifts_pts = np.concatenate((flip0_shifts_pts,flip1_shifts_pts),axis=0) - - multi_shifts_pts_tensor = to_tensor(multi_shifts_pts) - multi_shifts_pts_tensor = multi_shifts_pts_tensor.to( - dtype=torch.float32) - - multi_shifts_pts_tensor[:,:,0] = torch.clamp(multi_shifts_pts_tensor[:,:,0], min=-self.max_x,max=self.max_x) - multi_shifts_pts_tensor[:,:,1] = torch.clamp(multi_shifts_pts_tensor[:,:,1], min=-self.max_y,max=self.max_y) - if multi_shifts_pts_tensor.shape[0] < 2*final_shift_num: - padding = torch.full([final_shift_num*2-multi_shifts_pts_tensor.shape[0],self.fixed_num,2], self.padding_value) - multi_shifts_pts_tensor = torch.cat([multi_shifts_pts_tensor,padding],dim=0) - instances_list.append(multi_shifts_pts_tensor) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_v4(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points - instances_list = [] - is_poly = False - for fixed_num_pts in fixed_num_sampled_points: - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - pts_num = fixed_num_pts.shape[0] - shift_num = pts_num - 1 - shift_pts_list = [] - if is_poly: - pts_to_shift = fixed_num_pts[:-1,:] - for shift_right_i in range(shift_num): - shift_pts_list.append(pts_to_shift.roll(shift_right_i,0)) - flip_pts_to_shift = pts_to_shift.flip(0) - for shift_right_i in range(shift_num): - shift_pts_list.append(flip_pts_to_shift.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - if is_poly: - _, _, num_coords = shift_pts.shape - tmp_shift_pts = shift_pts.new_zeros((shift_num*2, pts_num, num_coords)) - tmp_shift_pts[:,:-1,:] = shift_pts - tmp_shift_pts[:,-1,:] = shift_pts[:,0,:] - shift_pts = tmp_shift_pts - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([shift_num*2-shift_pts.shape[0],pts_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - @property - def shift_fixed_num_sampled_points_torch(self): - """ - return [instances_num, num_shifts, fixed_num, 2] - """ - fixed_num_sampled_points = self.fixed_num_sampled_points_torch - instances_list = [] - is_poly = False - - for fixed_num_pts in fixed_num_sampled_points: - is_poly = fixed_num_pts[0].equal(fixed_num_pts[-1]) - fixed_num = fixed_num_pts.shape[0] - shift_pts_list = [] - if is_poly: - for shift_right_i in range(fixed_num): - shift_pts_list.append(fixed_num_pts.roll(shift_right_i,0)) - else: - shift_pts_list.append(fixed_num_pts) - shift_pts_list.append(fixed_num_pts.flip(0)) - shift_pts = torch.stack(shift_pts_list,dim=0) - - shift_pts[:,:,0] = torch.clamp(shift_pts[:,:,0], min=-self.max_x,max=self.max_x) - shift_pts[:,:,1] = torch.clamp(shift_pts[:,:,1], min=-self.max_y,max=self.max_y) - - if not is_poly: - padding = torch.full([fixed_num-shift_pts.shape[0],fixed_num,2], self.padding_value) - shift_pts = torch.cat([shift_pts,padding],dim=0) - instances_list.append(shift_pts) - instances_tensor = torch.stack(instances_list, dim=0) - instances_tensor = instances_tensor.to( - dtype=torch.float32) - return instances_tensor - - - -class VectorizedLocalMap(object): - CLASS2LABEL = { - 'divider': 0, - 'ped_crossing': 1, - 'boundary': 2, - 'centerline': 3, - 'others': -1 - } - def __init__(self, - canvas_size, - patch_size, - map_classes=['divider','ped_crossing','boundary'], - sample_dist=1, - num_samples=250, - padding=False, - fixed_ptsnum_per_line=-1, - padding_value=-10000, - thickness=3, - aux_seg = dict( - use_aux_seg=False, - bev_seg=False, - pv_seg=False, - seg_classes=1, - feat_down_sample=32)): - ''' - Args: - fixed_ptsnum_per_line = -1 : no fixed num - ''' - super().__init__() - - self.vec_classes = map_classes - - - self.sample_dist = sample_dist - self.num_samples = num_samples - self.padding = padding - self.fixed_num = fixed_ptsnum_per_line - self.padding_value = padding_value - - # for semantic mask - self.patch_size = patch_size - self.canvas_size = canvas_size - self.thickness = thickness - self.scale_x = self.canvas_size[1] / self.patch_size[1] - self.scale_y = self.canvas_size[0] / self.patch_size[0] - # self.auxseg_use_sem = auxseg_use_sem - self.aux_seg = aux_seg - - def gen_vectorized_samples(self, map_annotation, example=None, feat_down_sample=32): - ''' - use lidar2global to get gt map layers - ''' - vectors = [] - for vec_class in self.vec_classes: - instance_list = map_annotation[vec_class] - for instance in instance_list: - # vectors.append((LineString(np.array(instance)), self.CLASS2LABEL.get(vec_class, -1))) - vectors.append((LineString(instance), self.CLASS2LABEL.get(vec_class, -1))) - - filtered_vectors = [] - gt_pts_loc_3d = [] - gt_pts_num_3d = [] - gt_labels = [] - gt_instance = [] - if self.aux_seg['use_aux_seg']: - if self.aux_seg['seg_classes'] == 1: - - if self.aux_seg['bev_seg']: - gt_semantic_mask = np.zeros((1, self.canvas_size[0], self.canvas_size[1]), dtype=np.uint8) - else: - gt_semantic_mask = None - - if self.aux_seg['pv_seg']: - num_cam = len(example['img_metas'].data['pad_shape']) - img_shape = example['img_metas'].data['pad_shape'][0] - gt_pv_semantic_mask = np.zeros((num_cam, 1, img_shape[0] // feat_down_sample, img_shape[1] // feat_down_sample), dtype=np.uint8) - lidar2img = example['img_metas'].data['lidar2img'] - scale_factor = np.eye(4) - scale_factor[0, 0] *= 1/32 - scale_factor[1, 1] *= 1/32 - lidar2feat = [scale_factor @ l2i for l2i in lidar2img] - else: - gt_pv_semantic_mask = None - - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - if instance.geom_type == 'LineString': - - if self.aux_seg['bev_seg']: - self.line_ego_to_mask(instance, gt_semantic_mask[0], color=1, thickness=self.thickness) - - if self.aux_seg['pv_seg']: - for cam_index in range(num_cam): - self.line_ego_to_pvmask(instance, gt_pv_semantic_mask[cam_index][0], lidar2feat[cam_index], color=1, thickness=self.aux_seg['pv_thickness']) - - else: - print(instance.geom_type) - - else: - if self.aux_seg['bev_seg']: - gt_semantic_mask = np.zeros((len(self.vec_classes), self.canvas_size[0], self.canvas_size[1]), dtype=np.uint8) - else: - gt_semantic_mask = None - if self.aux_seg['pv_seg']: - num_cam = len(example['img_metas'].data['pad_shape']) - gt_pv_semantic_mask = np.zeros((num_cam, len(self.vec_classes), img_shape[0] // feat_down_sample, img_shape[1] // feat_down_sample), dtype=np.uint8) - lidar2img = example['img_metas'].data['lidar2img'] - scale_factor = np.eye(4) - scale_factor[0, 0] *= 1/32 - scale_factor[1, 1] *= 1/32 - lidar2feat = [scale_factor @ l2i for l2i in lidar2img] - else: - gt_pv_semantic_mask = None - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - if instance.geom_type == 'LineString': - if self.aux_seg['bev_seg']: - self.line_ego_to_mask(instance, gt_semantic_mask[instance_type], color=1, thickness=self.thickness) - if self.aux_seg['pv_seg']: - for cam_index in range(num_cam): - self.line_ego_to_pvmask(instance, gt_pv_semantic_mask[cam_index][instance_type], lidar2feat[cam_index],color=1, thickness=self.aux_seg['pv_thickness']) - else: - print(instance.geom_type) - else: - for instance, instance_type in vectors: - if instance_type != -1: - gt_instance.append(instance) - gt_labels.append(instance_type) - gt_semantic_mask=None - gt_pv_semantic_mask=None - - gt_instance = LiDARInstanceLines(gt_instance, gt_labels, self.sample_dist, - self.num_samples, self.padding, self.fixed_num,self.padding_value, patch_size=self.patch_size) - - anns_results = dict( - gt_vecs_pts_loc=gt_instance, - gt_vecs_label=gt_labels, - gt_semantic_mask=gt_semantic_mask, - gt_pv_semantic_mask=gt_pv_semantic_mask, - ) - return anns_results - - def sample_line(self, line_ego, n_points=200): - x, y = np.array(line_ego.xy) - seg_len = np.sqrt(np.diff(x)**2 + np.diff(y)**2) - cum_len = np.concatenate([[0], np.cumsum(seg_len)]) - total_len = cum_len[-1] - - distances = np.linspace(0, total_len, n_points) - xs = np.interp(distances, cum_len, x) - ys = np.interp(distances, cum_len, y) - coords = np.stack([xs, ys], axis=1) # (N,2) - return coords - - def project_points(self, coords, proj_mat, z=0.0): - pts_num = coords.shape[0] - lidar_coords = np.vstack([ - coords[:,0], - coords[:,1], - np.full(pts_num, z, dtype=coords.dtype), - np.ones(pts_num, dtype=coords.dtype) - ]) - - pix_coords = proj_mat @ lidar_coords - - valid = pix_coords[2,:] > 0 - pix_coords = pix_coords[:, valid] - - pix_coords[:2,:] /= (pix_coords[2:3,:] + 1e-7) - - return pix_coords[:2,:].T - - def line_ego_to_pvmask(self, - line_ego, - mask, - lidar2feat, - color=1, - thickness=1, - z=-1.6): - # distances = np.linspace(0, line_ego.length, 200) - # coords = np.array([list(line_ego.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - # pts_num = coords.shape[0] - # zeros = np.zeros((pts_num,1)) - # zeros[:] = z - # ones = np.ones((pts_num,1)) - # lidar_coords = np.concatenate([coords,zeros,ones], axis=1).transpose(1,0) - # pix_coords = perspective(lidar_coords, lidar2feat) - - coords = self.sample_line(line_ego) - pix_coords = self.project_points(coords, lidar2feat, z=z) - - cv2.polylines(mask, np.int32([pix_coords]), False, color=color, thickness=thickness) - - def scale_translate_geom(self, geom, scale_x, scale_y, trans_x, trans_y, origin=(0, 0)): - x0, y0 = origin - xoff = trans_x + x0 - scale_x * x0 - yoff = trans_y + y0 - scale_y * y0 - matrix = [scale_x, 0.0, 0.0, scale_y, xoff, yoff] - return affinity.affine_transform(geom, matrix) - - def line_ego_to_mask(self, - line_ego, - mask, - color=1, - thickness=3): - ''' Rasterize a single line to mask. - - Args: - line_ego (LineString): line - mask (array): semantic mask to paint on - color (int): positive label, default: 1 - thickness (int): thickness of rasterized lines, default: 3 - ''' - - trans_x = self.canvas_size[1] / 2 - trans_y = self.canvas_size[0] / 2 - - # line_ego = affinity.scale(line_ego, self.scale_x, self.scale_y, origin=(0, 0)) - # line_ego = affinity.affine_transform(line_ego, [1.0, 0.0, 0.0, 1.0, trans_x, trans_y]) - # coords = np.array(list(line_ego.coords), dtype=np.int32)[:, :2] - # coords = coords.reshape((-1, 2)) - # assert len(coords) >= 2 - # cv2.polylines(mask, np.int32([coords]), False, color=color, thickness=thickness) - - line_ego = self.scale_translate_geom(line_ego, self.scale_x, self.scale_y, trans_x, trans_y) - coords = np.asarray(line_ego.coords, dtype=np.int32) - assert len(coords) >= 2 - cv2.polylines(mask, [coords], False, color=color, thickness=thickness) - - def get_map_geom(self, patch_box, patch_angle, layer_names, location): - map_geom = [] - for layer_name in layer_names: - if layer_name in self.line_classes: - geoms = self.get_divider_line(patch_box, patch_angle, layer_name, location) - map_geom.append((layer_name, geoms)) - elif layer_name in self.polygon_classes: - geoms = self.get_contour_line(patch_box, patch_angle, layer_name, location) - map_geom.append((layer_name, geoms)) - elif layer_name in self.ped_crossing_classes: - geoms = self.get_ped_crossing_line(patch_box, patch_angle, location) - map_geom.append((layer_name, geoms)) - return map_geom - - def _one_type_line_geom_to_vectors(self, line_geom): - line_vectors = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_vectors.append(self.sample_pts_from_line(single_line)) - elif line.geom_type == 'LineString': - line_vectors.append(self.sample_pts_from_line(line)) - else: - raise NotImplementedError - return line_vectors - - def _one_type_line_geom_to_instances(self, line_geom): - line_instances = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_instances.append(single_line) - elif line.geom_type == 'LineString': - line_instances.append(line) - else: - raise NotImplementedError - return line_instances - - def poly_geoms_to_vectors(self, polygon_geom): - roads = polygon_geom[0][1] - lanes = polygon_geom[1][1] - union_roads = ops.unary_union(roads) - union_lanes = ops.unary_union(lanes) - union_segments = ops.unary_union([union_roads, union_lanes]) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_vectors(results) - - def ped_poly_geoms_to_instances(self, ped_geom): - ped = ped_geom[0][1] - union_segments = ops.unary_union(ped) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x - 0.2, -max_y - 0.2, max_x + 0.2, max_y + 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - - def poly_geoms_to_instances(self, polygon_geom): - roads = polygon_geom[0][1] - lanes = polygon_geom[1][1] - union_roads = ops.unary_union(roads) - union_lanes = ops.unary_union(lanes) - union_segments = ops.unary_union([union_roads, union_lanes]) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - def line_geoms_to_vectors(self, line_geom): - line_vectors_dict = dict() - for line_type, a_type_of_lines in line_geom: - one_type_vectors = self._one_type_line_geom_to_vectors(a_type_of_lines) - line_vectors_dict[line_type] = one_type_vectors - - return line_vectors_dict - def line_geoms_to_instances(self, line_geom): - line_instances_dict = dict() - for line_type, a_type_of_lines in line_geom: - one_type_instances = self._one_type_line_geom_to_instances(a_type_of_lines) - line_instances_dict[line_type] = one_type_instances - - return line_instances_dict - - def ped_geoms_to_vectors(self, ped_geom): - ped_geom = ped_geom[0][1] - union_ped = ops.unary_union(ped_geom) - if union_ped.geom_type != 'MultiPolygon': - union_ped = MultiPolygon([union_ped]) - - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - results = [] - for ped_poly in union_ped: - # rect = ped_poly.minimum_rotated_rectangle - ext = ped_poly.exterior - if not ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - results.append(lines) - - return self._one_type_line_geom_to_vectors(results) - - def get_contour_line(self,patch_box,patch_angle,layer_name,location): - if layer_name not in self.map_explorer[location].map_api.non_geometric_polygon_layers: - raise ValueError('{} is not a polygonal layer'.format(layer_name)) - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - - records = getattr(self.map_explorer[location].map_api, layer_name) - - polygon_list = [] - if layer_name == 'drivable_area': - for record in records: - polygons = [self.map_explorer[location].map_api.extract_polygon(polygon_token) for polygon_token in record['polygon_tokens']] - - for polygon in polygons: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - else: - for record in records: - polygon = self.map_explorer[location].map_api.extract_polygon(record['polygon_token']) - - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - def get_divider_line(self,patch_box,patch_angle,layer_name,location): - if layer_name not in self.map_explorer[location].map_api.non_geometric_line_layers: - raise ValueError("{} is not a line layer".format(layer_name)) - - if layer_name == 'traffic_light': - return None - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - - line_list = [] - records = getattr(self.map_explorer[location].map_api, layer_name) - for record in records: - line = self.map_explorer[location].map_api.extract_line(record['line_token']) - if line.is_empty: # Skip lines without nodes. - continue - - new_line = line.intersection(patch) - if not new_line.is_empty: - new_line = affinity.rotate(new_line, -patch_angle, origin=(patch_x, patch_y), use_radians=False) - new_line = affinity.affine_transform(new_line, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - line_list.append(new_line) - - return line_list - - def get_ped_crossing_line(self, patch_box, patch_angle, location): - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer[location].get_patch_coord(patch_box, patch_angle) - polygon_list = [] - records = getattr(self.map_explorer[location].map_api, 'ped_crossing') - # records = getattr(self.nusc_maps[location], 'ped_crossing') - for record in records: - polygon = self.map_explorer[location].map_api.extract_polygon(record['polygon_token']) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - def sample_pts_from_line(self, line): - if self.fixed_num < 0: - distances = np.arange(0, line.length, self.sample_dist) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / self.fixed_num - distances = np.linspace(0, line.length, self.fixed_num) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - - num_valid = len(sampled_points) - - if not self.padding or self.fixed_num > 0: - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if self.fixed_num < 0: - if num_valid < self.num_samples: - padding = np.zeros((self.num_samples - len(sampled_points), 2)) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:self.num_samples, :] - num_valid = self.num_samples - - - return sampled_points, num_valid - - -@DATASETS.register_module() -class CustomNuScenesOfflineLocalMapDataset(CustomNuScenesDataset): - r"""NuScenes Dataset. - - This datset add static map elements - """ - MAPCLASSES = ('divider',) - def __init__(self, - map_ann_file=None, - queue_length=4, - bev_size=(200, 200), - pc_range=[-51.2, -51.2, -5.0, 51.2, 51.2, 3.0], - overlap_test=False, - fixed_ptsnum_per_line=-1, - eval_use_same_gt_sample_num_flag=False, - padding_value=-10000, - map_classes=None, - noise='None', - noise_std=0, - aux_seg = dict( - use_aux_seg=False, - bev_seg=False, - pv_seg=False, - seg_classes=1, - feat_down_sample=32, - ), - *args, - **kwargs): - super().__init__(*args, **kwargs) - self.map_ann_file = map_ann_file - - self.queue_length = queue_length - self.overlap_test = overlap_test - self.bev_size = bev_size - - self.MAPCLASSES = self.get_map_classes(map_classes) - self.NUM_MAPCLASSES = len(self.MAPCLASSES) - self.pc_range = pc_range - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - self.patch_size = (patch_h, patch_w) - self.padding_value = padding_value - self.fixed_num = fixed_ptsnum_per_line - self.eval_use_same_gt_sample_num_flag = eval_use_same_gt_sample_num_flag - self.aux_seg = aux_seg - self.vector_map = VectorizedLocalMap(canvas_size=bev_size, - patch_size=self.patch_size, - map_classes=self.MAPCLASSES, - fixed_ptsnum_per_line=fixed_ptsnum_per_line, - padding_value=self.padding_value, - aux_seg=aux_seg) - self.is_vis_on_test = False - self.noise = noise - self.noise_std = noise_std - @classmethod - def get_map_classes(cls, map_classes=None): - """Get class names of current dataset. - - Args: - classes (Sequence[str] | str | None): If classes is None, use - default CLASSES defined by builtin dataset. If classes is a - string, take it as a file name. The file contains the name of - classes where each line contains one class name. If classes is - a tuple or list, override the CLASSES defined by the dataset. - - Return: - list[str]: A list of class names. - """ - if map_classes is None: - return cls.MAPCLASSES - - if isinstance(map_classes, str): - # take it as a file path - class_names = mmcv.list_from_file(map_classes) - elif isinstance(map_classes, (tuple, list)): - class_names = map_classes - else: - raise ValueError(f'Unsupported type {type(map_classes)} of map classes.') - - return class_names - def vectormap_pipeline(self, example, input_dict): - ''' - `example` type: - keys: 'img_metas', 'gt_bboxes_3d', 'gt_labels_3d', 'img'; - all keys type is 'DataContainer'; - 'img_metas' cpu_only=True, type is dict, others are false; - 'gt_labels_3d' shape torch.size([num_samples]), stack=False, - padding_value=0, cpu_only=False - 'gt_bboxes_3d': stack=False, cpu_only=True - ''' - # import ipdb;ipdb.set_trace() - - anns_results = self.vector_map.gen_vectorized_samples(input_dict['annotation'] if 'annotation' in input_dict.keys() else input_dict['ann_info'], - example=example, feat_down_sample=self.aux_seg['feat_down_sample']) - - ''' - anns_results, type: dict - 'gt_vecs_pts_loc': list[num_vecs], vec with num_points*2 coordinates - 'gt_vecs_pts_num': list[num_vecs], vec with num_points - 'gt_vecs_label': list[num_vecs], vec with cls index - ''' - gt_vecs_label = to_tensor(anns_results['gt_vecs_label']) - if isinstance(anns_results['gt_vecs_pts_loc'], LiDARInstanceLines): - gt_vecs_pts_loc = anns_results['gt_vecs_pts_loc'] - else: - gt_vecs_pts_loc = to_tensor(anns_results['gt_vecs_pts_loc']) - try: - gt_vecs_pts_loc = gt_vecs_pts_loc.flatten(1).to(dtype=torch.float32) - except: - # empty tensor, will be passed in train, - # but we preserve it for test - gt_vecs_pts_loc = gt_vecs_pts_loc - example['gt_labels_3d'] = DC(gt_vecs_label, cpu_only=False) - example['gt_bboxes_3d'] = DC(gt_vecs_pts_loc, cpu_only=True) - - # gt_seg_mask = to_tensor(anns_results['gt_semantic_mask']) - # gt_pv_seg_mask = to_tensor(anns_results['gt_pv_semantic_mask']) - if anns_results['gt_semantic_mask'] is not None: - example['gt_seg_mask'] = DC(to_tensor(anns_results['gt_semantic_mask']), cpu_only=False) - if anns_results['gt_pv_semantic_mask'] is not None: - example['gt_pv_seg_mask'] = DC(to_tensor(anns_results['gt_pv_semantic_mask']), cpu_only=False) - return example - - def prepare_train_data(self, index): - """ - Training data preparation. - Args: - index (int): Index for accessing the target data. - Returns: - dict: Training data dict of the corresponding index. - """ - data_queue = [] - - # temporal aug - prev_indexs_list = list(range(index-self.queue_length, index)) - random.shuffle(prev_indexs_list) - prev_indexs_list = sorted(prev_indexs_list[1:], reverse=True) - ## - - input_dict = self.get_data_info(index) - if input_dict is None: - return None - frame_idx = input_dict['frame_idx'] - scene_token = input_dict['scene_token'] - self.pre_pipeline(input_dict) - # import pdb;pdb.set_trace() - example = self.pipeline(input_dict) - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - data_queue.insert(0, example) - for i in prev_indexs_list: - i = max(0, i) - input_dict = self.get_data_info(i) - if input_dict is None: - return None - if input_dict['frame_idx'] < frame_idx and input_dict['scene_token'] == scene_token: - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - example = self.vectormap_pipeline(example,input_dict) - if self.filter_empty_gt and \ - (example is None or ~(example['gt_labels_3d']._data != -1).any()): - return None - frame_idx = input_dict['frame_idx'] - data_queue.insert(0, copy.deepcopy(example)) - return self.union2one(data_queue) - - def union2one(self, queue): - """ - convert sample queue into one single sample. - """ - # import ipdb;ipdb.set_trace() - imgs_list = [each['img'].data for each in queue] - metas_map = {} - prev_pos = None - prev_angle = None - for i, each in enumerate(queue): - metas_map[i] = each['img_metas'].data - if i == 0: - metas_map[i]['prev_bev'] = False - prev_lidar2global = metas_map[i]['lidar2global'] - prev_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - prev_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] = 0 - metas_map[i]['can_bus'][-1] = 0 - tmp_lidar2prev_lidar = np.eye(4) - metas_map[i]['tmp_lidar2prev_lidar'] = tmp_lidar2prev_lidar - tmp_lidar2prev_lidar_translation = tmp_lidar2prev_lidar[:3,3] - tmp_lidar2prev_lidar_angle = quaternion_yaw(Quaternion( - matrix=tmp_lidar2prev_lidar)) / np.pi * 180 - metas_map[i]['tmp_lidar2prev_lidar_translation'] = tmp_lidar2prev_lidar_translation - metas_map[i]['tmp_lidar2prev_lidar_angle'] = tmp_lidar2prev_lidar_angle - else: - metas_map[i]['prev_bev'] = True - tmp_lidar2global = metas_map[i]['lidar2global'] - tmp_lidar2prev_lidar = np.linalg.inv(prev_lidar2global)@tmp_lidar2global - tmp_lidar2prev_lidar_translation = tmp_lidar2prev_lidar[:3,3] - tmp_lidar2prev_lidar_angle = quaternion_yaw(Quaternion( - matrix=tmp_lidar2prev_lidar)) / np.pi * 180 - tmp_pos = copy.deepcopy(metas_map[i]['can_bus'][:3]) - tmp_angle = copy.deepcopy(metas_map[i]['can_bus'][-1]) - metas_map[i]['can_bus'][:3] -= prev_pos - metas_map[i]['can_bus'][-1] -= prev_angle - metas_map[i]['tmp_lidar2prev_lidar'] = tmp_lidar2prev_lidar - metas_map[i]['tmp_lidar2prev_lidar_translation'] = tmp_lidar2prev_lidar_translation - metas_map[i]['tmp_lidar2prev_lidar_angle'] = tmp_lidar2prev_lidar_angle - prev_pos = copy.deepcopy(tmp_pos) - prev_angle = copy.deepcopy(tmp_angle) - prev_lidar2global = copy.deepcopy(tmp_lidar2global) - - queue[-1]['img'] = DC(torch.stack(imgs_list), - cpu_only=False, stack=True) - queue[-1]['img_metas'] = DC(metas_map, cpu_only=True) - queue = queue[-1] - return queue - - def get_data_info(self, index): - """Get data info according to the given index. - - Args: - index (int): Index of the sample data to get. - - Returns: - dict: Data information that will be passed to the data \ - preprocessing pipelines. It includes the following keys: - - - sample_idx (str): Sample index. - - pts_filename (str): Filename of point clouds. - - sweeps (list[dict]): Infos of sweeps. - - timestamp (float): Sample timestamp. - - img_filename (str, optional): Image filename. - - lidar2img (list[np.ndarray], optional): Transformations \ - from lidar to different cameras. - - ann_info (dict): Annotation info. - """ - info = self.data_infos[index] - # standard protocal modified from SECOND.Pytorch - input_dict = dict( - sample_idx=info['token'], - pts_filename=info['lidar_path'], - lidar_path=info["lidar_path"], - sweeps=info['sweeps'], - ego2global_translation=info['ego2global_translation'], - ego2global_rotation=info['ego2global_rotation'], - lidar2ego_translation=info['lidar2ego_translation'], - lidar2ego_rotation=info['lidar2ego_rotation'], - prev_idx=info['prev'], - next_idx=info['next'], - scene_token=info['scene_token'], - can_bus=info['can_bus'], - frame_idx=info['frame_idx'], - timestamp=info['timestamp'], - map_location = info['map_location'], - ) - # lidar to ego transform - lidar2ego = np.eye(4).astype(np.float32) - lidar2ego[:3, :3] = Quaternion(info["lidar2ego_rotation"]).rotation_matrix - lidar2ego[:3, 3] = info["lidar2ego_translation"] - input_dict["lidar2ego"] = lidar2ego - if self.modality['use_camera']: - image_paths = [] - lidar2img_rts = [] - lidar2cam_rts = [] - cam_intrinsics = [] - input_dict["camera2ego"] = [] - input_dict["camera_intrinsics"] = [] - input_dict["camego2global"] = [] - for cam_type, cam_info in info['cams'].items(): - image_paths.append(cam_info['data_path']) - # obtain lidar to image transformation matrix - lidar2cam_r = np.linalg.inv(cam_info['sensor2lidar_rotation']) - lidar2cam_t = cam_info[ - 'sensor2lidar_translation'] @ lidar2cam_r.T - lidar2cam_rt = np.eye(4) - lidar2cam_rt[:3, :3] = lidar2cam_r.T - lidar2cam_rt[3, :3] = -lidar2cam_t - lidar2cam_rt_t = lidar2cam_rt.T - - if self.noise == 'rotation': - lidar2cam_rt_t = add_rotation_noise(lidar2cam_rt_t, std=self.noise_std) - elif self.noise == 'translation': - lidar2cam_rt_t = add_translation_noise( - lidar2cam_rt_t, std=self.noise_std) - - intrinsic = cam_info['cam_intrinsic'] - viewpad = np.eye(4) - viewpad[:intrinsic.shape[0], :intrinsic.shape[1]] = intrinsic - lidar2img_rt = (viewpad @ lidar2cam_rt_t) - lidar2img_rts.append(lidar2img_rt) - - cam_intrinsics.append(viewpad) - lidar2cam_rts.append(lidar2cam_rt_t) - - # camera to ego transform - camera2ego = np.eye(4).astype(np.float32) - camera2ego[:3, :3] = Quaternion( - cam_info["sensor2ego_rotation"] - ).rotation_matrix - camera2ego[:3, 3] = cam_info["sensor2ego_translation"] - input_dict["camera2ego"].append(camera2ego) - - # camego to global transform - camego2global = np.eye(4, dtype=np.float32) - camego2global[:3, :3] = Quaternion( - cam_info['ego2global_rotation']).rotation_matrix - camego2global[:3, 3] = cam_info['ego2global_translation'] - camego2global = torch.from_numpy(camego2global) - input_dict["camego2global"].append(camego2global) - - # camera intrinsics - camera_intrinsics = np.eye(4).astype(np.float32) - camera_intrinsics[:3, :3] = cam_info["cam_intrinsic"] - input_dict["camera_intrinsics"].append(camera_intrinsics) - - input_dict.update( - dict( - img_filename=image_paths, - lidar2img=lidar2img_rts, - cam_intrinsic=cam_intrinsics, - lidar2cam=lidar2cam_rts, - )) - - # if not self.test_mode: - # # annos = self.get_ann_info(index) - input_dict['ann_info'] = info['annotation'] - - rotation = Quaternion(input_dict['ego2global_rotation']) - translation = input_dict['ego2global_translation'] - can_bus = input_dict['can_bus'] - can_bus[:3] = translation - can_bus[3:7] = rotation - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - if patch_angle < 0: - patch_angle += 360 - can_bus[-2] = patch_angle / 180 * np.pi - can_bus[-1] = patch_angle - - - lidar2ego = np.eye(4) - lidar2ego[:3,:3] = Quaternion(input_dict['lidar2ego_rotation']).rotation_matrix - lidar2ego[:3, 3] = input_dict['lidar2ego_translation'] - ego2global = np.eye(4) - ego2global[:3,:3] = Quaternion(input_dict['ego2global_rotation']).rotation_matrix - ego2global[:3, 3] = input_dict['ego2global_translation'] - lidar2global = ego2global @ lidar2ego - input_dict['lidar2global'] = lidar2global - return input_dict - - def prepare_test_data(self, index): - """Prepare data for testing. - - Args: - index (int): Index for accessing the target data. - - Returns: - dict: Testing data dict of the corresponding index. - """ - input_dict = self.get_data_info(index) - self.pre_pipeline(input_dict) - example = self.pipeline(input_dict) - if self.is_vis_on_test: - example = self.vectormap_pipeline(example, input_dict) - return example - - def __getitem__(self, idx): - """Get item from infos according to the given index. - Returns: - dict: Data dictionary of the corresponding index. - """ - if self.test_mode: - return self.prepare_test_data(idx) - while True: - - data = self.prepare_train_data(idx) - if data is None: - idx = self._rand_another(idx) - continue - return data - def _format_gt(self): - gt_annos = [] - print('Start to convert gt map format...') - assert self.map_ann_file is not None - if (not os.path.exists(self.map_ann_file)) : - dataset_length = len(self) - prog_bar = mmcv.ProgressBar(dataset_length) - mapped_class_names = self.MAPCLASSES - for sample_id in range(dataset_length): - sample_token = self.data_infos[sample_id]['token'] - gt_anno = {} - gt_anno['sample_token'] = sample_token - # gt_sample_annos = [] - gt_sample_dict = {} - gt_sample_dict = self.vectormap_pipeline(gt_sample_dict, self.data_infos[sample_id]) - gt_labels = gt_sample_dict['gt_labels_3d'].data.numpy() - gt_vecs = gt_sample_dict['gt_bboxes_3d'].data.instance_list - gt_vec_list = [] - for i, (gt_label, gt_vec) in enumerate(zip(gt_labels, gt_vecs)): - name = mapped_class_names[gt_label] - anno = dict( - pts=np.array(list(gt_vec.coords)), - pts_num=len(list(gt_vec.coords)), - cls_name=name, - type=gt_label, - ) - gt_vec_list.append(anno) - gt_anno['vectors']=gt_vec_list - gt_annos.append(gt_anno) - - prog_bar.update() - nusc_submissions = { - 'GTs': gt_annos - } - print('\n GT anns writes to', self.map_ann_file) - mmcv.dump(nusc_submissions, self.map_ann_file) - else: - print(f'{self.map_ann_file} exist, not update') - - def _format_bbox(self, results, jsonfile_prefix=None): - """Convert the results to the standard format. - - Args: - results (list[dict]): Testing results of the dataset. - jsonfile_prefix (str): The prefix of the output jsonfile. - You can specify the output directory/filename by - modifying the jsonfile_prefix. Default: None. - - Returns: - str: Path of the output json file. - """ - assert self.map_ann_file is not None - pred_annos = [] - mapped_class_names = self.MAPCLASSES - # import pdb;pdb.set_trace() - print('Start to convert map detection format...') - for sample_id, det in enumerate(mmcv.track_iter_progress(results)): - pred_anno = {} - vecs = output_to_vecs(det) - sample_token = self.data_infos[sample_id]['token'] - pred_anno['sample_token'] = sample_token - pred_vec_list=[] - for i, vec in enumerate(vecs): - name = mapped_class_names[vec['label']] - anno = dict( - pts=vec['pts'], - pts_num=len(vec['pts']), - cls_name=name, - type=vec['label'], - confidence_level=vec['score']) - pred_vec_list.append(anno) - - pred_anno['vectors'] = pred_vec_list - pred_annos.append(pred_anno) - - if not os.path.exists(self.map_ann_file): - self._format_gt() - else: - print(f'{self.map_ann_file} exist, not update') - - nusc_submissions = { - 'meta': self.modality, - 'results': pred_annos, - - } - - mmcv.mkdir_or_exist(jsonfile_prefix) - res_path = osp.join(jsonfile_prefix, 'nuscmap_results.json') - print('Results writes to', res_path) - mmcv.dump(nusc_submissions, res_path) - return res_path - - def to_gt_vectors(self, - gt_dict): - # import pdb;pdb.set_trace() - gt_labels = gt_dict['gt_labels_3d'].data - gt_instances = gt_dict['gt_bboxes_3d'].data.instance_list - - gt_vectors = [] - - for gt_instance, gt_label in zip(gt_instances, gt_labels): - pts, pts_num = sample_pts_from_line(gt_instance, patch_size=self.patch_size) - gt_vectors.append({ - 'pts': pts, - 'pts_num': pts_num, - 'type': int(gt_label) - }) - vector_num_list = {} - for i in range(self.NUM_MAPCLASSES): - vector_num_list[i] = [] - for vec in gt_vectors: - if vector['pts_num'] >= 2: - vector_num_list[vector['type']].append((LineString(vector['pts'][:vector['pts_num']]), vector.get('confidence_level', 1))) - return gt_vectors - - def _evaluate_single(self, - result_path, - logger=None, - metric='chamfer', - result_name='pts_bbox'): - """Evaluation for a single model in nuScenes protocol. - - Args: - result_path (str): Path of the result file. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - metric (str): Metric name used for evaluation. Default: 'bbox'. - result_name (str): Result name in the metric prefix. - Default: 'pts_bbox'. - - Returns: - dict: Dictionary of evaluation details. - """ - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import eval_map - from projects.mmdet3d_plugin.datasets.map_utils.mean_ap import format_res_gt_by_classes - result_path = osp.abspath(result_path) - detail = dict() - - print('Formating results & gts by classes') - with open(result_path,'r') as f: - pred_results = json.load(f) - gen_results = pred_results['results'] - with open(self.map_ann_file,'r') as ann_f: - gt_anns = json.load(ann_f) - annotations = gt_anns['GTs'] - cls_gens, cls_gts = format_res_gt_by_classes(result_path, - gen_results, - annotations, - cls_names=self.MAPCLASSES, - num_pred_pts_per_instance=self.fixed_num, - eval_use_same_gt_sample_num_flag=self.eval_use_same_gt_sample_num_flag, - pc_range=self.pc_range) - - metrics = metric if isinstance(metric, list) else [metric] - allowed_metrics = ['chamfer', 'iou'] - for metric in metrics: - if metric not in allowed_metrics: - raise KeyError(f'metric {metric} is not supported') - - for metric in metrics: - print('-*'*10+f'use metric:{metric}'+'-*'*10) - - if metric == 'chamfer': - thresholds = [0.5,1.0,1.5] - elif metric == 'iou': - thresholds= np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) - cls_aps = np.zeros((len(thresholds),self.NUM_MAPCLASSES)) - - for i, thr in enumerate(thresholds): - print('-*'*10+f'threshhold:{thr}'+'-*'*10) - mAP, cls_ap = eval_map( - gen_results, - annotations, - cls_gens, - cls_gts, - threshold=thr, - cls_names=self.MAPCLASSES, - logger=logger, - num_pred_pts_per_instance=self.fixed_num, - pc_range=self.pc_range, - metric=metric) - for j in range(self.NUM_MAPCLASSES): - cls_aps[i, j] = cls_ap[j]['ap'] - - for i, name in enumerate(self.MAPCLASSES): - print('{}: {}'.format(name, cls_aps.mean(0)[i])) - detail['NuscMap_{}/{}_AP'.format(metric,name)] = cls_aps.mean(0)[i] - print('map: {}'.format(cls_aps.mean(0).mean())) - detail['NuscMap_{}/mAP'.format(metric)] = cls_aps.mean(0).mean() - - for i, name in enumerate(self.MAPCLASSES): - for j, thr in enumerate(thresholds): - if metric == 'chamfer': - detail['NuscMap_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - elif metric == 'iou': - if thr == 0.5 or thr == 0.75: - detail['NuscMap_{}/{}_AP_thr_{}'.format(metric,name,thr)]=cls_aps[j][i] - - return detail - - - def evaluate(self, - results, - metric='bbox', - logger=None, - jsonfile_prefix=None, - result_names=['pts_bbox'], - show=False, - out_dir=None, - pipeline=None): - """Evaluation in nuScenes protocol. - - Args: - results (list[dict]): Testing results of the dataset. - metric (str | list[str]): Metrics to be evaluated. - logger (logging.Logger | str | None): Logger used for printing - related information during evaluation. Default: None. - jsonfile_prefix (str | None): The prefix of json files. It includes - the file path and the prefix of filename, e.g., "a/b/prefix". - If not specified, a temp file will be created. Default: None. - show (bool): Whether to visualize. - Default: False. - out_dir (str): Path to save the visualization results. - Default: None. - pipeline (list[dict], optional): raw data loading for showing. - Default: None. - - Returns: - dict[str, float]: Results of each evaluation metric. - """ - result_files, tmp_dir = self.format_results(results, jsonfile_prefix) - - if isinstance(result_files, dict): - results_dict = dict() - for name in result_names: - print('Evaluating bboxes of {}'.format(name)) - ret_dict = self._evaluate_single(result_files[name], metric=metric) - results_dict.update(ret_dict) - elif isinstance(result_files, str): - results_dict = self._evaluate_single(result_files, metric=metric) - - if tmp_dir is not None: - tmp_dir.cleanup() - - if show: - self.show(results, out_dir, pipeline=pipeline) - return results_dict - - -def output_to_vecs(detection): - box3d = detection['boxes_3d'].numpy() - scores = detection['scores_3d'].numpy() - labels = detection['labels_3d'].numpy() - pts = detection['pts_3d'].numpy() - - vec_list = [] - for i in range(box3d.shape[0]): - vec = dict( - bbox = box3d[i], # xyxy - label=labels[i], - score=scores[i], - pts=pts[i], - ) - vec_list.append(vec) - return vec_list - -def sample_pts_from_line(line, - fixed_num=-1, - sample_dist=1, - normalize=False, - patch_size=None, - padding=False, - num_samples=250,): - if fixed_num < 0: - distances = np.arange(0, line.length, sample_dist) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - else: - # fixed number of points, so distance is line.length / fixed_num - distances = np.linspace(0, line.length, fixed_num) - sampled_points = np.array([list(line.interpolate(distance).coords) for distance in distances]).reshape(-1, 2) - - if normalize: - sampled_points = sampled_points / np.array([patch_size[1], patch_size[0]]) - - num_valid = len(sampled_points) - - if not padding or fixed_num > 0: - # fixed num sample can return now! - return sampled_points, num_valid - - # fixed distance sampling need padding! - num_valid = len(sampled_points) - - if fixed_num < 0: - if num_valid < num_samples: - padding = np.zeros((num_samples - len(sampled_points), 2)) - sampled_points = np.concatenate([sampled_points, padding], axis=0) - else: - sampled_points = sampled_points[:num_samples, :] - num_valid = num_samples - - if normalize: - sampled_points = sampled_points / np.array([patch_size[1], patch_size[0]]) - num_valid = len(sampled_points) - - return sampled_points, num_valid - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/__init__.py deleted file mode 100644 index cd77592d2e275656ce109a37ae0db5e9afaffb51..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from .transform_3d import ( - PadMultiViewImage, PadMultiViewImageDepth, NormalizeMultiviewImage, - PhotoMetricDistortionMultiViewImage, CustomCollect3D, RandomScaleImageMultiViewImage, CustomPointsRangeFilter) -from .formating import CustomDefaultFormatBundle3D - -from .loading import CustomLoadPointsFromFile, CustomLoadPointsFromMultiSweeps, CustomLoadMultiViewImageFromFiles, CustomPointToMultiViewDepth -__all__ = [ - 'PadMultiViewImage', 'NormalizeMultiviewImage', - 'PhotoMetricDistortionMultiViewImage', 'CustomDefaultFormatBundle3D', 'CustomCollect3D', 'RandomScaleImageMultiViewImage' -] \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/formating.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/formating.py deleted file mode 100644 index 52878523f5ad82bceba47f3845a58d6468d95849..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/formating.py +++ /dev/null @@ -1,39 +0,0 @@ - -# Copyright (c) OpenMMLab. All rights reserved. -import numpy as np -from mmcv.parallel import DataContainer as DC - -from mmdet3d.core.bbox import BaseInstance3DBoxes -from mmdet3d.core.points import BasePoints -from mmdet.datasets.builder import PIPELINES -from mmdet.datasets.pipelines import to_tensor -from mmdet3d.datasets.pipelines import DefaultFormatBundle3D - -@PIPELINES.register_module() -class CustomDefaultFormatBundle3D(DefaultFormatBundle3D): - """Default formatting bundle. - It simplifies the pipeline of formatting common fields for voxels, - including "proposals", "gt_bboxes", "gt_labels", "gt_masks" and - "gt_semantic_seg". - These fields are formatted as follows. - - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) - - proposals: (1)to tensor, (2)to DataContainer - - gt_bboxes: (1)to tensor, (2)to DataContainer - - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer - - gt_labels: (1)to tensor, (2)to DataContainer - """ - - def __call__(self, results): - """Call function to transform and format common fields in results. - Args: - results (dict): Result dict contains the data to convert. - Returns: - dict: The result dict contains the data that is formatted with - default bundle. - """ - # Format 3D data - results = super(CustomDefaultFormatBundle3D, self).__call__(results) - results['gt_map_masks'] = DC( - to_tensor(results['gt_map_masks']), stack=True) - - return results \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading.py deleted file mode 100644 index 8f6017d0833e82e2701e7dfc994b9c596a9718f2..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading.py +++ /dev/null @@ -1,459 +0,0 @@ -import os -from typing import Any, Dict, Tuple - -import mmcv -import numpy as np -from nuscenes.map_expansion.map_api import NuScenesMap -from nuscenes.map_expansion.map_api import locations as LOCATIONS -from PIL import Image - - -from mmdet3d.core.points import BasePoints, get_points_type -from mmdet.datasets.builder import PIPELINES -from mmdet.datasets.pipelines import LoadAnnotations - -from .loading_utils import load_augmented_point_cloud, reduce_LiDAR_beams - -import torch -from pyquaternion import Quaternion - -@PIPELINES.register_module() -class CustomLoadMultiViewImageFromFiles(object): - """Load multi channel images from a list of separate channel files. - - Expects results['img_filename'] to be a list of filenames. - - Args: - to_float32 (bool): Whether to convert the img to float32. - Defaults to False. - color_type (str): Color type of the file. Defaults to 'unchanged'. - """ - - def __init__(self, to_float32=False, padding=True,pad_val=128, color_type='unchanged'): - self.to_float32 = to_float32 - self.color_type = color_type - self.padding = padding - self.pad_val = pad_val - - def __call__(self, results): - """Call function to load multi-view image from files. - - Args: - results (dict): Result dict containing multi-view image filenames. - - Returns: - dict: The result dict containing the multi-view image data. \ - Added keys and values are described below. - - - filename (str): Multi-view image filenames. - - img (np.ndarray): Multi-view image arrays. - - img_shape (tuple[int]): Shape of multi-view image arrays. - - ori_shape (tuple[int]): Shape of original image arrays. - - pad_shape (tuple[int]): Shape of padded image arrays. - - scale_factor (float): Scale factor. - - img_norm_cfg (dict): Normalization configuration of images. - """ - filename = results['img_filename'] - # img is of shape (h, w, c, num_views) - # img = np.stack( - # [mmcv.imread(name, self.color_type) for name in filename], axis=-1) - img_list = [mmcv.imread(name, self.color_type) for name in filename] - img_shape_list = [img.shape for img in img_list] - max_h = max([shape[0] for shape in img_shape_list]) - max_w = max([shape[1] for shape in img_shape_list]) - size = (max_h, max_w) - # import pdb;pdb.set_trace() - img_list = [mmcv.impad( - img, shape=size, pad_val=self.pad_val) for img in img_list] - - img = np.stack(img_list,axis=-1) - if self.to_float32: - img = img.astype(np.float32) - results['filename'] = filename - # unravel to list, see `DefaultFormatBundle` in formating.py - # which will transpose each image separately and then stack into array - results['img'] = [img[..., i] for i in range(img.shape[-1])] - results['img_shape'] = img.shape - results['ori_shape'] = img.shape - # Set initial values for default meta_keys - results['pad_shape'] = img.shape - results['scale_factor'] = 1.0 - num_channels = 1 if len(img.shape) < 3 else img.shape[2] - results['img_norm_cfg'] = dict( - mean=np.zeros(num_channels, dtype=np.float32), - std=np.ones(num_channels, dtype=np.float32), - to_rgb=False) - return results - - def __repr__(self): - """str: Return a string that describes the module.""" - repr_str = self.__class__.__name__ - repr_str += f'(to_float32={self.to_float32}, ' - repr_str += f"color_type='{self.color_type}')" - return repr_str - -@PIPELINES.register_module() -class CustomLoadPointsFromMultiSweeps: - """Load points from multiple sweeps. - - This is usually used for nuScenes dataset to utilize previous sweeps. - - Args: - sweeps_num (int): Number of sweeps. Defaults to 10. - load_dim (int): Dimension number of the loaded points. Defaults to 5. - use_dim (list[int]): Which dimension to use. Defaults to [0, 1, 2, 4]. - pad_empty_sweeps (bool): Whether to repeat keyframe when - sweeps is empty. Defaults to False. - remove_close (bool): Whether to remove close points. - Defaults to False. - test_mode (bool): If test_model=True used for testing, it will not - randomly sample sweeps but select the nearest N frames. - Defaults to False. - """ - - def __init__( - self, - sweeps_num=10, - load_dim=5, - use_dim=[0, 1, 2, 4], - pad_empty_sweeps=False, - remove_close=False, - test_mode=False, - load_augmented=None, - reduce_beams=None, - ): - self.load_dim = load_dim - self.sweeps_num = sweeps_num - if isinstance(use_dim, int): - use_dim = list(range(use_dim)) - self.use_dim = use_dim - self.pad_empty_sweeps = pad_empty_sweeps - self.remove_close = remove_close - self.test_mode = test_mode - self.load_augmented = load_augmented - self.reduce_beams = reduce_beams - - def _load_points(self, lidar_path): - """Private function to load point clouds data. - - Args: - lidar_path (str): Filename of point clouds data. - - Returns: - np.ndarray: An array containing point clouds data. - """ - mmcv.check_file_exist(lidar_path) - if self.load_augmented: - assert self.load_augmented in ["pointpainting", "mvp"] - virtual = self.load_augmented == "mvp" - points = load_augmented_point_cloud( - lidar_path, virtual=virtual, reduce_beams=self.reduce_beams - ) - elif lidar_path.endswith(".npy"): - points = np.load(lidar_path) - else: - points = np.fromfile(lidar_path, dtype=np.float32) - return points - - def _remove_close(self, points, radius=1.0): - """Removes point too close within a certain radius from origin. - - Args: - points (np.ndarray | :obj:`BasePoints`): Sweep points. - radius (float): Radius below which points are removed. - Defaults to 1.0. - - Returns: - np.ndarray: Points after removing. - """ - if isinstance(points, np.ndarray): - points_numpy = points - elif isinstance(points, BasePoints): - points_numpy = points.tensor.numpy() - else: - raise NotImplementedError - x_filt = np.abs(points_numpy[:, 0]) < radius - y_filt = np.abs(points_numpy[:, 1]) < radius - not_close = np.logical_not(np.logical_and(x_filt, y_filt)) - return points[not_close] - - def __call__(self, results): - """Call function to load multi-sweep point clouds from files. - - Args: - results (dict): Result dict containing multi-sweep point cloud \ - filenames. - - Returns: - dict: The result dict containing the multi-sweep points data. \ - Added key and value are described below. - - - points (np.ndarray | :obj:`BasePoints`): Multi-sweep point \ - cloud arrays. - """ - points = results["points"] - points.tensor[:, 4] = 0 - sweep_points_list = [points] - ts = results["timestamp"] / 1e6 - if self.pad_empty_sweeps and len(results["sweeps"]) == 0: - for i in range(self.sweeps_num): - if self.remove_close: - sweep_points_list.append(self._remove_close(points)) - else: - sweep_points_list.append(points) - else: - if len(results["sweeps"]) <= self.sweeps_num: - choices = np.arange(len(results["sweeps"])) - elif self.test_mode: - choices = np.arange(self.sweeps_num) - else: - # NOTE: seems possible to load frame -11? - if not self.load_augmented: - choices = np.random.choice( - len(results["sweeps"]), self.sweeps_num, replace=False - ) - else: - # don't allow to sample the earliest frame, match with Tianwei's implementation. - choices = np.random.choice( - len(results["sweeps"]) - 1, self.sweeps_num, replace=False - ) - for idx in choices: - sweep = results["sweeps"][idx] - points_sweep = self._load_points(sweep["data_path"]) - points_sweep = np.copy(points_sweep).reshape(-1, self.load_dim) - - # TODO: make it more general - if self.reduce_beams and self.reduce_beams < 32: - points_sweep = reduce_LiDAR_beams(points_sweep, self.reduce_beams) - - if self.remove_close: - points_sweep = self._remove_close(points_sweep) - sweep_ts = sweep["timestamp"] / 1e6 - points_sweep[:, :3] = ( - points_sweep[:, :3] @ sweep["sensor2lidar_rotation"].T - ) - points_sweep[:, :3] += sweep["sensor2lidar_translation"] - points_sweep[:, 4] = ts - sweep_ts - points_sweep = points.new_point(points_sweep) - sweep_points_list.append(points_sweep) - - points = points.cat(sweep_points_list) - points = points[:, self.use_dim] - results["points"] = points - return results - - def __repr__(self): - """str: Return a string that describes the module.""" - return f"{self.__class__.__name__}(sweeps_num={self.sweeps_num})" - - - -@PIPELINES.register_module() -class CustomLoadPointsFromFile: - """Load Points From File. - - Load sunrgbd and scannet points from file. - - Args: - coord_type (str): The type of coordinates of points cloud. - Available options includes: - - 'LIDAR': Points in LiDAR coordinates. - - 'DEPTH': Points in depth coordinates, usually for indoor dataset. - - 'CAMERA': Points in camera coordinates. - load_dim (int): The dimension of the loaded points. - Defaults to 6. - use_dim (list[int]): Which dimensions of the points to be used. - Defaults to [0, 1, 2]. For KITTI dataset, set use_dim=4 - or use_dim=[0, 1, 2, 3] to use the intensity dimension. - shift_height (bool): Whether to use shifted height. Defaults to False. - use_color (bool): Whether to use color features. Defaults to False. - """ - - def __init__( - self, - coord_type, - load_dim=6, - use_dim=[0, 1, 2], - shift_height=False, - use_color=False, - load_augmented=None, - reduce_beams=None, - ): - self.shift_height = shift_height - self.use_color = use_color - if isinstance(use_dim, int): - use_dim = list(range(use_dim)) - assert ( - max(use_dim) < load_dim - ), f"Expect all used dimensions < {load_dim}, got {use_dim}" - assert coord_type in ["CAMERA", "LIDAR", "DEPTH"] - - self.coord_type = coord_type - self.load_dim = load_dim - self.use_dim = use_dim - self.load_augmented = load_augmented - self.reduce_beams = reduce_beams - - def _load_points(self, lidar_path): - """Private function to load point clouds data. - - Args: - lidar_path (str): Filename of point clouds data. - - Returns: - np.ndarray: An array containing point clouds data. - """ - mmcv.check_file_exist(lidar_path) - if self.load_augmented: - assert self.load_augmented in ["pointpainting", "mvp"] - virtual = self.load_augmented == "mvp" - points = load_augmented_point_cloud( - lidar_path, virtual=virtual, reduce_beams=self.reduce_beams - ) - elif lidar_path.endswith(".npy"): - points = np.load(lidar_path) - else: - points = np.fromfile(lidar_path, dtype=np.float32) - - return points - - def __call__(self, results): - """Call function to load points data from file. - - Args: - results (dict): Result dict containing point clouds data. - - Returns: - dict: The result dict containing the point clouds data. \ - Added key and value are described below. - - - points (:obj:`BasePoints`): Point clouds data. - """ - lidar_path = results["lidar_path"] - points = self._load_points(lidar_path) - points = points.reshape(-1, self.load_dim) - # TODO: make it more general - if self.reduce_beams and self.reduce_beams < 32: - points = reduce_LiDAR_beams(points, self.reduce_beams) - points = points[:, self.use_dim] - attribute_dims = None - - if self.shift_height: - floor_height = np.percentile(points[:, 2], 0.99) - height = points[:, 2] - floor_height - points = np.concatenate( - [points[:, :3], np.expand_dims(height, 1), points[:, 3:]], 1 - ) - attribute_dims = dict(height=3) - - if self.use_color: - assert len(self.use_dim) >= 6 - if attribute_dims is None: - attribute_dims = dict() - attribute_dims.update( - dict( - color=[ - points.shape[1] - 3, - points.shape[1] - 2, - points.shape[1] - 1, - ] - ) - ) - - points_class = get_points_type(self.coord_type) - points = points_class( - points, points_dim=points.shape[-1], attribute_dims=attribute_dims - ) - results["points"] = points - - return results - - -@PIPELINES.register_module() -class CustomPointToMultiViewDepth(object): - - def __init__(self, grid_config, downsample=1): - self.downsample = downsample - self.grid_config = grid_config - - def points2depthmap(self, points, height, width): - height, width = height // self.downsample, width // self.downsample - depth_map = torch.zeros((height, width), dtype=torch.float32) - coor = torch.round(points[:, :2] / self.downsample) - depth = points[:, 2] - kept1 = (coor[:, 0] >= 0) & (coor[:, 0] < width) & ( - coor[:, 1] >= 0) & (coor[:, 1] < height) & ( - depth < self.grid_config['depth'][1]) & ( - depth >= self.grid_config['depth'][0]) - coor, depth = coor[kept1], depth[kept1] - ranks = coor[:, 0] + coor[:, 1] * width - sort = (ranks + depth / 100.).argsort() - coor, depth, ranks = coor[sort], depth[sort], ranks[sort] - - kept2 = torch.ones(coor.shape[0], device=coor.device, dtype=torch.bool) - kept2[1:] = (ranks[1:] != ranks[:-1]) - coor, depth = coor[kept2], depth[kept2] - coor = coor.to(torch.long) - depth_map[coor[:, 1], coor[:, 0]] = depth - return depth_map - - def __call__(self, results): - points_lidar = results['points'] - imgs = np.stack(results['img']) - img_aug_matrix = results['img_aug_matrix'] - post_rots = [torch.tensor(single_aug_matrix[:3, :3]).to(torch.float) for single_aug_matrix in img_aug_matrix] - post_trans = torch.stack([torch.tensor(single_aug_matrix[:3, 3]).to(torch.float) for single_aug_matrix in img_aug_matrix]) - # import pdb;pdb.set_trace() - intrins = results['camera_intrinsics'] - depth_map_list = [] - - for cid in range(len(imgs)): - # import pdb;pdb.set_trace() - lidar2lidarego = torch.tensor(results['lidar2ego']).to(torch.float32) - lidarego2global = np.eye(4, dtype=np.float32) - lidarego2global[:3, :3] = Quaternion(results['ego2global_rotation']).rotation_matrix - lidarego2global[:3, 3] = results['ego2global_translation'] - lidarego2global = torch.from_numpy(lidarego2global) - cam2camego = torch.tensor(results['camera2ego'][cid]) - - camego2global = results['camego2global'][cid] - - cam2img = torch.tensor(intrins[cid]).to(torch.float32) - - lidar2cam = torch.inverse(camego2global.matmul(cam2camego)).matmul( - lidarego2global.matmul(lidar2lidarego)) - lidar2img = cam2img.matmul(lidar2cam) - - points_img = points_lidar.tensor[:, :3].matmul( - lidar2img[:3, :3].T.to(torch.float)) + lidar2img[:3, 3].to(torch.float).unsqueeze(0) - points_img = torch.cat( - [points_img[:, :2] / points_img[:, 2:3], points_img[:, 2:3]], - 1) - points_img = points_img.matmul( - post_rots[cid].T) + post_trans[cid:cid + 1, :] - depth_map = self.points2depthmap(points_img, imgs.shape[1], - imgs.shape[2]) - depth_map_list.append(depth_map) - depth_map = torch.stack(depth_map_list) - - ################################################################## - # global i - # import cv2 - # for image_id in range(imgs.shape[0]): - # i+=1 - # image = imgs[image_id] - # gt_depth_image = depth_map[image_id].numpy() - - # gt_depth_image = np.expand_dims(gt_depth_image,2).repeat(3,2) - - # #apply colormap on deoth image(image must be converted to 8-bit per pixel first) - # im_color=cv2.applyColorMap(cv2.convertScaleAbs(gt_depth_image,alpha=15),cv2.COLORMAP_JET) - # #convert to mat png - # image[gt_depth_image>0] = im_color[gt_depth_image>0] - # im=Image.fromarray(np.uint8(image)) - # #save image - # im.save('visualize_1/visualize_{}.png'.format(i)) - ################################################################# - - results['gt_depth'] = depth_map - return results diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading_utils.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading_utils.py deleted file mode 100644 index c66dbb2d8cb0865d189d22ce17b91d73da342ffb..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/pipelines/loading_utils.py +++ /dev/null @@ -1,107 +0,0 @@ -import os - -import numpy as np -import torch - -__all__ = ["load_augmented_point_cloud", "reduce_LiDAR_beams"] - - -def load_augmented_point_cloud(path, virtual=False, reduce_beams=32): - # NOTE: following Tianwei's implementation, it is hard coded for nuScenes - points = np.fromfile(path, dtype=np.float32).reshape(-1, 5) - # NOTE: path definition different from Tianwei's implementation. - tokens = path.split("/") - vp_dir = "_VIRTUAL" if reduce_beams == 32 else f"_VIRTUAL_{reduce_beams}BEAMS" - seg_path = os.path.join( - *tokens[:-3], - "virtual_points", - tokens[-3], - tokens[-2] + vp_dir, - tokens[-1] + ".pkl.npy", - ) - assert os.path.exists(seg_path) - data_dict = np.load(seg_path, allow_pickle=True).item() - - virtual_points1 = data_dict["real_points"] - # NOTE: add zero reflectance to virtual points instead of removing them from real points - virtual_points2 = np.concatenate( - [ - data_dict["virtual_points"][:, :3], - np.zeros([data_dict["virtual_points"].shape[0], 1]), - data_dict["virtual_points"][:, 3:], - ], - axis=-1, - ) - - points = np.concatenate( - [ - points, - np.ones([points.shape[0], virtual_points1.shape[1] - points.shape[1] + 1]), - ], - axis=1, - ) - virtual_points1 = np.concatenate( - [virtual_points1, np.zeros([virtual_points1.shape[0], 1])], axis=1 - ) - # note: this part is different from Tianwei's implementation, we don't have duplicate foreground real points. - if len(data_dict["real_points_indice"]) > 0: - points[data_dict["real_points_indice"]] = virtual_points1 - if virtual: - virtual_points2 = np.concatenate( - [virtual_points2, -1 * np.ones([virtual_points2.shape[0], 1])], axis=1 - ) - points = np.concatenate([points, virtual_points2], axis=0).astype(np.float32) - return points - - -def reduce_LiDAR_beams(pts, reduce_beams_to=32): - # print(pts.size()) - if isinstance(pts, np.ndarray): - pts = torch.from_numpy(pts) - radius = torch.sqrt(pts[:, 0].pow(2) + pts[:, 1].pow(2) + pts[:, 2].pow(2)) - sine_theta = pts[:, 2] / radius - # [-pi/2, pi/2] - theta = torch.asin(sine_theta) - phi = torch.atan2(pts[:, 1], pts[:, 0]) - - top_ang = 0.1862 - down_ang = -0.5353 - - beam_range = torch.zeros(32) - beam_range[0] = top_ang - beam_range[31] = down_ang - - for i in range(1, 31): - beam_range[i] = beam_range[i - 1] - 0.023275 - # beam_range = [1, 0.18, 0.15, 0.13, 0.11, 0.085, 0.065, 0.03, 0.01, -0.01, -0.03, -0.055, -0.08, -0.105, -0.13, -0.155, -0.18, -0.205, -0.228, -0.251, -0.275, - # -0.295, -0.32, -0.34, -0.36, -0.38, -0.40, -0.425, -0.45, -0.47, -0.49, -0.52, -0.54] - - num_pts, _ = pts.size() - mask = torch.zeros(num_pts) - if reduce_beams_to == 16: - for id in [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]: - beam_mask = (theta < (beam_range[id - 1] - 0.012)) * ( - theta > (beam_range[id] - 0.012) - ) - mask = mask + beam_mask - mask = mask.bool() - elif reduce_beams_to == 4: - for id in [7, 9, 11, 13]: - beam_mask = (theta < (beam_range[id - 1] - 0.012)) * ( - theta > (beam_range[id] - 0.012) - ) - mask = mask + beam_mask - mask = mask.bool() - # [?] pick the 14th beam - elif reduce_beams_to == 1: - chosen_beam_id = 9 - mask = (theta < (beam_range[chosen_beam_id - 1] - 0.012)) * ( - theta > (beam_range[chosen_beam_id] - 0.012) - ) - else: - raise NotImplementedError - # points = copy.copy(pts) - points = pts[mask] - # print(points.size()) - return points.numpy() - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/__init__.py deleted file mode 100644 index bb2a0b17769a958042583dcb4c8c4a4f51636f4c..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .group_sampler import DistributedGroupSampler -from .distributed_sampler import DistributedSampler -from .sampler import SAMPLER, build_sampler - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py deleted file mode 100644 index 16c59e5f3dd880ba185247acfba6eae354deb771..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/datasets/samplers/group_sampler.py +++ /dev/null @@ -1,110 +0,0 @@ - -# Copyright (c) OpenMMLab. All rights reserved. -import math - -import numpy as np -import torch -from mmcv.runner import get_dist_info -from torch.utils.data import Sampler -from .sampler import SAMPLER -import random -from IPython import embed - - -@SAMPLER.register_module() -class DistributedGroupSampler(Sampler): - """Sampler that restricts data loading to a subset of the dataset. - It is especially useful in conjunction with - :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each - process can pass a DistributedSampler instance as a DataLoader sampler, - and load a subset of the original dataset that is exclusive to it. - .. note:: - Dataset is assumed to be of constant size. - Arguments: - dataset: Dataset used for sampling. - num_replicas (optional): Number of processes participating in - distributed training. - rank (optional): Rank of the current process within num_replicas. - seed (int, optional): random seed used to shuffle the sampler if - ``shuffle=True``. This number should be identical across all - processes in the distributed group. Default: 0. - """ - - def __init__(self, - dataset, - samples_per_gpu=1, - num_replicas=None, - rank=None, - seed=0): - _rank, _num_replicas = get_dist_info() - if num_replicas is None: - num_replicas = _num_replicas - if rank is None: - rank = _rank - self.dataset = dataset - self.samples_per_gpu = samples_per_gpu - self.num_replicas = num_replicas - self.rank = rank - self.epoch = 0 - self.seed = seed if seed is not None else 0 - - assert hasattr(self.dataset, 'flag') - self.flag = self.dataset.flag - self.group_sizes = np.bincount(self.flag) - - self.num_samples = 0 - for i, j in enumerate(self.group_sizes): - self.num_samples += int( - math.ceil(self.group_sizes[i] * 1.0 / self.samples_per_gpu / - self.num_replicas)) * self.samples_per_gpu - self.total_size = self.num_samples * self.num_replicas - - def __iter__(self): - # deterministically shuffle based on epoch - g = torch.Generator() - g.manual_seed(self.epoch + self.seed) - - indices = [] - for i, size in enumerate(self.group_sizes): - if size > 0: - indice = np.where(self.flag == i)[0] - assert len(indice) == size - # add .numpy() to avoid bug when selecting indice in parrots. - # TODO: check whether torch.randperm() can be replaced by - # numpy.random.permutation(). - indice = indice[list( - torch.randperm(int(size), generator=g).numpy())].tolist() - extra = int( - math.ceil( - size * 1.0 / self.samples_per_gpu / self.num_replicas) - ) * self.samples_per_gpu * self.num_replicas - len(indice) - # pad indice - tmp = indice.copy() - for _ in range(extra // size): - indice.extend(tmp) - indice.extend(tmp[:extra % size]) - indices.extend(indice) - - assert len(indices) == self.total_size - - indices = [ - indices[j] for i in list( - torch.randperm( - len(indices) // self.samples_per_gpu, generator=g)) - for j in range(i * self.samples_per_gpu, (i + 1) * - self.samples_per_gpu) - ] - - # subsample - offset = self.num_samples * self.rank - indices = indices[offset:offset + self.num_samples] - assert len(indices) == self.num_samples - - return iter(indices) - - def __len__(self): - return self.num_samples - - def set_epoch(self, epoch): - self.epoch = epoch - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/__init__.py deleted file mode 100644 index f6c4b0ff320a2a38821dba476c16729d25246feb..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .maptr_assigner import MapTRAssigner \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/maptr_assigner.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/maptr_assigner.py deleted file mode 100644 index 4da7f35f15a7b80d79f5e8043d30ae41fd6174b2..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/assigners/maptr_assigner.py +++ /dev/null @@ -1,327 +0,0 @@ -import torch -from mmdet.core.bbox.builder import BBOX_ASSIGNERS -from mmdet.core.bbox.assigners import AssignResult -from mmdet.core.bbox.assigners import BaseAssigner -from mmdet.core.bbox.match_costs import build_match_cost -import torch.nn.functional as F -from mmdet.core.bbox.transforms import bbox_xyxy_to_cxcywh, bbox_cxcywh_to_xyxy -try: - from scipy.optimize import linear_sum_assignment -except ImportError: - linear_sum_assignment = None - -def denormalize_3d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - new_pts[...,2:3] = (pts[...,2:3]*(pc_range[5] - - pc_range[2]) + pc_range[2]) - return new_pts - -def normalize_3d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - patch_z = pc_range[5]-pc_range[2] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - new_pts[...,2:3] = pts[...,2:3] - pc_range[2] - factor = pts.new_tensor([patch_w, patch_h,patch_z]) - normalized_pts = new_pts / factor - return normalized_pts - -def normalize_2d_bbox(bboxes, pc_range): - - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - cxcywh_bboxes = bbox_xyxy_to_cxcywh(bboxes) - cxcywh_bboxes[...,0:1] = cxcywh_bboxes[..., 0:1] - pc_range[0] - cxcywh_bboxes[...,1:2] = cxcywh_bboxes[...,1:2] - pc_range[1] - factor = bboxes.new_tensor([patch_w, patch_h,patch_w,patch_h]) - - normalized_bboxes = cxcywh_bboxes / factor - return normalized_bboxes - -def normalize_2d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - factor = pts.new_tensor([patch_w, patch_h]) - normalized_pts = new_pts / factor - return normalized_pts - -def denormalize_2d_bbox(bboxes, pc_range): - - bboxes = bbox_cxcywh_to_xyxy(bboxes) - bboxes[..., 0::2] = (bboxes[..., 0::2]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - bboxes[..., 1::2] = (bboxes[..., 1::2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - - return bboxes -def denormalize_2d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - return new_pts - -@BBOX_ASSIGNERS.register_module() -class MapTRAssigner(BaseAssigner): - """Computes one-to-one matching between predictions and ground truth. - This class computes an assignment between the targets and the predictions - based on the costs. The costs are weighted sum of three components: - classification cost, regression L1 cost and regression iou cost. The - targets don't include the no_object, so generally there are more - predictions than targets. After the one-to-one matching, the un-matched - are treated as backgrounds. Thus each query prediction will be assigned - with `0` or a positive integer indicating the ground truth index: - - 0: negative sample, no assigned gt - - positive integer: positive sample, index (1-based) of assigned gt - Args: - cls_weight (int | float, optional): The scale factor for classification - cost. Default 1.0. - bbox_weight (int | float, optional): The scale factor for regression - L1 cost. Default 1.0. - iou_weight (int | float, optional): The scale factor for regression - iou cost. Default 1.0. - iou_calculator (dict | optional): The config for the iou calculation. - Default type `BboxOverlaps2D`. - iou_mode (str | optional): "iou" (intersection over union), "iof" - (intersection over foreground), or "giou" (generalized - intersection over union). Default "giou". - """ - - def __init__(self, - z_cfg = dict( - pred_z_flag=False, - gt_z_flag=False, - ), - cls_cost=dict(type='ClassificationCost', weight=1.), - reg_cost=dict(type='BBoxL1Cost', weight=1.0), - iou_cost=dict(type='IoUCost', weight=0.0), - pts_cost=dict(type='ChamferDistance',loss_src_weight=1.0,loss_dst_weight=1.0), - pc_range=None): - self.z_cfg = z_cfg - self.cls_cost = build_match_cost(cls_cost) - self.reg_cost = build_match_cost(reg_cost) - self.iou_cost = build_match_cost(iou_cost) - self.pts_cost = build_match_cost(pts_cost) - self.pc_range = pc_range - - @torch._dynamo.disable - def hungarian_match(self, cost, gt_labels, assigned_gt_inds, assigned_labels, num_gts, device): - cost = cost.detach().cpu() - if linear_sum_assignment is None: - raise ImportError('Please run "pip install scipy" ' - 'to install scipy first.') - - matched_row_inds, matched_col_inds = linear_sum_assignment(cost) - matched_row_inds = torch.as_tensor(matched_row_inds, device=device) - matched_col_inds = torch.as_tensor(matched_col_inds, device=device) - - assigned_gt_inds[:] = 0 - assigned_gt_inds[matched_row_inds] = matched_col_inds + 1 - - assigned_labels[matched_row_inds] = gt_labels[0][matched_col_inds] - assign_result = AssignResult(num_gts, assigned_gt_inds, None, labels=assigned_labels) - - return assign_result - - #@torch.compile(options={"triton.cudagraphs": True, "triton.cudagraph_trees": False}) - def assign(self, - bbox_pred, - cls_pred, - pts_pred, - gt_bboxes, - gt_labels, - gt_pts, - gt_bboxes_ignore=None, - eps=1e-7): - """Computes one-to-one matching based on the weighted costs. - This method assign each query prediction to a ground truth or - background. The `assigned_gt_inds` with -1 means don't care, - 0 means negative sample, and positive number is the index (1-based) - of assigned gt. - The assignment is done in the following steps, the order matters. - 1. assign every prediction to -1 - 2. compute the weighted costs - 3. do Hungarian matching on CPU based on the costs - 4. assign all to 0 (background) first, then for each matched pair - between predictions and gts, treat this prediction as foreground - and assign the corresponding gt index (plus 1) to it. - Args: - bbox_pred (Tensor): Predicted boxes with normalized coordinates - (cx, cy, w, h), which are all in range [0, 1]. Shape - [num_query, 4]. - cls_pred (Tensor): Predicted classification logits, shape - [num_query, num_class]. - gt_bboxes (Tensor): Ground truth boxes with unnormalized - coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). - gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are - labelled as `ignored`. Default None. - eps (int | float, optional): A value added to the denominator for - numerical stability. Default 1e-7. - Returns: - :obj:`AssignResult`: The assigned result. - """ - assert gt_bboxes_ignore is None, \ - 'Only case when gt_bboxes_ignore is None is supported.' - assert bbox_pred.shape[-1] == 4, \ - 'Only support bbox pred shape is 4 dims' - num_bboxes = bbox_pred.size(0) - - # 1. assign -1 by default - assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - assigned_labels = bbox_pred.new_full((num_bboxes, ), - -1, - dtype=torch.long) - - # if num_gts == 0 or num_bboxes == 0: - # # No ground truth or boxes, return empty assignment - # if num_gts == 0: - # # No ground truth, assign all to background - # assigned_gt_inds[:] = 0 - # return AssignResult( - # num_gts, assigned_gt_inds, None, labels=assigned_labels), None - - # 2. compute the weighted costs - # classification and bboxcost. - cls_cost = self.cls_cost(cls_pred, gt_labels[0]) - # regression L1 cost - normalized_gt_bboxes = normalize_2d_bbox(gt_bboxes[0], self.pc_range) - # normalized_gt_bboxes = gt_bboxes - - _, num_orders, num_pts_per_gtline, num_coords = gt_pts[0].shape - normalized_gt_pts = normalize_2d_pts(gt_pts[0], self.pc_range) if not self.z_cfg['gt_z_flag'] \ - else normalize_3d_pts(gt_pts[0], self.pc_range) - - num_pts_per_predline = pts_pred.size(1) - if num_pts_per_predline != num_pts_per_gtline: - pts_pred_interpolated = F.interpolate(pts_pred.permute(0,2,1), size=(num_pts_per_gtline), mode='linear', align_corners=True) - pts_pred_interpolated = pts_pred_interpolated.permute(0,2,1).contiguous() - else: - pts_pred_interpolated = pts_pred - - bboxes = denormalize_2d_bbox(bbox_pred, self.pc_range) - - # num_q, num_pts, 2 <-> num_gt, num_pts, 2 - pts_cost_ordered = self.pts_cost(pts_pred_interpolated, normalized_gt_pts) - pts_cost_ordered = pts_cost_ordered.view(num_bboxes, gt_bboxes[0].size(0), num_orders) - pts_cost, order_index = torch.min(pts_cost_ordered, 2) - - reg_cost = self.reg_cost(bbox_pred[:, :4], normalized_gt_bboxes[:, :4]) - iou_cost = self.iou_cost(bboxes, gt_bboxes[0]) - - cost = cls_cost + reg_cost + iou_cost + pts_cost - - # 3. do Hungarian matching on CPU using linear_sum_assignment - assign_result = self.hungarian_match(cost[:, gt_bboxes[1]], gt_labels, assigned_gt_inds, assigned_labels, gt_bboxes[2], bbox_pred.device) - - # 4. assign backgrounds and foregrounds - # assign all indices to backgrounds first - return assign_result, order_index - - # def assign(self, - # bbox_pred, - # cls_pred, - # pts_pred, - # gt_bboxes, - # gt_labels, - # gt_pts, - # gt_bboxes_ignore=None, - # eps=1e-7): - # """Computes one-to-one matching based on the weighted costs. - # This method assign each query prediction to a ground truth or - # background. The `assigned_gt_inds` with -1 means don't care, - # 0 means negative sample, and positive number is the index (1-based) - # of assigned gt. - # The assignment is done in the following steps, the order matters. - # 1. assign every prediction to -1 - # 2. compute the weighted costs - # 3. do Hungarian matching on CPU based on the costs - # 4. assign all to 0 (background) first, then for each matched pair - # between predictions and gts, treat this prediction as foreground - # and assign the corresponding gt index (plus 1) to it. - # Args: - # bbox_pred (Tensor): Predicted boxes with normalized coordinates - # (cx, cy, w, h), which are all in range [0, 1]. Shape - # [num_query, 4]. - # cls_pred (Tensor): Predicted classification logits, shape - # [num_query, num_class]. - # gt_bboxes (Tensor): Ground truth boxes with unnormalized - # coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. - # gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). - # gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are - # labelled as `ignored`. Default None. - # eps (int | float, optional): A value added to the denominator for - # numerical stability. Default 1e-7. - # Returns: - # :obj:`AssignResult`: The assigned result. - # """ - # assert gt_bboxes_ignore is None, \ - # 'Only case when gt_bboxes_ignore is None is supported.' - # assert bbox_pred.shape[-1] == 4, \ - # 'Only support bbox pred shape is 4 dims' - # num_bboxes = bbox_pred.size(0) - - # # 1. assign -1 by default - # assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), - # -1, - # dtype=torch.long) - # assigned_labels = bbox_pred.new_full((num_bboxes, ), - # -1, - # dtype=torch.long) - - # # if num_gts == 0 or num_bboxes == 0: - # # # No ground truth or boxes, return empty assignment - # # if num_gts == 0: - # # # No ground truth, assign all to background - # # assigned_gt_inds[:] = 0 - # # return AssignResult( - # # num_gts, assigned_gt_inds, None, labels=assigned_labels), None - - # # 2. compute the weighted costs - # # classification and bboxcost. - # cls_cost = self.cls_cost(cls_pred, gt_labels) - # # regression L1 cost - # normalized_gt_bboxes = normalize_2d_bbox(gt_bboxes, self.pc_range) - # # normalized_gt_bboxes = gt_bboxes - - # _, num_orders, num_pts_per_gtline, num_coords = gt_pts.shape - # normalized_gt_pts = normalize_2d_pts(gt_pts, self.pc_range) if not self.z_cfg['gt_z_flag'] \ - # else normalize_3d_pts(gt_pts, self.pc_range) - - # num_pts_per_predline = pts_pred.size(1) - # if num_pts_per_predline != num_pts_per_gtline: - # pts_pred_interpolated = F.interpolate(pts_pred.permute(0,2,1), size=(num_pts_per_gtline), mode='linear', align_corners=True) - # pts_pred_interpolated = pts_pred_interpolated.permute(0,2,1).contiguous() - # else: - # pts_pred_interpolated = pts_pred - - # bboxes = denormalize_2d_bbox(bbox_pred, self.pc_range) - - # # num_q, num_pts, 2 <-> num_gt, num_pts, 2 - # pts_cost_ordered = self.pts_cost(pts_pred_interpolated, normalized_gt_pts) - # pts_cost_ordered = pts_cost_ordered.view(num_bboxes, gt_bboxes.size(0), num_orders) - # pts_cost, order_index = torch.min(pts_cost_ordered, 2) - - # reg_cost = self.reg_cost(bbox_pred[:, :4], normalized_gt_bboxes[:, :4]) - # iou_cost = self.iou_cost(bboxes, gt_bboxes) - - # cost = cls_cost + reg_cost + iou_cost + pts_cost - - # # 3. do Hungarian matching on CPU using linear_sum_assignment - # assign_result = self.hungarian_match(cost, gt_labels, assigned_gt_inds, assigned_labels, gt_bboxes.size(0), bbox_pred.device) - - # # 4. assign backgrounds and foregrounds - # # assign all indices to backgrounds first - # return assign_result, order_index diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/__init__.py deleted file mode 100644 index 9a384d697f03d7bba24452198abc5101a48b4466..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .maptr_head import MapTRHead -from .maptrv2_head import MapTRv2Head \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptr_head.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptr_head.py deleted file mode 100644 index 44fd988eb35e5c43449ad1084f0ec11d5b9ec74d..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptr_head.py +++ /dev/null @@ -1,767 +0,0 @@ -import copy -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmdet.models import HEADS, build_loss -from mmdet.models.dense_heads import DETRHead -from mmdet3d.core.bbox.coders import build_bbox_coder -from mmcv.runner import force_fp32, auto_fp16 -from mmcv.cnn import Linear, bias_init_with_prob, xavier_init, constant_init -from mmdet.models.utils.transformer import inverse_sigmoid -from mmdet.core.bbox.transforms import bbox_xyxy_to_cxcywh, bbox_cxcywh_to_xyxy -from mmdet.core import (multi_apply, multi_apply, reduce_mean) -from mmcv.utils import TORCH_VERSION, digit_version - -def normalize_2d_bbox(bboxes, pc_range): - - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - cxcywh_bboxes = bbox_xyxy_to_cxcywh(bboxes) - cxcywh_bboxes[...,0:1] = cxcywh_bboxes[..., 0:1] - pc_range[0] - cxcywh_bboxes[...,1:2] = cxcywh_bboxes[...,1:2] - pc_range[1] - factor = bboxes.new_tensor([patch_w, patch_h,patch_w,patch_h]) - - normalized_bboxes = cxcywh_bboxes / factor - return normalized_bboxes - -def normalize_2d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - factor = pts.new_tensor([patch_w, patch_h]) - normalized_pts = new_pts / factor - return normalized_pts - -def denormalize_2d_bbox(bboxes, pc_range): - - bboxes = bbox_cxcywh_to_xyxy(bboxes) - bboxes[..., 0::2] = (bboxes[..., 0::2]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - bboxes[..., 1::2] = (bboxes[..., 1::2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - - return bboxes -def denormalize_2d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - return new_pts -@HEADS.register_module() -class MapTRHead(DETRHead): - """Head of Detr3D. - Args: - with_box_refine (bool): Whether to refine the reference points - in the decoder. Defaults to False. - as_two_stage (bool) : Whether to generate the proposal from - the outputs of encoder. - transformer (obj:`ConfigDict`): ConfigDict is used for building - the Encoder and Decoder. - bev_h, bev_w (int): spatial shape of BEV queries. - """ - - def __init__(self, - *args, - with_box_refine=False, - as_two_stage=False, - transformer=None, - bbox_coder=None, - num_cls_fcs=2, - code_weights=None, - bev_h=30, - bev_w=30, - num_vec=20, - num_pts_per_vec=2, - num_pts_per_gt_vec=2, - query_embed_type='all_pts', - transform_method='minmax', - gt_shift_pts_pattern='v0', - dir_interval=1, - loss_pts=dict(type='ChamferDistance', - loss_src_weight=1.0, - loss_dst_weight=1.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=2.0), - **kwargs): - - self.bev_h = bev_h - self.bev_w = bev_w - self.fp16_enabled = False - - self.with_box_refine = with_box_refine - self.as_two_stage = as_two_stage - self.bev_encoder_type = transformer.encoder.type - if self.as_two_stage: - transformer['as_two_stage'] = self.as_two_stage - if 'code_size' in kwargs: - self.code_size = kwargs['code_size'] - else: - self.code_size = 10 - if code_weights is not None: - self.code_weights = code_weights - else: - self.code_weights = [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2] - - self.bbox_coder = build_bbox_coder(bbox_coder) - self.pc_range = self.bbox_coder.pc_range - self.real_w = self.pc_range[3] - self.pc_range[0] - self.real_h = self.pc_range[4] - self.pc_range[1] - self.num_cls_fcs = num_cls_fcs - 1 - - - self.query_embed_type = query_embed_type - self.transform_method = transform_method - self.gt_shift_pts_pattern = gt_shift_pts_pattern - num_query = num_vec * num_pts_per_vec - self.num_query = num_query - self.num_vec = num_vec - self.num_pts_per_vec = num_pts_per_vec - self.num_pts_per_gt_vec = num_pts_per_gt_vec - self.dir_interval = dir_interval - - - super(MapTRHead, self).__init__( - *args, transformer=transformer, **kwargs) - self.code_weights = nn.Parameter(torch.tensor( - self.code_weights, requires_grad=False), requires_grad=False) - self.loss_pts = build_loss(loss_pts) - self.loss_dir = build_loss(loss_dir) - num_query = num_vec * num_pts_per_vec - self.num_query = num_query - self.num_vec = num_vec - self.num_pts_per_vec = num_pts_per_vec - self.num_pts_per_gt_vec = num_pts_per_gt_vec - self._init_layers() - - def _init_layers(self): - """Initialize classification branch and regression branch of head.""" - cls_branch = [] - # cls_branch.append(Linear(self.embed_dims * 2, self.embed_dims)) - # cls_branch.append(nn.LayerNorm(self.embed_dims)) - # cls_branch.append(nn.ReLU(inplace=True)) - for _ in range(self.num_reg_fcs): - cls_branch.append(Linear(self.embed_dims, self.embed_dims)) - cls_branch.append(nn.LayerNorm(self.embed_dims)) - cls_branch.append(nn.ReLU(inplace=True)) - cls_branch.append(Linear(self.embed_dims, self.cls_out_channels)) - fc_cls = nn.Sequential(*cls_branch) - - reg_branch = [] - for _ in range(self.num_reg_fcs): - reg_branch.append(Linear(self.embed_dims, self.embed_dims)) - reg_branch.append(nn.ReLU()) - reg_branch.append(Linear(self.embed_dims, self.code_size)) - reg_branch = nn.Sequential(*reg_branch) - - def _get_clones(module, N): - return nn.ModuleList([copy.deepcopy(module) for i in range(N)]) - - # last reg_branch is used to generate proposal from - # encode feature map when as_two_stage is True. - num_pred = (self.transformer.decoder.num_layers + 1) if \ - self.as_two_stage else self.transformer.decoder.num_layers - - if self.with_box_refine: - self.cls_branches = _get_clones(fc_cls, num_pred) - self.reg_branches = _get_clones(reg_branch, num_pred) - else: - self.cls_branches = nn.ModuleList( - [fc_cls for _ in range(num_pred)]) - self.reg_branches = nn.ModuleList( - [reg_branch for _ in range(num_pred)]) - - if not self.as_two_stage: - if self.bev_encoder_type == 'BEVFormerEncoder': - self.bev_embedding = nn.Embedding( - self.bev_h * self.bev_w, self.embed_dims) - else: - self.bev_embedding = None - if self.query_embed_type == 'all_pts': - self.query_embedding = nn.Embedding(self.num_query, - self.embed_dims * 2) - elif self.query_embed_type == 'instance_pts': - self.query_embedding = None - self.instance_embedding = nn.Embedding(self.num_vec, self.embed_dims * 2) - self.pts_embedding = nn.Embedding(self.num_pts_per_vec, self.embed_dims * 2) - - def init_weights(self): - """Initialize weights of the DeformDETR head.""" - self.transformer.init_weights() - if self.loss_cls.use_sigmoid: - bias_init = bias_init_with_prob(0.01) - for m in self.cls_branches: - nn.init.constant_(m[-1].bias, bias_init) - # for m in self.reg_branches: - # constant_init(m[-1], 0, bias=0) - # nn.init.constant_(self.reg_branches[0][-1].bias.data[2:], 0.) - - # @auto_fp16(apply_to=('mlvl_feats')) - @force_fp32(apply_to=('mlvl_feats', 'prev_bev')) - def forward(self, mlvl_feats, lidar_feat, img_metas, prev_bev=None, only_bev=False): - """Forward function. - Args: - mlvl_feats (tuple[Tensor]): Features from the upstream - network, each is a 5D-tensor with shape - (B, N, C, H, W). - prev_bev: previous bev featues - only_bev: only compute BEV features with encoder. - Returns: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, theta, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - """ - - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - # import pdb;pdb.set_trace() - if self.query_embed_type == 'all_pts': - object_query_embeds = self.query_embedding.weight.to(dtype) - elif self.query_embed_type == 'instance_pts': - pts_embeds = self.pts_embedding.weight.unsqueeze(0) - instance_embeds = self.instance_embedding.weight.unsqueeze(1) - object_query_embeds = (pts_embeds + instance_embeds).flatten(0, 1).to(dtype) - if self.bev_embedding is not None: - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - else: - bev_queries = None - bev_mask = None - bev_pos = None - - if only_bev: # only use encoder to obtain BEV features, TODO: refine the workaround - return self.transformer.get_bev_features( - mlvl_feats, - lidar_feat, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - ) - else: - outputs = self.transformer( - mlvl_feats, - lidar_feat, - bev_queries, - object_query_embeds, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - reg_branches=self.reg_branches if self.with_box_refine else None, # noqa:E501 - cls_branches=self.cls_branches if self.as_two_stage else None, - img_metas=img_metas, - prev_bev=prev_bev - ) - - bev_embed, hs, init_reference, inter_references = outputs - hs = hs.permute(0, 2, 1, 3) - outputs_classes = [] - outputs_coords = [] - outputs_pts_coords = [] - for lvl in range(hs.shape[0]): - if lvl == 0: - # import pdb;pdb.set_trace() - reference = init_reference - else: - reference = inter_references[lvl - 1] - reference = inverse_sigmoid(reference) - # import pdb;pdb.set_trace() - # vec_embedding = hs[lvl].reshape(bs, self.num_vec, -1) - outputs_class = self.cls_branches[lvl](hs[lvl] - .view(bs,self.num_vec, self.num_pts_per_vec,-1) - .mean(2)) - tmp = self.reg_branches[lvl](hs[lvl]) - - # TODO: check the shape of reference - assert reference.shape[-1] == 2 - tmp[..., 0:2] += reference[..., 0:2] - # tmp[..., 0:2] = tmp[..., 0:2].sigmoid() - tmp = tmp.sigmoid() # cx,cy,w,h - # import pdb;pdb.set_trace() - # tmp[..., 0:1] = (tmp[..., 0:1] * (self.pc_range[3] - - # self.pc_range[0]) + self.pc_range[0]) - # tmp[..., 1:2] = (tmp[..., 1:2] * (self.pc_range[4] - - # self.pc_range[1]) + self.pc_range[1]) - # tmp = tmp.reshape(bs, self.num_vec,-1) - # TODO: check if using sigmoid - outputs_coord, outputs_pts_coord = self.transform_box(tmp) - outputs_classes.append(outputs_class) - outputs_coords.append(outputs_coord) - outputs_pts_coords.append(outputs_pts_coord) - - outputs_classes = torch.stack(outputs_classes) - outputs_coords = torch.stack(outputs_coords) - outputs_pts_coords = torch.stack(outputs_pts_coords) - outs = { - 'bev_embed': bev_embed, - 'all_cls_scores': outputs_classes, - 'all_bbox_preds': outputs_coords, - 'all_pts_preds': outputs_pts_coords, - 'enc_cls_scores': None, - 'enc_bbox_preds': None, - 'enc_pts_preds': None - } - - return outs - def transform_box(self, pts, y_first=False): - """ - Converting the points set into bounding box. - - Args: - pts: the input points sets (fields), each points - set (fields) is represented as 2n scalar. - y_first: if y_fisrt=True, the point set is represented as - [y1, x1, y2, x2 ... yn, xn], otherwise the point set is - represented as [x1, y1, x2, y2 ... xn, yn]. - Returns: - The bbox [cx, cy, w, h] transformed from points. - """ - pts_reshape = pts.view(pts.shape[0], self.num_vec, - self.num_pts_per_vec,2) - pts_y = pts_reshape[:, :, :, 0] if y_first else pts_reshape[:, :, :, 1] - pts_x = pts_reshape[:, :, :, 1] if y_first else pts_reshape[:, :, :, 0] - if self.transform_method == 'minmax': - # import pdb;pdb.set_trace() - - xmin = pts_x.min(dim=2, keepdim=True)[0] - xmax = pts_x.max(dim=2, keepdim=True)[0] - ymin = pts_y.min(dim=2, keepdim=True)[0] - ymax = pts_y.max(dim=2, keepdim=True)[0] - bbox = torch.cat([xmin, ymin, xmax, ymax], dim=2) - bbox = bbox_xyxy_to_cxcywh(bbox) - else: - raise NotImplementedError - return bbox, pts_reshape - def _get_target_single(self, - cls_score, - bbox_pred, - pts_pred, - gt_labels, - gt_bboxes, - gt_shifts_pts, - gt_bboxes_ignore=None): - """"Compute regression and classification targets for one image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_score (Tensor): Box score logits from a single decoder layer - for one image. Shape [num_query, cls_out_channels]. - bbox_pred (Tensor): Sigmoid outputs from a single decoder layer - for one image, with normalized coordinate (cx, cy, w, h) and - shape [num_query, 4]. - gt_bboxes (Tensor): Ground truth bboxes for one image with - shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels (Tensor): Ground truth class indices for one image - with shape (num_gts, ). - gt_bboxes_ignore (Tensor, optional): Bounding boxes - which can be ignored. Default None. - Returns: - tuple[Tensor]: a tuple containing the following for one image. - - labels (Tensor): Labels of each image. - - label_weights (Tensor]): Label weights of each image. - - bbox_targets (Tensor): BBox targets of each image. - - bbox_weights (Tensor): BBox weights of each image. - - pos_inds (Tensor): Sampled positive indices for each image. - - neg_inds (Tensor): Sampled negative indices for each image. - """ - # import pdb;pdb.set_trace() - num_bboxes = bbox_pred.size(0) - # assigner and sampler - gt_c = gt_bboxes.shape[-1] - # import pdb;pdb.set_trace() - assign_result, order_index = self.assigner.assign(bbox_pred, cls_score, pts_pred, - gt_bboxes, gt_labels, gt_shifts_pts, - gt_bboxes_ignore) - - sampling_result = self.sampler.sample(assign_result, bbox_pred, - gt_bboxes) - # pts_sampling_result = self.sampler.sample(assign_result, pts_pred, - # gt_pts) - - - # import pdb;pdb.set_trace() - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - - # label targets - labels = gt_bboxes.new_full((num_bboxes,), - self.num_classes, - dtype=torch.long) - labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] - label_weights = gt_bboxes.new_ones(num_bboxes) - - # bbox targets - bbox_targets = torch.zeros_like(bbox_pred)[..., :gt_c] - bbox_weights = torch.zeros_like(bbox_pred) - bbox_weights[pos_inds] = 1.0 - - # pts targets - # import pdb;pdb.set_trace() - # pts_targets = torch.zeros_like(pts_pred) - # num_query, num_order, num_points, num_coords - if order_index is None: - # import pdb;pdb.set_trace() - assigned_shift = gt_labels[sampling_result.pos_assigned_gt_inds] - else: - assigned_shift = order_index[sampling_result.pos_inds, sampling_result.pos_assigned_gt_inds] - pts_targets = pts_pred.new_zeros((pts_pred.size(0), - pts_pred.size(1), pts_pred.size(2))) - pts_weights = torch.zeros_like(pts_targets) - pts_weights[pos_inds] = 1.0 - - # DETR - bbox_targets[pos_inds] = sampling_result.pos_gt_bboxes - pts_targets[pos_inds] = gt_shifts_pts[sampling_result.pos_assigned_gt_inds,assigned_shift,:,:] - return (labels, label_weights, bbox_targets, bbox_weights, - pts_targets, pts_weights, - pos_inds, neg_inds) - - def get_targets(self, - cls_scores_list, - bbox_preds_list, - pts_preds_list, - gt_bboxes_list, - gt_labels_list, - gt_shifts_pts_list, - gt_bboxes_ignore_list=None): - """"Compute regression and classification targets for a batch image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_scores_list (list[Tensor]): Box score logits from a single - decoder layer for each image with shape [num_query, - cls_out_channels]. - bbox_preds_list (list[Tensor]): Sigmoid outputs from a single - decoder layer for each image, with normalized coordinate - (cx, cy, w, h) and shape [num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - tuple: a tuple containing the following targets. - - labels_list (list[Tensor]): Labels for all images. - - label_weights_list (list[Tensor]): Label weights for all \ - images. - - bbox_targets_list (list[Tensor]): BBox targets for all \ - images. - - bbox_weights_list (list[Tensor]): BBox weights for all \ - images. - - num_total_pos (int): Number of positive samples in all \ - images. - - num_total_neg (int): Number of negative samples in all \ - images. - """ - assert gt_bboxes_ignore_list is None, \ - 'Only supports for gt_bboxes_ignore setting to None.' - num_imgs = len(cls_scores_list) - gt_bboxes_ignore_list = [ - gt_bboxes_ignore_list for _ in range(num_imgs) - ] - - (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pts_targets_list, pts_weights_list, - pos_inds_list, neg_inds_list) = multi_apply( - self._get_target_single, cls_scores_list, bbox_preds_list,pts_preds_list, - gt_labels_list, gt_bboxes_list, gt_shifts_pts_list, gt_bboxes_ignore_list) - num_total_pos = sum((inds.numel() for inds in pos_inds_list)) - num_total_neg = sum((inds.numel() for inds in neg_inds_list)) - return (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pts_targets_list, pts_weights_list, - num_total_pos, num_total_neg) - - def loss_single(self, - cls_scores, - bbox_preds, - pts_preds, - gt_bboxes_list, - gt_labels_list, - gt_shifts_pts_list, - gt_bboxes_ignore_list=None): - """"Loss function for outputs from a single decoder layer of a single - feature level. - Args: - cls_scores (Tensor): Box score logits from a single decoder layer - for all images. Shape [bs, num_query, cls_out_channels]. - bbox_preds (Tensor): Sigmoid outputs from a single decoder layer - for all images, with normalized coordinate (cx, cy, w, h) and - shape [bs, num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_pts_list (list[Tensor]): Ground truth pts for each image - with shape (num_gts, fixed_num, 2) in [x,y] format. - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components for outputs from - a single decoder layer. - """ - num_imgs = cls_scores.size(0) - cls_scores_list = [cls_scores[i] for i in range(num_imgs)] - bbox_preds_list = [bbox_preds[i] for i in range(num_imgs)] - pts_preds_list = [pts_preds[i] for i in range(num_imgs)] - # import pdb;pdb.set_trace() - cls_reg_targets = self.get_targets(cls_scores_list, bbox_preds_list,pts_preds_list, - gt_bboxes_list, gt_labels_list,gt_shifts_pts_list, - gt_bboxes_ignore_list) - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - pts_targets_list, pts_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - # import pdb;pdb.set_trace() - labels = torch.cat(labels_list, 0) - label_weights = torch.cat(label_weights_list, 0) - bbox_targets = torch.cat(bbox_targets_list, 0) - bbox_weights = torch.cat(bbox_weights_list, 0) - pts_targets = torch.cat(pts_targets_list, 0) - pts_weights = torch.cat(pts_weights_list, 0) - - # classification loss - cls_scores = cls_scores.reshape(-1, self.cls_out_channels) - # construct weighted avg_factor to match with the official DETR repo - cls_avg_factor = num_total_pos * 1.0 + \ - num_total_neg * self.bg_cls_weight - if self.sync_cls_avg_factor: - cls_avg_factor = reduce_mean( - cls_scores.new_tensor([cls_avg_factor])) - - cls_avg_factor = max(cls_avg_factor, 1) - loss_cls = self.loss_cls( - cls_scores, labels, label_weights, avg_factor=cls_avg_factor) - - # Compute the average number of gt boxes accross all gpus, for - # normalization purposes - num_total_pos = loss_cls.new_tensor([num_total_pos]) - num_total_pos = torch.clamp(reduce_mean(num_total_pos), min=1).item() - - # import pdb;pdb.set_trace() - # regression L1 loss - bbox_preds = bbox_preds.reshape(-1, bbox_preds.size(-1)) - normalized_bbox_targets = normalize_2d_bbox(bbox_targets, self.pc_range) - # normalized_bbox_targets = bbox_targets - isnotnan = torch.isfinite(normalized_bbox_targets).all(dim=-1) - bbox_weights = bbox_weights * self.code_weights - - loss_bbox = self.loss_bbox( - bbox_preds[isnotnan, :4], normalized_bbox_targets[isnotnan, - :4], bbox_weights[isnotnan, :4], - avg_factor=num_total_pos) - - # regression pts CD loss - # pts_preds = pts_preds - # import pdb;pdb.set_trace() - - # num_samples, num_order, num_pts, num_coords - normalized_pts_targets = normalize_2d_pts(pts_targets, self.pc_range) - - # num_samples, num_pts, num_coords - pts_preds = pts_preds.reshape(-1, pts_preds.size(-2),pts_preds.size(-1)) - if self.num_pts_per_vec != self.num_pts_per_gt_vec: - pts_preds = pts_preds.permute(0,2,1) - pts_preds = F.interpolate(pts_preds, size=(self.num_pts_per_gt_vec), mode='linear', - align_corners=True) - pts_preds = pts_preds.permute(0,2,1).contiguous() - - # import pdb;pdb.set_trace() - loss_pts = self.loss_pts( - pts_preds[isnotnan,:,:], normalized_pts_targets[isnotnan, - :,:], - pts_weights[isnotnan,:,:], - avg_factor=num_total_pos) - dir_weights = pts_weights[:, :-self.dir_interval,0] - denormed_pts_preds = denormalize_2d_pts(pts_preds, self.pc_range) - denormed_pts_preds_dir = denormed_pts_preds[:,self.dir_interval:,:] - denormed_pts_preds[:,:-self.dir_interval,:] - pts_targets_dir = pts_targets[:, self.dir_interval:,:] - pts_targets[:,:-self.dir_interval,:] - # dir_weights = pts_weights[:, indice,:-1,0] - # import pdb;pdb.set_trace() - loss_dir = self.loss_dir( - denormed_pts_preds_dir[isnotnan,:,:], pts_targets_dir[isnotnan, - :,:], - dir_weights[isnotnan,:], - avg_factor=num_total_pos) - - bboxes = denormalize_2d_bbox(bbox_preds, self.pc_range) - # regression IoU loss, defaultly GIoU loss - loss_iou = self.loss_iou( - bboxes[isnotnan, :4], bbox_targets[isnotnan, :4], bbox_weights[isnotnan, :4], - avg_factor=num_total_pos) - - if digit_version(TORCH_VERSION) >= digit_version('1.8'): - loss_cls = torch.nan_to_num(loss_cls) - loss_bbox = torch.nan_to_num(loss_bbox) - loss_iou = torch.nan_to_num(loss_iou) - loss_pts = torch.nan_to_num(loss_pts) - loss_dir = torch.nan_to_num(loss_dir) - return loss_cls, loss_bbox, loss_iou, loss_pts, loss_dir - - @force_fp32(apply_to=('preds_dicts')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - preds_dicts, - gt_bboxes_ignore=None, - img_metas=None): - """"Loss function. - Args: - - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - preds_dicts: - all_cls_scores (Tensor): Classification score of all - decoder layers, has shape - [nb_dec, bs, num_query, cls_out_channels]. - all_bbox_preds (Tensor): Sigmoid regression - outputs of all decode layers. Each is a 4D-tensor with - normalized coordinate format (cx, cy, w, h) and shape - [nb_dec, bs, num_query, 4]. - enc_cls_scores (Tensor): Classification scores of - points on encode feature map , has shape - (N, h*w, num_classes). Only be passed when as_two_stage is - True, otherwise is None. - enc_bbox_preds (Tensor): Regression results of each points - on the encode feature map, has shape (N, h*w, 4). Only be - passed when as_two_stage is True, otherwise is None. - gt_bboxes_ignore (list[Tensor], optional): Bounding boxes - which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components. - """ - assert gt_bboxes_ignore is None, \ - f'{self.__class__.__name__} only supports ' \ - f'for gt_bboxes_ignore setting to None.' - gt_vecs_list = copy.deepcopy(gt_bboxes_list) - # import pdb;pdb.set_trace() - all_cls_scores = preds_dicts['all_cls_scores'] - all_bbox_preds = preds_dicts['all_bbox_preds'] - all_pts_preds = preds_dicts['all_pts_preds'] - enc_cls_scores = preds_dicts['enc_cls_scores'] - enc_bbox_preds = preds_dicts['enc_bbox_preds'] - enc_pts_preds = preds_dicts['enc_pts_preds'] - - num_dec_layers = len(all_cls_scores) - device = gt_labels_list[0].device - - # gt_bboxes_list = [torch.cat( - # (gt_bboxes.gravity_center, gt_bboxes.tensor[:, 3:]), - # dim=1).to(device) for gt_bboxes in gt_bboxes_list] - # import pdb;pdb.set_trace() - # gt_bboxes_list = [ - # gt_bboxes.to(device) for gt_bboxes in gt_bboxes_list] - gt_bboxes_list = [ - gt_bboxes.bbox.to(device) for gt_bboxes in gt_vecs_list] - gt_pts_list = [ - gt_bboxes.fixed_num_sampled_points.to(device) for gt_bboxes in gt_vecs_list] - if self.gt_shift_pts_pattern == 'v0': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points.to(device) for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v1': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v1.to(device) for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v2': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v2.to(device) for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v3': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v3.to(device) for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v4': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v4.to(device) for gt_bboxes in gt_vecs_list] - else: - raise NotImplementedError - all_gt_bboxes_list = [gt_bboxes_list for _ in range(num_dec_layers)] - all_gt_labels_list = [gt_labels_list for _ in range(num_dec_layers)] - all_gt_pts_list = [gt_pts_list for _ in range(num_dec_layers)] - all_gt_shifts_pts_list = [gt_shifts_pts_list for _ in range(num_dec_layers)] - all_gt_bboxes_ignore_list = [ - gt_bboxes_ignore for _ in range(num_dec_layers) - ] - # import pdb;pdb.set_trace() - losses_cls, losses_bbox, losses_iou, losses_pts, losses_dir = multi_apply( - self.loss_single, all_cls_scores, all_bbox_preds,all_pts_preds, - all_gt_bboxes_list, all_gt_labels_list,all_gt_shifts_pts_list, - all_gt_bboxes_ignore_list) - - loss_dict = dict() - # loss of proposal generated from encode feature map. - if enc_cls_scores is not None: - binary_labels_list = [ - torch.zeros_like(gt_labels_list[i]) - for i in range(len(all_gt_labels_list)) - ] - # TODO bug here - enc_loss_cls, enc_losses_bbox, enc_losses_iou, enc_losses_pts, enc_losses_dir = \ - self.loss_single(enc_cls_scores, enc_bbox_preds, enc_pts_preds, - gt_bboxes_list, binary_labels_list, gt_pts_list,gt_bboxes_ignore) - loss_dict['enc_loss_cls'] = enc_loss_cls - loss_dict['enc_loss_bbox'] = enc_losses_bbox - loss_dict['enc_losses_iou'] = enc_losses_iou - loss_dict['enc_losses_pts'] = enc_losses_pts - loss_dict['enc_losses_dir'] = enc_losses_dir - - # loss from the last decoder layer - loss_dict['loss_cls'] = losses_cls[-1] - loss_dict['loss_bbox'] = losses_bbox[-1] - loss_dict['loss_iou'] = losses_iou[-1] - loss_dict['loss_pts'] = losses_pts[-1] - loss_dict['loss_dir'] = losses_dir[-1] - # loss from other decoder layers - num_dec_layer = 0 - for loss_cls_i, loss_bbox_i, loss_iou_i, loss_pts_i, loss_dir_i in zip(losses_cls[:-1], - losses_bbox[:-1], - losses_iou[:-1], - losses_pts[:-1], - losses_dir[:-1]): - loss_dict[f'd{num_dec_layer}.loss_cls'] = loss_cls_i - loss_dict[f'd{num_dec_layer}.loss_bbox'] = loss_bbox_i - loss_dict[f'd{num_dec_layer}.loss_iou'] = loss_iou_i - loss_dict[f'd{num_dec_layer}.loss_pts'] = loss_pts_i - loss_dict[f'd{num_dec_layer}.loss_dir'] = loss_dir_i - num_dec_layer += 1 - return loss_dict - - @force_fp32(apply_to=('preds_dicts')) - def get_bboxes(self, preds_dicts, img_metas, rescale=False): - """Generate bboxes from bbox head predictions. - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - img_metas (list[dict]): Point cloud and image's meta info. - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - """ - # bboxes: xmin, ymin, xmax, ymax - preds_dicts = self.bbox_coder.decode(preds_dicts) - - num_samples = len(preds_dicts) - ret_list = [] - for i in range(num_samples): - preds = preds_dicts[i] - bboxes = preds['bboxes'] - # bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - - # code_size = bboxes.shape[-1] - # bboxes = img_metas[i]['box_type_3d'](bboxes, code_size) - scores = preds['scores'] - labels = preds['labels'] - pts = preds['pts'] - - ret_list.append([bboxes, scores, labels, pts]) - - return ret_list - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptrv2_head.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptrv2_head.py deleted file mode 100644 index f355edbca199819487742ed54440c6e678845ba9..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/dense_heads/maptrv2_head.py +++ /dev/null @@ -1,1014 +0,0 @@ -import copy -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmdet.models import HEADS, build_loss -from mmdet.models.dense_heads import DETRHead -from mmdet3d.core.bbox.coders import build_bbox_coder -from mmcv.runner import force_fp32, auto_fp16 -from mmcv.cnn import Linear, bias_init_with_prob, xavier_init, constant_init -from mmdet.models.utils.transformer import inverse_sigmoid -from mmdet.core.bbox.transforms import bbox_xyxy_to_cxcywh, bbox_cxcywh_to_xyxy -from mmdet.core import (multi_apply, multi_apply, reduce_mean) -from mmcv.utils import TORCH_VERSION, digit_version - -def denormalize_3d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - new_pts[...,2:3] = (pts[...,2:3]*(pc_range[5] - - pc_range[2]) + pc_range[2]) - return new_pts - -#@torch.compile(mode="max-autotune-no-cudagraphs") -def normalize_3d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - patch_z = pc_range[5]-pc_range[2] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - new_pts[...,2:3] = pts[...,2:3] - pc_range[2] - factor = pts.new_tensor([patch_w, patch_h,patch_z]) - normalized_pts = new_pts / factor - return normalized_pts - -#@torch.compile(mode="max-autotune-no-cudagraphs") -def normalize_2d_bbox(bboxes, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - cxcywh_bboxes = bbox_xyxy_to_cxcywh(bboxes) - cxcywh_bboxes[...,0:1] = cxcywh_bboxes[..., 0:1] - pc_range[0] - cxcywh_bboxes[...,1:2] = cxcywh_bboxes[...,1:2] - pc_range[1] - factor = bboxes.new_tensor([patch_w, patch_h,patch_w,patch_h]) - - normalized_bboxes = cxcywh_bboxes / factor - return normalized_bboxes - -#@torch.compile(mode="max-autotune-no-cudagraphs") -def normalize_2d_pts(pts, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - new_pts = pts.clone() - new_pts[...,0:1] = pts[..., 0:1] - pc_range[0] - new_pts[...,1:2] = pts[...,1:2] - pc_range[1] - factor = pts.new_tensor([patch_w, patch_h]) - normalized_pts = new_pts / factor - return normalized_pts - -#@torch.compile(mode="max-autotune-no-cudagraphs") -def denormalize_2d_bbox(bboxes, pc_range): - - bboxes = bbox_cxcywh_to_xyxy(bboxes) - bboxes[..., 0::2] = (bboxes[..., 0::2]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - bboxes[..., 1::2] = (bboxes[..., 1::2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - return bboxes - -#@torch.compile(mode="max-autotune-no-cudagraphs") -def denormalize_2d_pts(pts, pc_range): - new_pts = pts.clone() - new_pts[...,0:1] = (pts[..., 0:1]*(pc_range[3] - - pc_range[0]) + pc_range[0]) - new_pts[...,1:2] = (pts[...,1:2]*(pc_range[4] - - pc_range[1]) + pc_range[1]) - return new_pts - - -@HEADS.register_module() -class MapTRv2Head(DETRHead): - """Head of Detr3D. - Args: - with_box_refine (bool): Whether to refine the reference points - in the decoder. Defaults to False. - as_two_stage (bool) : Whether to generate the proposal from - the outputs of encoder. - transformer (obj:`ConfigDict`): ConfigDict is used for building - the Encoder and Decoder. - bev_h, bev_w (int): spatial shape of BEV queries. - """ - - def __init__(self, - *args, - with_box_refine=False, - as_two_stage=False, - transformer=None, - bbox_coder=None, - num_cls_fcs=2, - code_weights=None, - bev_h=30, - bev_w=30, - # num_vec=20, - num_vec_one2one=50, - num_vec_one2many=0, - k_one2many=0, - lambda_one2many=1, - num_pts_per_vec=2, - num_pts_per_gt_vec=2, - query_embed_type='all_pts', - transform_method='minmax', - gt_shift_pts_pattern='v0', - dir_interval=1, - aux_seg = dict( - use_aux_seg=False, - bev_seg=False, - pv_seg=False, - seg_classes=1, - feat_down_sample=32, - ), - z_cfg = dict( - pred_z_flag=False, - gt_z_flag=False, - ), - loss_pts=dict(type='ChamferDistance', - loss_src_weight=1.0, - loss_dst_weight=1.0), - loss_seg=dict(type='SimpleLoss', - pos_weight=2.13, - loss_weight=1.0), - loss_pv_seg=dict(type='SimpleLoss', - pos_weight=2.13, - loss_weight=1.0), - loss_dir=dict(type='PtsDirCosLoss', loss_weight=2.0), - **kwargs): - - self.bev_h = bev_h - self.bev_w = bev_w - self.fp16_enabled = False - - self.with_box_refine = with_box_refine - self.as_two_stage = as_two_stage - self.bev_encoder_type = transformer.encoder.type - if self.as_two_stage: - transformer['as_two_stage'] = self.as_two_stage - if 'code_size' in kwargs: - self.code_size = 2 if not z_cfg['pred_z_flag'] else 3 - else: - self.code_size = 2 - if code_weights is not None: - self.code_weights = code_weights - else: - self.code_weights = [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2] - - self.bbox_coder = build_bbox_coder(bbox_coder) - self.pc_range = self.bbox_coder.pc_range - self.real_w = self.pc_range[3] - self.pc_range[0] - self.real_h = self.pc_range[4] - self.pc_range[1] - self.num_cls_fcs = num_cls_fcs - 1 - - - self.query_embed_type = query_embed_type - self.transform_method = transform_method - self.gt_shift_pts_pattern = gt_shift_pts_pattern - - num_vec = num_vec_one2one + num_vec_one2many - num_query = num_vec * num_pts_per_vec - self.num_query = num_query - self.num_vec = num_vec - self.num_pts_per_vec = num_pts_per_vec - self.num_pts_per_gt_vec = num_pts_per_gt_vec - self.dir_interval = dir_interval - self.aux_seg = aux_seg - self.z_cfg = z_cfg - - super(MapTRv2Head, self).__init__( - *args, transformer=transformer, **kwargs) - self.code_weights = nn.Parameter(torch.tensor( - self.code_weights, requires_grad=False), requires_grad=False) - self.loss_pts = build_loss(loss_pts) - self.loss_dir = build_loss(loss_dir) - - - num_query = num_vec * num_pts_per_vec - self.num_query = num_query - self.num_vec = num_vec - self.num_pts_per_vec = num_pts_per_vec - self.num_pts_per_gt_vec = num_pts_per_gt_vec - self.num_vec_one2one = num_vec_one2one - self.num_vec_one2many = num_vec_one2many - self.k_one2many = k_one2many - self.lambda_one2many=lambda_one2many - - self.loss_seg = build_loss(loss_seg) - self.loss_pv_seg = build_loss(loss_pv_seg) - - self._init_layers() - - def _init_layers(self): - """Initialize classification branch and regression branch of head.""" - cls_branch = [] - # cls_branch.append(Linear(self.embed_dims * 2, self.embed_dims)) - # cls_branch.append(nn.LayerNorm(self.embed_dims)) - # cls_branch.append(nn.ReLU(inplace=True)) - for _ in range(self.num_reg_fcs): - cls_branch.append(Linear(self.embed_dims, self.embed_dims)) - cls_branch.append(nn.LayerNorm(self.embed_dims)) - cls_branch.append(nn.ReLU(inplace=True)) - cls_branch.append(Linear(self.embed_dims, self.cls_out_channels)) - fc_cls = nn.Sequential(*cls_branch) - - reg_branch = [] - for _ in range(self.num_reg_fcs): - reg_branch.append(Linear(self.embed_dims, self.embed_dims)) - reg_branch.append(nn.ReLU()) - reg_branch.append(Linear(self.embed_dims, self.code_size)) - reg_branch = nn.Sequential(*reg_branch) - - def _get_clones(module, N): - return nn.ModuleList([copy.deepcopy(module) for i in range(N)]) - - # last reg_branch is used to generate proposal from - # encode feature map when as_two_stage is True. - num_pred = (self.transformer.decoder.num_layers + 1) if \ - self.as_two_stage else self.transformer.decoder.num_layers - - if self.with_box_refine: - self.cls_branches = _get_clones(fc_cls, num_pred) - self.reg_branches = _get_clones(reg_branch, num_pred) - else: - self.cls_branches = nn.ModuleList( - [fc_cls for _ in range(num_pred)]) - self.reg_branches = nn.ModuleList( - [reg_branch for _ in range(num_pred)]) - - if self.aux_seg['use_aux_seg']: - if not (self.aux_seg['bev_seg'] or self.aux_seg['pv_seg']): - raise ValueError('aux_seg must have bev_seg or pv_seg') - if self.aux_seg['bev_seg']: - self.seg_head = nn.Sequential( - nn.Conv2d(self.embed_dims, self.embed_dims, kernel_size=3, padding=1, bias=False), - # nn.BatchNorm2d(128), - nn.ReLU(inplace=True), - nn.Conv2d(self.embed_dims, self.aux_seg['seg_classes'], kernel_size=1, padding=0) - ) - if self.aux_seg['pv_seg']: - self.pv_seg_head = nn.Sequential( - nn.Conv2d(self.embed_dims, self.embed_dims, kernel_size=3, padding=1, bias=False), - # nn.BatchNorm2d(128), - nn.ReLU(inplace=True), - nn.Conv2d(self.embed_dims, self.aux_seg['seg_classes'], kernel_size=1, padding=0) - ) - - if not self.as_two_stage: - if 'BEVFormerEncoder' in self.bev_encoder_type: - self.bev_embedding = nn.Embedding( - self.bev_h * self.bev_w, self.embed_dims) - else: - self.bev_embedding = None - if self.query_embed_type == 'all_pts': - self.query_embedding = nn.Embedding(self.num_query, - self.embed_dims * 2) - elif self.query_embed_type == 'instance_pts': - self.query_embedding = None - self.instance_embedding = nn.Embedding(self.num_vec, self.embed_dims * 2) - self.pts_embedding = nn.Embedding(self.num_pts_per_vec, self.embed_dims * 2) - - def init_weights(self): - """Initialize weights of the DeformDETR head.""" - self.transformer.init_weights() - if self.loss_cls.use_sigmoid: - bias_init = bias_init_with_prob(0.01) - for m in self.cls_branches: - nn.init.constant_(m[-1].bias, bias_init) - # for m in self.reg_branches: - # constant_init(m[-1], 0, bias=0) - # nn.init.constant_(self.reg_branches[0][-1].bias.data[2:], 0.) - - #@torch.compile(mode="max-autotune-no-cudagraphs") #### - def compute_decoder_predictions(self, outputs, bs, num_vec, mlvl_feats): - bev_embed,depth, hs, init_reference, inter_references = outputs - hs = hs.permute(0, 2, 1, 3) - outputs_classes_one2one = [] - outputs_coords_one2one = [] - outputs_pts_coords_one2one = [] - - outputs_classes_one2many = [] - outputs_coords_one2many = [] - outputs_pts_coords_one2many = [] - for lvl in range(hs.shape[0]): - if lvl == 0: - # import pdb;pdb.set_trace() - reference = init_reference[...,0:2] if not self.z_cfg['gt_z_flag'] else init_reference[...,0:3] - else: - reference = inter_references[lvl - 1][...,0:2] if not self.z_cfg['gt_z_flag'] else inter_references[lvl - 1][...,0:3] - reference = inverse_sigmoid(reference) - # import pdb;pdb.set_trace() - # vec_embedding = hs[lvl].reshape(bs, self.num_vec, -1) - outputs_class = self.cls_branches[lvl](hs[lvl] - .view(bs,num_vec, self.num_pts_per_vec,-1) - .mean(2)) - tmp = self.reg_branches[lvl](hs[lvl]) - tmp = tmp[..., 0:2] if not self.z_cfg['gt_z_flag'] else tmp[..., 0:3] - # TODO: check the shape of reference - # assert reference.shape[-1] == 2 - # tmp[..., 0:2] += reference[..., 0:2] - # assert reference.shape[-1] == 2 - tmp += reference - - tmp = tmp.sigmoid() # cx,cy,w,h - # if not self.z_cfg['gt_z_flag']: - # tmp = tmp[..., 0:2] if not self.z_cfg['gt_z_flag'] else tmp[..., 0:3] - # TODO: check if using sigmoid - outputs_coord, outputs_pts_coord = self.transform_box(tmp,num_vec=num_vec) - - outputs_classes_one2one.append(outputs_class[:, 0:self.num_vec_one2one]) - outputs_coords_one2one.append(outputs_coord[:, 0:self.num_vec_one2one]) - outputs_pts_coords_one2one.append(outputs_pts_coord[:, 0:self.num_vec_one2one]) - - outputs_classes_one2many.append(outputs_class[:, self.num_vec_one2one:]) - outputs_coords_one2many.append(outputs_coord[:, self.num_vec_one2one:]) - outputs_pts_coords_one2many.append(outputs_pts_coord[:, self.num_vec_one2one:]) - - outputs_seg = None - outputs_pv_seg = None - if self.aux_seg['use_aux_seg']: - seg_bev_embed = bev_embed.permute(1,0,2).view(bs,self.bev_h, self.bev_w, -1).permute(0,3,1,2).contiguous() - if self.aux_seg['bev_seg']: - outputs_seg = self.seg_head(seg_bev_embed) - bs, num_cam, embed_dims, feat_h, feat_w = mlvl_feats[-1].shape - if self.aux_seg['pv_seg']: - outputs_pv_seg = self.pv_seg_head(mlvl_feats[-1].flatten(0,1)) - outputs_pv_seg = outputs_pv_seg.view(bs, num_cam, -1, feat_h, feat_w) - - return bev_embed, outputs_classes_one2one, outputs_coords_one2one, outputs_pts_coords_one2one, depth, outputs_seg, outputs_pv_seg, outputs_classes_one2many, outputs_coords_one2many, outputs_pts_coords_one2many - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def prepare_transformer_inputs(self, mlvl_feats): - - if self.training: - num_vec = self.num_vec - else: - num_vec = self.num_vec_one2one - - - bs, num_cam, _, _, _ = mlvl_feats[0].shape - dtype = mlvl_feats[0].dtype - if self.query_embed_type == 'all_pts': - object_query_embeds = self.query_embedding.weight.to(dtype) - elif self.query_embed_type == 'instance_pts': - pts_embeds = self.pts_embedding.weight.unsqueeze(0) - instance_embeds = self.instance_embedding.weight[0:num_vec].unsqueeze(1) - object_query_embeds = (pts_embeds + instance_embeds).flatten(0, 1).to(dtype) - if self.bev_embedding is not None: - bev_queries = self.bev_embedding.weight.to(dtype) - - bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - device=bev_queries.device).to(dtype) - bev_pos = self.positional_encoding(bev_mask).to(dtype) - else: - bev_queries = None - bev_mask = None - bev_pos = None - - # make attn mask - """ attention mask to prevent information leakage - """ - self_attn_mask = ( - torch.zeros([num_vec, num_vec,]).bool().to(mlvl_feats[0].device) - ) - self_attn_mask[self.num_vec_one2one :, 0 : self.num_vec_one2one,] = True - self_attn_mask[0 : self.num_vec_one2one, self.num_vec_one2one :,] = True - - return num_vec, object_query_embeds, bev_queries, bev_pos, self_attn_mask, bs - - # @auto_fp16(apply_to=('mlvl_feats')) - @force_fp32(apply_to=('mlvl_feats', 'prev_bev')) - def forward(self, mlvl_feats, lidar_feat, img_metas, prev_bev=None, only_bev=False): - """Forward function. - Args: - mlvl_feats (tuple[Tensor]): Features from the upstream - network, each is a 5D-tensor with shape - (B, N, C, H, W). - prev_bev: previous bev featues - only_bev: only compute BEV features with encoder. - Returns: - all_cls_scores (Tensor): Outputs from the classification head, \ - shape [nb_dec, bs, num_query, cls_out_channels]. Note \ - cls_out_channels should includes background. - all_bbox_preds (Tensor): Sigmoid outputs from the regression \ - head with normalized coordinate format (cx, cy, w, l, cz, h, theta, vx, vy). \ - Shape [nb_dec, bs, num_query, 9]. - """ - # if self.training: - # num_vec = self.num_vec - # else: - # num_vec = self.num_vec_one2one - # # import ipdb;ipdb.set_trace() - - - # bs, num_cam, _, _, _ = mlvl_feats[0].shape - # dtype = mlvl_feats[0].dtype - # # import ipdb;ipdb.set_trace() - # if self.query_embed_type == 'all_pts': - # object_query_embeds = self.query_embedding.weight.to(dtype) - # elif self.query_embed_type == 'instance_pts': - # pts_embeds = self.pts_embedding.weight.unsqueeze(0) - # instance_embeds = self.instance_embedding.weight[0:num_vec].unsqueeze(1) - # object_query_embeds = (pts_embeds + instance_embeds).flatten(0, 1).to(dtype) - # if self.bev_embedding is not None: - # bev_queries = self.bev_embedding.weight.to(dtype) - - # bev_mask = torch.zeros((bs, self.bev_h, self.bev_w), - # device=bev_queries.device).to(dtype) - # bev_pos = self.positional_encoding(bev_mask).to(dtype) - # else: - # bev_queries = None - # bev_mask = None - # bev_pos = None - - # # make attn mask - # """ attention mask to prevent information leakage - # """ - # self_attn_mask = ( - # torch.zeros([num_vec, num_vec,]).bool().to(mlvl_feats[0].device) - # ) - # self_attn_mask[self.num_vec_one2one :, 0 : self.num_vec_one2one,] = True - # self_attn_mask[0 : self.num_vec_one2one, self.num_vec_one2one :,] = True - - num_vec, object_query_embeds, bev_queries, bev_pos, self_attn_mask, bs = self.prepare_transformer_inputs(mlvl_feats) - - if only_bev: # only use encoder to obtain BEV features, TODO: refine the workaround - return self.transformer.get_bev_features( - mlvl_feats, - lidar_feat, - bev_queries, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - img_metas=img_metas, - prev_bev=prev_bev, - )['bev'] - else: - outputs = self.transformer( - mlvl_feats, - lidar_feat, - bev_queries, - object_query_embeds, - self.bev_h, - self.bev_w, - grid_length=(self.real_h / self.bev_h, - self.real_w / self.bev_w), - bev_pos=bev_pos, - reg_branches=self.reg_branches if self.with_box_refine else None, # noqa:E501 - cls_branches=self.cls_branches if self.as_two_stage else None, - img_metas=img_metas, - prev_bev=prev_bev, - self_attn_mask=self_attn_mask, - num_vec=num_vec, - num_pts_per_vec=self.num_pts_per_vec, - ) - - bev_embed, outputs_classes_one2one, outputs_coords_one2one, outputs_pts_coords_one2one, depth, outputs_seg, outputs_pv_seg, outputs_classes_one2many, outputs_coords_one2many, outputs_pts_coords_one2many = self.compute_decoder_predictions(outputs, bs, num_vec, mlvl_feats) - - outputs_classes_one2one = torch.stack(outputs_classes_one2one) - outputs_coords_one2one = torch.stack(outputs_coords_one2one) - outputs_pts_coords_one2one = torch.stack(outputs_pts_coords_one2one) - - outputs_classes_one2many = torch.stack(outputs_classes_one2many) - outputs_coords_one2many = torch.stack(outputs_coords_one2many) - outputs_pts_coords_one2many = torch.stack(outputs_pts_coords_one2many) - - outs = { - 'bev_embed': bev_embed, - 'all_cls_scores': outputs_classes_one2one, - 'all_bbox_preds': outputs_coords_one2one, - 'all_pts_preds': outputs_pts_coords_one2one, - 'enc_cls_scores': None, - 'enc_bbox_preds': None, - 'enc_pts_preds': None, - 'depth': depth, - 'seg': outputs_seg, - 'pv_seg': outputs_pv_seg, - "one2many_outs": dict( - all_cls_scores=outputs_classes_one2many, - all_bbox_preds=outputs_coords_one2many, - all_pts_preds=outputs_pts_coords_one2many, - enc_cls_scores=None, - enc_bbox_preds=None, - enc_pts_preds=None, - seg=None, - pv_seg=None, - ) - } - - return outs - - def transform_box(self, pts, num_vec=50, y_first=False): - """ - Converting the points set into bounding box. - - Args: - pts: the input points sets (fields), each points - set (fields) is represented as 2n scalar. - y_first: if y_fisrt=True, the point set is represented as - [y1, x1, y2, x2 ... yn, xn], otherwise the point set is - represented as [x1, y1, x2, y2 ... xn, yn]. - Returns: - The bbox [cx, cy, w, h] transformed from points. - """ - if self.z_cfg['gt_z_flag']: - pts_reshape = pts.view(pts.shape[0], num_vec, - self.num_pts_per_vec,3) - else: - pts_reshape = pts.view(pts.shape[0], num_vec, - self.num_pts_per_vec,2) - pts_y = pts_reshape[:, :, :, 0] if y_first else pts_reshape[:, :, :, 1] - pts_x = pts_reshape[:, :, :, 1] if y_first else pts_reshape[:, :, :, 0] - if self.transform_method == 'minmax': - # import pdb;pdb.set_trace() - - xmin = pts_x.min(dim=2, keepdim=True)[0] - xmax = pts_x.max(dim=2, keepdim=True)[0] - ymin = pts_y.min(dim=2, keepdim=True)[0] - ymax = pts_y.max(dim=2, keepdim=True)[0] - bbox = torch.cat([xmin, ymin, xmax, ymax], dim=2) - bbox = bbox_xyxy_to_cxcywh(bbox) - else: - raise NotImplementedError - return bbox, pts_reshape - - def get_label_result(self, sampling_result, gt_bboxes, gt_labels, bbox_pred, order_index, pts_pred, gt_shifts_pts): - - num_bboxes = bbox_pred.size(0) - gt_c = gt_bboxes.shape[-1] - - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - pos_assigned_gt_inds = sampling_result.pos_assigned_gt_inds - pos_gt_bboxes = sampling_result.pos_gt_bboxes - - # label targets - labels = gt_bboxes.new_full((num_bboxes,), self.num_classes, dtype=torch.long) - labels[pos_inds] = gt_labels[pos_assigned_gt_inds] - label_weights = gt_bboxes.new_ones(num_bboxes) - - # bbox targets - bbox_targets = torch.zeros_like(bbox_pred)[..., :gt_c] - bbox_weights = torch.zeros_like(bbox_pred) - bbox_weights[pos_inds] = 1.0 - - if order_index is None: - assigned_shift = gt_labels[pos_assigned_gt_inds] - else: - assigned_shift = order_index[pos_inds, pos_assigned_gt_inds] - pts_targets = pts_pred.new_zeros((pts_pred.size(0), - pts_pred.size(1), pts_pred.size(2))) - pts_weights = torch.zeros_like(pts_targets) - pts_weights[pos_inds] = 1.0 - - # DETR - bbox_targets[pos_inds] = pos_gt_bboxes - pts_targets[pos_inds] = gt_shifts_pts[pos_assigned_gt_inds, assigned_shift,:,:] - return labels, label_weights, bbox_targets, bbox_weights, pts_targets, pts_weights, pos_inds, neg_inds - - def _get_target_single(self, - cls_score, - bbox_pred, - pts_pred, - gt_labels, - gt_bboxes, - gt_shifts_pts, - gt_bboxes_ignore=None): - """"Compute regression and classification targets for one image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_score (Tensor): Box score logits from a single decoder layer - for one image. Shape [num_query, cls_out_channels]. - bbox_pred (Tensor): Sigmoid outputs from a single decoder layer - for one image, with normalized coordinate (cx, cy, w, h) and - shape [num_query, 4]. - gt_bboxes (Tensor): Ground truth bboxes for one image with - shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels (Tensor): Ground truth class indices for one image - with shape (num_gts, ). - gt_bboxes_ignore (Tensor, optional): Bounding boxes - which can be ignored. Default None. - Returns: - tuple[Tensor]: a tuple containing the following for one image. - - labels (Tensor): Labels of each image. - - label_weights (Tensor]): Label weights of each image. - - bbox_targets (Tensor): BBox targets of each image. - - bbox_weights (Tensor): BBox weights of each image. - - pos_inds (Tensor): Sampled positive indices for each image. - - neg_inds (Tensor): Sampled negative indices for each image. - """ - # num_bboxes = bbox_pred.size(0) - # # assigner and sampler - # gt_c = gt_bboxes.shape[-1] - assign_result, order_index = self.assigner.assign(bbox_pred, cls_score, pts_pred, gt_bboxes, gt_labels, gt_shifts_pts, gt_bboxes_ignore) - - sampling_result = self.sampler.sample(assign_result, bbox_pred, gt_bboxes[0]) - labels, label_weights, bbox_targets, bbox_weights, pts_targets, pts_weights, pos_inds, neg_inds = self.get_label_result(sampling_result, gt_bboxes[0], gt_labels[0], bbox_pred, order_index, pts_pred, gt_shifts_pts[0]) - - # sampling_result = self.sampler.sample(assign_result, bbox_pred, gt_bboxes) - # labels, label_weights, bbox_targets, bbox_weights, pts_targets, pts_weights, pos_inds, neg_inds = self.get_label_result(sampling_result, gt_bboxes, gt_labels, bbox_pred, order_index, pts_pred, gt_shifts_pts) - - - return (labels, label_weights, bbox_targets, bbox_weights, - pts_targets, pts_weights, - pos_inds, neg_inds) - - def get_targets(self, - cls_scores_list, - bbox_preds_list, - pts_preds_list, - gt_bboxes_list, - gt_labels_list, - gt_shifts_pts_list, - gt_bboxes_ignore_list=None): - """"Compute regression and classification targets for a batch image. - Outputs from a single decoder layer of a single feature level are used. - Args: - cls_scores_list (list[Tensor]): Box score logits from a single - decoder layer for each image with shape [num_query, - cls_out_channels]. - bbox_preds_list (list[Tensor]): Sigmoid outputs from a single - decoder layer for each image, with normalized coordinate - (cx, cy, w, h) and shape [num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - tuple: a tuple containing the following targets. - - labels_list (list[Tensor]): Labels for all images. - - label_weights_list (list[Tensor]): Label weights for all \ - images. - - bbox_targets_list (list[Tensor]): BBox targets for all \ - images. - - bbox_weights_list (list[Tensor]): BBox weights for all \ - images. - - num_total_pos (int): Number of positive samples in all \ - images. - - num_total_neg (int): Number of negative samples in all \ - images. - """ - assert gt_bboxes_ignore_list is None, \ - 'Only supports for gt_bboxes_ignore setting to None.' - num_imgs = len(cls_scores_list) - gt_bboxes_ignore_list = [gt_bboxes_ignore_list for _ in range(num_imgs)] - - (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pts_targets_list, pts_weights_list, - pos_inds_list, neg_inds_list) = multi_apply( - self._get_target_single, cls_scores_list, bbox_preds_list,pts_preds_list, - gt_labels_list, gt_bboxes_list, gt_shifts_pts_list, gt_bboxes_ignore_list) - num_total_pos = sum((inds.numel() for inds in pos_inds_list)) - num_total_neg = sum((inds.numel() for inds in neg_inds_list)) - return (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, pts_targets_list, pts_weights_list, - num_total_pos, num_total_neg) - - def loss_single(self, - cls_scores, - bbox_preds, - pts_preds, - gt_bboxes_list, - gt_labels_list, - gt_shifts_pts_list, - gt_bboxes_ignore_list=None): - """"Loss function for outputs from a single decoder layer of a single - feature level. - Args: - cls_scores (Tensor): Box score logits from a single decoder layer - for all images. Shape [bs, num_query, cls_out_channels]. - bbox_preds (Tensor): Sigmoid outputs from a single decoder layer - for all images, with normalized coordinate (cx, cy, w, h) and - shape [bs, num_query, 4]. - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - gt_pts_list (list[Tensor]): Ground truth pts for each image - with shape (num_gts, fixed_num, 2) in [x,y] format. - gt_bboxes_ignore_list (list[Tensor], optional): Bounding - boxes which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components for outputs from - a single decoder layer. - """ - num_imgs = cls_scores.size(0) - cls_scores_list = [cls_scores[i] for i in range(num_imgs)] - bbox_preds_list = [bbox_preds[i] for i in range(num_imgs)] - pts_preds_list = [pts_preds[i] for i in range(num_imgs)] - # import pdb;pdb.set_trace() - cls_reg_targets = self.get_targets(cls_scores_list, bbox_preds_list, pts_preds_list, - gt_bboxes_list, gt_labels_list, gt_shifts_pts_list, - gt_bboxes_ignore_list) - - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - pts_targets_list, pts_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - # import pdb;pdb.set_trace() - labels = torch.cat(labels_list, 0) - label_weights = torch.cat(label_weights_list, 0) - bbox_targets = torch.cat(bbox_targets_list, 0) - bbox_weights = torch.cat(bbox_weights_list, 0) - pts_targets = torch.cat(pts_targets_list, 0) - pts_weights = torch.cat(pts_weights_list, 0) - - # classification loss - cls_scores = cls_scores.reshape(-1, self.cls_out_channels) - # construct weighted avg_factor to match with the official DETR repo - cls_avg_factor = num_total_pos * 1.0 + \ - num_total_neg * self.bg_cls_weight - if self.sync_cls_avg_factor: - cls_avg_factor = reduce_mean( - cls_scores.new_tensor([cls_avg_factor])) - - cls_avg_factor = max(cls_avg_factor, 1) - loss_cls = self.loss_cls( - cls_scores, labels, label_weights, avg_factor=cls_avg_factor) - - # Compute the average number of gt boxes accross all gpus, for - # normalization purposes - num_total_pos = loss_cls.new_tensor([num_total_pos]) - num_total_pos = torch.clamp(reduce_mean(num_total_pos), min=1).item() - - # import pdb;pdb.set_trace() - # regression L1 loss - bbox_preds = bbox_preds.reshape(-1, bbox_preds.size(-1)) - normalized_bbox_targets = normalize_2d_bbox(bbox_targets, self.pc_range) - # normalized_bbox_targets = bbox_targets - isnotnan = torch.isfinite(normalized_bbox_targets).all(dim=-1) - bbox_weights = bbox_weights * self.code_weights - - loss_bbox = self.loss_bbox( - bbox_preds[isnotnan, :4], normalized_bbox_targets[isnotnan, - :4], bbox_weights[isnotnan, :4], - avg_factor=num_total_pos) - - # regression pts CD loss - # pts_preds = pts_preds - # import pdb;pdb.set_trace() - - # num_samples, num_order, num_pts, num_coords - normalized_pts_targets = normalize_2d_pts(pts_targets, self.pc_range) if not self.z_cfg['gt_z_flag'] \ - else normalize_3d_pts(pts_targets, self.pc_range) - - # num_samples, num_pts, num_coords - pts_preds = pts_preds.reshape(-1, pts_preds.size(-2),pts_preds.size(-1)) - if self.num_pts_per_vec != self.num_pts_per_gt_vec: - pts_preds = pts_preds.permute(0,2,1) - pts_preds = F.interpolate(pts_preds, size=(self.num_pts_per_gt_vec), mode='linear', - align_corners=True) - pts_preds = pts_preds.permute(0,2,1).contiguous() - - # import pdb;pdb.set_trace() - loss_pts = self.loss_pts( - pts_preds[isnotnan,:,:], normalized_pts_targets[isnotnan, - :,:], - pts_weights[isnotnan,:,:], - avg_factor=num_total_pos) - dir_weights = pts_weights[:, :-self.dir_interval,0] - denormed_pts_preds = denormalize_2d_pts(pts_preds, self.pc_range) if not self.z_cfg['gt_z_flag'] \ - else denormalize_3d_pts(pts_preds, self.pc_range) - denormed_pts_preds_dir = denormed_pts_preds[:,self.dir_interval:,:] - denormed_pts_preds[:,:-self.dir_interval,:] - pts_targets_dir = pts_targets[:, self.dir_interval:,:] - pts_targets[:,:-self.dir_interval,:] - # dir_weights = pts_weights[:, indice,:-1,0] - # import pdb;pdb.set_trace() - loss_dir = self.loss_dir( - denormed_pts_preds_dir[isnotnan,:,:], pts_targets_dir[isnotnan, - :,:], - dir_weights[isnotnan,:], - avg_factor=num_total_pos) - - bboxes = denormalize_2d_bbox(bbox_preds, self.pc_range) - # regression IoU loss, defaultly GIoU loss - loss_iou = self.loss_iou( - bboxes[isnotnan, :4], bbox_targets[isnotnan, :4], bbox_weights[isnotnan, :4], - avg_factor=num_total_pos) - - if digit_version(TORCH_VERSION) >= digit_version('1.8'): - loss_cls = torch.nan_to_num(loss_cls) - loss_bbox = torch.nan_to_num(loss_bbox) - loss_iou = torch.nan_to_num(loss_iou) - loss_pts = torch.nan_to_num(loss_pts) - loss_dir = torch.nan_to_num(loss_dir) - - return loss_cls, loss_bbox, loss_iou, loss_pts, loss_dir - - import torch - - def pad_to_static_list(self, tensors, pad_value=0, device=None): - - # max_len = max(t.size(0) for t in tensors) - max_len = 200 - - results = [] - for t in tensors: - pad_shape = (max_len,) + t.shape[1:] - out = torch.full(pad_shape, pad_value, device=device, dtype=t.dtype) - mask = torch.zeros(max_len, dtype=torch.bool, device=device) - - length = t.size(0) - out[:length, ...] = t - mask[:length] = 1 - - results.append((out, mask, length)) - - return results - - @force_fp32(apply_to=('preds_dicts')) - def loss(self, - gt_bboxes_list, - gt_labels_list, - gt_seg_mask, - gt_pv_seg_mask, - preds_dicts, - gt_bboxes_ignore=None, - img_metas=None): - """"Loss function. - Args: - - gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image - with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. - gt_labels_list (list[Tensor]): Ground truth class indices for each - image with shape (num_gts, ). - preds_dicts: - all_cls_scores (Tensor): Classification score of all - decoder layers, has shape - [nb_dec, bs, num_query, cls_out_channels]. - all_bbox_preds (Tensor): Sigmoid regression - outputs of all decode layers. Each is a 4D-tensor with - normalized coordinate format (cx, cy, w, h) and shape - [nb_dec, bs, num_query, 4]. - enc_cls_scores (Tensor): Classification scores of - points on encode feature map , has shape - (N, h*w, num_classes). Only be passed when as_two_stage is - True, otherwise is None. - enc_bbox_preds (Tensor): Regression results of each points - on the encode feature map, has shape (N, h*w, 4). Only be - passed when as_two_stage is True, otherwise is None. - gt_bboxes_ignore (list[Tensor], optional): Bounding boxes - which can be ignored for each image. Default None. - Returns: - dict[str, Tensor]: A dictionary of loss components. - """ - assert gt_bboxes_ignore is None, \ - f'{self.__class__.__name__} only supports ' \ - f'for gt_bboxes_ignore setting to None.' - gt_vecs_list = copy.deepcopy(gt_bboxes_list) - all_cls_scores = preds_dicts['all_cls_scores'] - all_bbox_preds = preds_dicts['all_bbox_preds'] - all_pts_preds = preds_dicts['all_pts_preds'] - enc_cls_scores = preds_dicts['enc_cls_scores'] - enc_bbox_preds = preds_dicts['enc_bbox_preds'] - enc_pts_preds = preds_dicts['enc_pts_preds'] - - num_dec_layers = len(all_cls_scores) - device = gt_labels_list[0].device - - gt_bboxes_list = [gt_bboxes.bbox.to(device) for gt_bboxes in gt_vecs_list] - # gt_pts_list = [gt_bboxes.fixed_num_sampled_points.to(device) for gt_bboxes in gt_vecs_list] - - # if self.gt_shift_pts_pattern == 'v0': - # gt_shifts_pts_list = [ - # gt_bboxes.shift_fixed_num_sampled_points.to(device) for gt_bboxes in gt_vecs_list] - # elif self.gt_shift_pts_pattern == 'v1': - # gt_shifts_pts_list = [ - # gt_bboxes.shift_fixed_num_sampled_points_v1.to(device) for gt_bboxes in gt_vecs_list] - # elif self.gt_shift_pts_pattern == 'v2': - # gt_shifts_pts_list = [ - # gt_bboxes.shift_fixed_num_sampled_points_v2.to(device) for gt_bboxes in gt_vecs_list] - # elif self.gt_shift_pts_pattern == 'v3': - # gt_shifts_pts_list = [ - # gt_bboxes.shift_fixed_num_sampled_points_v3.to(device) for gt_bboxes in gt_vecs_list] - # elif self.gt_shift_pts_pattern == 'v4': - # gt_shifts_pts_list = [ - # gt_bboxes.shift_fixed_num_sampled_points_v4.to(device) for gt_bboxes in gt_vecs_list] - # else: - # raise NotImplementedError - - # all_gt_bboxes_list = [gt_bboxes_list for _ in range(num_dec_layers)] - # all_gt_labels_list = [gt_labels_list for _ in range(num_dec_layers)] - # all_gt_shifts_pts_list = [gt_shifts_pts_list for _ in range(num_dec_layers)] - # all_gt_bboxes_ignore_list = [gt_bboxes_ignore for _ in range(num_dec_layers)] - # # all_gt_pts_list = [gt_pts_list for _ in range(num_dec_layers)] - - if self.gt_shift_pts_pattern == 'v0': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v1': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v1 for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v2': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v2 for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v3': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v3 for gt_bboxes in gt_vecs_list] - elif self.gt_shift_pts_pattern == 'v4': - gt_shifts_pts_list = [ - gt_bboxes.shift_fixed_num_sampled_points_v4 for gt_bboxes in gt_vecs_list] - else: - raise NotImplementedError - - all_gt_bboxes = self.pad_to_static_list(gt_bboxes_list, device=device) - all_shifts_pts = self.pad_to_static_list(gt_shifts_pts_list, device=device) - all_gt_labels = self.pad_to_static_list(gt_labels_list, device=device) - - all_gt_bboxes_list = [all_gt_bboxes for _ in range(num_dec_layers)] - all_gt_shifts_pts_list = [all_shifts_pts for _ in range(num_dec_layers)] - all_gt_labels_list = [all_gt_labels for _ in range(num_dec_layers)] - all_gt_bboxes_ignore_list = [gt_bboxes_ignore for _ in range(num_dec_layers)] - # all_gt_pts_list = [gt_pts_list for _ in range(num_dec_layers)] - - losses_cls, losses_bbox, losses_iou, losses_pts, losses_dir = multi_apply( - self.loss_single, all_cls_scores, all_bbox_preds, all_pts_preds, - all_gt_bboxes_list, all_gt_labels_list, all_gt_shifts_pts_list, - all_gt_bboxes_ignore_list) - - loss_dict = dict() - if self.aux_seg['use_aux_seg']: - # import ipdb;ipdb.set_trace() - if self.aux_seg['bev_seg']: - if preds_dicts['seg'] is not None: - seg_output = preds_dicts['seg'] - num_imgs = seg_output.size(0) - seg_gt = torch.stack([gt_seg_mask[i] for i in range(num_imgs)],dim=0) - loss_seg = self.loss_seg(seg_output, seg_gt.float()) - loss_dict['loss_seg'] = loss_seg - if self.aux_seg['pv_seg']: - # import ipdb;ipdb.set_trace() - if preds_dicts['pv_seg'] is not None: - pv_seg_output = preds_dicts['pv_seg'] - num_imgs = pv_seg_output.size(0) - pv_seg_gt = torch.stack([gt_pv_seg_mask[i] for i in range(num_imgs)],dim=0) - loss_pv_seg = self.loss_pv_seg(pv_seg_output, pv_seg_gt.float()) - loss_dict['loss_pv_seg'] = loss_pv_seg - # loss of proposal generated from encode feature map. - if enc_cls_scores is not None: - binary_labels_list = [ - torch.zeros_like(gt_labels_list[i]) - for i in range(len(all_gt_labels_list)) - ] - # TODO bug here - enc_loss_cls, enc_losses_bbox, enc_losses_iou, enc_losses_pts, enc_losses_dir = \ - self.loss_single(enc_cls_scores, enc_bbox_preds, enc_pts_preds, - gt_bboxes_list, binary_labels_list, gt_pts_list,gt_bboxes_ignore) - loss_dict['enc_loss_cls'] = enc_loss_cls - loss_dict['enc_loss_bbox'] = enc_losses_bbox - loss_dict['enc_losses_iou'] = enc_losses_iou - loss_dict['enc_losses_pts'] = enc_losses_pts - loss_dict['enc_losses_dir'] = enc_losses_dir - - # loss from the last decoder layer - loss_dict['loss_cls'] = losses_cls[-1] - loss_dict['loss_bbox'] = losses_bbox[-1] - loss_dict['loss_iou'] = losses_iou[-1] - loss_dict['loss_pts'] = losses_pts[-1] - loss_dict['loss_dir'] = losses_dir[-1] - # loss from other decoder layers - num_dec_layer = 0 - for loss_cls_i, loss_bbox_i, loss_iou_i, loss_pts_i, loss_dir_i in zip(losses_cls[:-1], - losses_bbox[:-1], - losses_iou[:-1], - losses_pts[:-1], - losses_dir[:-1]): - loss_dict[f'd{num_dec_layer}.loss_cls'] = loss_cls_i - loss_dict[f'd{num_dec_layer}.loss_bbox'] = loss_bbox_i - loss_dict[f'd{num_dec_layer}.loss_iou'] = loss_iou_i - loss_dict[f'd{num_dec_layer}.loss_pts'] = loss_pts_i - loss_dict[f'd{num_dec_layer}.loss_dir'] = loss_dir_i - num_dec_layer += 1 - return loss_dict - - @force_fp32(apply_to=('preds_dicts')) - def get_bboxes(self, preds_dicts, img_metas, rescale=False): - """Generate bboxes from bbox head predictions. - Args: - preds_dicts (tuple[list[dict]]): Prediction results. - img_metas (list[dict]): Point cloud and image's meta info. - Returns: - list[dict]: Decoded bbox, scores and labels after nms. - """ - # bboxes: xmin, ymin, xmax, ymax - preds_dicts = self.bbox_coder.decode(preds_dicts) - - num_samples = len(preds_dicts) - ret_list = [] - for i in range(num_samples): - preds = preds_dicts[i] - bboxes = preds['bboxes'] - # bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5 - - # code_size = bboxes.shape[-1] - # bboxes = img_metas[i]['box_type_3d'](bboxes, code_size) - scores = preds['scores'] - labels = preds['labels'] - pts = preds['pts'] - - ret_list.append([bboxes, scores, labels, pts]) - - return ret_list - - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/__init__.py deleted file mode 100644 index 61348770365bbd61337f8263347a120262af71ab..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .maptr import MapTR -from .maptrv2 import MapTRv2 \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptr.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptr.py deleted file mode 100644 index 74b4325a79b974f32b9982a7f25d98587c4e3e72..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptr.py +++ /dev/null @@ -1,442 +0,0 @@ -import copy -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask -from mmcv.runner import force_fp32, auto_fp16 -from mmdet3d.ops import Voxelization, DynamicScatter -from mmdet3d.models import builder -@DETECTORS.register_module() -class MapTR(MVXTwoStageDetector): - """MapTR. - Args: - video_test_mode (bool): Decide whether to use temporal information during inference. - """ - - def __init__(self, - use_grid_mask=False, - pts_voxel_layer=None, - pts_voxel_encoder=None, - pts_middle_encoder=None, - pts_fusion_layer=None, - img_backbone=None, - pts_backbone=None, - img_neck=None, - pts_neck=None, - pts_bbox_head=None, - img_roi_head=None, - img_rpn_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None, - video_test_mode=False, - modality='vision', - lidar_encoder=None, - ): - - super(MapTR, - self).__init__(pts_voxel_layer, pts_voxel_encoder, - pts_middle_encoder, pts_fusion_layer, - img_backbone, pts_backbone, img_neck, pts_neck, - pts_bbox_head, img_roi_head, img_rpn_head, - train_cfg, test_cfg, pretrained) - self.grid_mask = GridMask( - True, True, rotate=1, offset=False, ratio=0.5, mode=1, prob=0.7) - self.use_grid_mask = use_grid_mask - self.fp16_enabled = False - - # temporal - self.video_test_mode = video_test_mode - self.prev_frame_info = { - 'prev_bev': None, - 'scene_token': None, - 'prev_pos': 0, - 'prev_angle': 0, - } - self.modality = modality - if self.modality == 'fusion' and lidar_encoder is not None : - if lidar_encoder["voxelize"].get("max_num_points", -1) > 0: - voxelize_module = Voxelization(**lidar_encoder["voxelize"]) - else: - voxelize_module = DynamicScatter(**lidar_encoder["voxelize"]) - self.lidar_modal_extractor = nn.ModuleDict( - { - "voxelize": voxelize_module, - "backbone": builder.build_middle_encoder(lidar_encoder["backbone"]), - } - ) - self.voxelize_reduce = lidar_encoder.get("voxelize_reduce", True) - - - def extract_img_feat(self, img, img_metas, len_queue=None): - """Extract features of images.""" - B = img.size(0) - if img is not None: - - # input_shape = img.shape[-2:] - # # update real input shape of each single img - # for img_meta in img_metas: - # img_meta.update(input_shape=input_shape) - - if img.dim() == 5 and img.size(0) == 1: - img.squeeze_() - elif img.dim() == 5 and img.size(0) > 1: - B, N, C, H, W = img.size() - img = img.reshape(B * N, C, H, W) - if self.use_grid_mask: - img = self.grid_mask(img) - - img_feats = self.img_backbone(img) - if isinstance(img_feats, dict): - img_feats = list(img_feats.values()) - else: - return None - if self.with_img_neck: - img_feats = self.img_neck(img_feats) - - img_feats_reshaped = [] - for img_feat in img_feats: - BN, C, H, W = img_feat.size() - if len_queue is not None: - img_feats_reshaped.append(img_feat.view(int(B/len_queue), len_queue, int(BN / B), C, H, W)) - else: - img_feats_reshaped.append(img_feat.view(B, int(BN / B), C, H, W)) - return img_feats_reshaped - - @auto_fp16(apply_to=('img'), out_fp32=True) - def extract_feat(self, img, img_metas=None, len_queue=None): - """Extract features from images and points.""" - - img_feats = self.extract_img_feat(img, img_metas, len_queue=len_queue) - - return img_feats - - - def forward_pts_train(self, - pts_feats, - lidar_feat, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None, - prev_bev=None): - """Forward function' - Args: - pts_feats (list[torch.Tensor]): Features of point cloud branch - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`]): Ground truth - boxes for each sample. - gt_labels_3d (list[torch.Tensor]): Ground truth labels for - boxes of each sampole - img_metas (list[dict]): Meta information of samples. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - boxes to be ignored. Defaults to None. - prev_bev (torch.Tensor, optional): BEV features of previous frame. - Returns: - dict: Losses of each branch. - """ - - outs = self.pts_bbox_head( - pts_feats, lidar_feat, img_metas, prev_bev) - loss_inputs = [gt_bboxes_3d, gt_labels_3d, outs] - losses = self.pts_bbox_head.loss(*loss_inputs, img_metas=img_metas) - return losses - - def forward_dummy(self, img): - dummy_metas = None - return self.forward_test(img=img, img_metas=[[dummy_metas]]) - - def forward(self, return_loss=True, **kwargs): - """Calls either forward_train or forward_test depending on whether - return_loss=True. - Note this setting will change the expected inputs. When - `return_loss=True`, img and img_metas are single-nested (i.e. - torch.Tensor and list[dict]), and when `resturn_loss=False`, img and - img_metas should be double nested (i.e. list[torch.Tensor], - list[list[dict]]), with the outer list indicating test time - augmentations. - """ - if return_loss: - return self.forward_train(**kwargs) - else: - return self.forward_test(**kwargs) - - def obtain_history_bev(self, imgs_queue, img_metas_list): - """Obtain history BEV features iteratively. To save GPU memory, gradients are not calculated. - """ - self.eval() - - with torch.no_grad(): - prev_bev = None - bs, len_queue, num_cams, C, H, W = imgs_queue.shape - imgs_queue = imgs_queue.reshape(bs*len_queue, num_cams, C, H, W) - img_feats_list = self.extract_feat(img=imgs_queue, len_queue=len_queue) - for i in range(len_queue): - img_metas = [each[i] for each in img_metas_list] - # img_feats = self.extract_feat(img=img, img_metas=img_metas) - img_feats = [each_scale[:, i] for each_scale in img_feats_list] - prev_bev = self.pts_bbox_head( - img_feats, img_metas, prev_bev, only_bev=True) - self.train() - return prev_bev - - @torch.no_grad() - @force_fp32() - def voxelize(self, points): - feats, coords, sizes = [], [], [] - for k, res in enumerate(points): - ret = self.lidar_modal_extractor["voxelize"](res) - if len(ret) == 3: - # hard voxelize - f, c, n = ret - else: - assert len(ret) == 2 - f, c = ret - n = None - feats.append(f) - coords.append(F.pad(c, (1, 0), mode="constant", value=k)) - if n is not None: - sizes.append(n) - - feats = torch.cat(feats, dim=0) - coords = torch.cat(coords, dim=0) - if len(sizes) > 0: - sizes = torch.cat(sizes, dim=0) - if self.voxelize_reduce: - feats = feats.sum(dim=1, keepdim=False) / sizes.type_as(feats).view( - -1, 1 - ) - feats = feats.contiguous() - - return feats, coords, sizes - @auto_fp16(apply_to=('points'), out_fp32=True) - def extract_lidar_feat(self,points): - feats, coords, sizes = self.voxelize(points) - # voxel_features = self.lidar_modal_extractor["voxel_encoder"](feats, sizes, coords) - batch_size = coords[-1, 0] + 1 - lidar_feat = self.lidar_modal_extractor["backbone"](feats, coords, batch_size, sizes=sizes) - - return lidar_feat - - # @auto_fp16(apply_to=('img', 'points')) - @force_fp32(apply_to=('img','points','prev_bev')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - lidar_feat = None - if self.modality == 'fusion': - lidar_feat = self.extract_lidar_feat(points) - - len_queue = img.size(1) - prev_img = img[:, :-1, ...] - img = img[:, -1, ...] - - prev_img_metas = copy.deepcopy(img_metas) - # prev_bev = self.obtain_history_bev(prev_img, prev_img_metas) - # import pdb;pdb.set_trace() - prev_bev = self.obtain_history_bev(prev_img, prev_img_metas) if len_queue>1 else None - - img_metas = [each[len_queue-1] for each in img_metas] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - losses = dict() - losses_pts = self.forward_pts_train(img_feats, lidar_feat, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev) - - losses.update(losses_pts) - return losses - - def forward_test(self, img_metas, img=None,points=None, **kwargs): - for var, name in [(img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - img = [img] if img is None else img - points = [points] if points is None else points - if img_metas[0][0]['scene_token'] != self.prev_frame_info['scene_token']: - # the first sample of each scene is truncated - self.prev_frame_info['prev_bev'] = None - # update idx - self.prev_frame_info['scene_token'] = img_metas[0][0]['scene_token'] - - # do not use temporal information - if not self.video_test_mode: - self.prev_frame_info['prev_bev'] = None - - # Get the delta of ego position and angle between two timestamps. - tmp_pos = copy.deepcopy(img_metas[0][0]['can_bus'][:3]) - tmp_angle = copy.deepcopy(img_metas[0][0]['can_bus'][-1]) - if self.prev_frame_info['prev_bev'] is not None: - img_metas[0][0]['can_bus'][:3] -= self.prev_frame_info['prev_pos'] - img_metas[0][0]['can_bus'][-1] -= self.prev_frame_info['prev_angle'] - else: - img_metas[0][0]['can_bus'][-1] = 0 - img_metas[0][0]['can_bus'][:3] = 0 - - new_prev_bev, bbox_results = self.simple_test( - img_metas[0], img[0], points[0], prev_bev=self.prev_frame_info['prev_bev'], **kwargs) - # During inference, we save the BEV features and ego motion of each timestamp. - self.prev_frame_info['prev_pos'] = tmp_pos - self.prev_frame_info['prev_angle'] = tmp_angle - self.prev_frame_info['prev_bev'] = new_prev_bev - return bbox_results - - def pred2result(self, bboxes, scores, labels, pts, attrs=None): - """Convert detection results to a list of numpy arrays. - - Args: - bboxes (torch.Tensor): Bounding boxes with shape of (n, 5). - labels (torch.Tensor): Labels with shape of (n, ). - scores (torch.Tensor): Scores with shape of (n, ). - attrs (torch.Tensor, optional): Attributes with shape of (n, ). \ - Defaults to None. - - Returns: - dict[str, torch.Tensor]: Bounding box results in cpu mode. - - - boxes_3d (torch.Tensor): 3D boxes. - - scores (torch.Tensor): Prediction scores. - - labels_3d (torch.Tensor): Box labels. - - attrs_3d (torch.Tensor, optional): Box attributes. - """ - result_dict = dict( - boxes_3d=bboxes.to('cpu'), - scores_3d=scores.cpu(), - labels_3d=labels.cpu(), - pts_3d=pts.to('cpu')) - - if attrs is not None: - result_dict['attrs_3d'] = attrs.cpu() - - return result_dict - def simple_test_pts(self, x, lidar_feat, img_metas, prev_bev=None, rescale=False): - """Test function""" - outs = self.pts_bbox_head(x, lidar_feat, img_metas, prev_bev=prev_bev) - - bbox_list = self.pts_bbox_head.get_bboxes( - outs, img_metas, rescale=rescale) - - bbox_results = [ - self.pred2result(bboxes, scores, labels, pts) - for bboxes, scores, labels, pts in bbox_list - ] - # import pdb;pdb.set_trace() - return outs['bev_embed'], bbox_results - def simple_test(self, img_metas, img=None, points=None, prev_bev=None, rescale=False, **kwargs): - """Test function without augmentaiton.""" - lidar_feat = None - if self.modality =='fusion': - lidar_feat = self.extract_lidar_feat(points) - img_feats = self.extract_feat(img=img, img_metas=img_metas) - - bbox_list = [dict() for i in range(len(img_metas))] - new_prev_bev, bbox_pts = self.simple_test_pts( - img_feats, lidar_feat, img_metas, prev_bev, rescale=rescale) - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return new_prev_bev, bbox_list - - -@DETECTORS.register_module() -class MapTR_fp16(MapTR): - """ - The default version BEVFormer currently can not support FP16. - We provide this version to resolve this issue. - """ - # @auto_fp16(apply_to=('img', 'prev_bev', 'points')) - @force_fp32(apply_to=('img','points','prev_bev')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - prev_bev=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - - img_feats = self.extract_feat(img=img, img_metas=img_metas) - # import pdb;pdb.set_trace() - losses = dict() - losses_pts = self.forward_pts_train(img_feats, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev=prev_bev) - losses.update(losses_pts) - return losses - - - def val_step(self, data, optimizer): - """ - In BEVFormer_fp16, we use this `val_step` function to inference the `prev_pev`. - This is not the standard function of `val_step`. - """ - - img = data['img'] - img_metas = data['img_metas'] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - prev_bev = data.get('prev_bev', None) - prev_bev = self.pts_bbox_head(img_feats, img_metas, prev_bev=prev_bev, only_bev=True) - return prev_bev diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptrv2.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptrv2.py deleted file mode 100644 index fe71589d7327234bd70c3235270a780e155070c6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/detectors/maptrv2.py +++ /dev/null @@ -1,411 +0,0 @@ -import copy -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmdet.models import DETECTORS -from mmdet3d.core import bbox3d2result -from mmdet3d.models.detectors.mvx_two_stage import MVXTwoStageDetector -from projects.mmdet3d_plugin.models.utils.grid_mask import GridMask -from mmcv.runner import force_fp32, auto_fp16 -from mmdet3d.ops import Voxelization, DynamicScatter -from mmdet3d.models import builder -from mmcv.utils import TORCH_VERSION, digit_version -@DETECTORS.register_module() -class MapTRv2(MVXTwoStageDetector): - """MapTR. - Args: - video_test_mode (bool): Decide whether to use temporal information during inference. - """ - - def __init__(self, - use_grid_mask=False, - pts_voxel_layer=None, - pts_voxel_encoder=None, - pts_middle_encoder=None, - pts_fusion_layer=None, - img_backbone=None, - pts_backbone=None, - img_neck=None, - pts_neck=None, - pts_bbox_head=None, - img_roi_head=None, - img_rpn_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None, - video_test_mode=False, - modality='vision', - lidar_encoder=None, - ): - - super(MapTRv2, - self).__init__(pts_voxel_layer, pts_voxel_encoder, - pts_middle_encoder, pts_fusion_layer, - img_backbone, pts_backbone, img_neck, pts_neck, - pts_bbox_head, img_roi_head, img_rpn_head, - train_cfg, test_cfg, pretrained) - self.grid_mask = GridMask( - True, True, rotate=1, offset=False, ratio=0.5, mode=1, prob=0.7) - self.use_grid_mask = use_grid_mask - self.fp16_enabled = False - - # temporal - self.video_test_mode = video_test_mode - self.prev_frame_info = { - 'prev_bev': None, - 'scene_token': None, - 'prev_pos': 0, - 'prev_angle': 0, - } - self.modality = modality - if self.modality == 'fusion' and lidar_encoder is not None : - if lidar_encoder["voxelize"].get("max_num_points", -1) > 0: - voxelize_module = Voxelization(**lidar_encoder["voxelize"]) - else: - voxelize_module = DynamicScatter(**lidar_encoder["voxelize"]) - self.lidar_modal_extractor = nn.ModuleDict( - { - "voxelize": voxelize_module, - "backbone": builder.build_middle_encoder(lidar_encoder["backbone"]), - } - ) - self.voxelize_reduce = lidar_encoder.get("voxelize_reduce", True) - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def extract_img_feat(self, img, img_metas, len_queue=None): - """Extract features of images.""" - B = img.size(0) - if img is not None: - - # input_shape = img.shape[-2:] - # # update real input shape of each single img - # for img_meta in img_metas: - # img_meta.update(input_shape=input_shape) - - if img.dim() == 5 and img.size(0) == 1: - img.squeeze_() - elif img.dim() == 5 and img.size(0) > 1: - B, N, C, H, W = img.size() - img = img.reshape(B * N, C, H, W) - if self.use_grid_mask: - img = self.grid_mask(img) - - img_feats = self.img_backbone(img) - if isinstance(img_feats, dict): - img_feats = list(img_feats.values()) - else: - return None - if self.with_img_neck: - img_feats = self.img_neck(img_feats) - - img_feats_reshaped = [] - for img_feat in img_feats: - BN, C, H, W = img_feat.size() - if len_queue is not None: - img_feats_reshaped.append(img_feat.view(int(B/len_queue), len_queue, int(BN / B), C, H, W)) - else: - img_feats_reshaped.append(img_feat.view(B, int(BN / B), C, H, W)) - return img_feats_reshaped - - @auto_fp16(apply_to=('img'), out_fp32=True) - def extract_feat(self, img, img_metas=None, len_queue=None): - """Extract features from images and points.""" - - img_feats = self.extract_img_feat(img, img_metas, len_queue=len_queue) - - return img_feats - - - def forward_pts_train(self, - pts_feats, - lidar_feat, - gt_bboxes_3d, - gt_labels_3d, - img_metas, - gt_bboxes_ignore=None, - prev_bev=None, - gt_depth=None, - gt_seg_mask=None, - gt_pv_seg_mask=None,): - """Forward function' - Args: - pts_feats (list[torch.Tensor]): Features of point cloud branch - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`]): Ground truth - boxes for each sample. - gt_labels_3d (list[torch.Tensor]): Ground truth labels for - boxes of each sampole - img_metas (list[dict]): Meta information of samples. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - boxes to be ignored. Defaults to None. - prev_bev (torch.Tensor, optional): BEV features of previous frame. - Returns: - dict: Losses of each branch. - """ - - outs = self.pts_bbox_head( - pts_feats, lidar_feat, img_metas, prev_bev) - - depth = outs.pop('depth') - losses = dict() - # calculate depth loss - if gt_depth is not None: - loss_depth = self.pts_bbox_head.transformer.encoder.get_depth_loss(gt_depth, depth) - if digit_version(TORCH_VERSION) >= digit_version('1.8'): - loss_depth = torch.nan_to_num(loss_depth) - losses.update(loss_depth=loss_depth) - - loss_inputs = [gt_bboxes_3d, gt_labels_3d, gt_seg_mask, gt_pv_seg_mask, outs] - losses_pts = self.pts_bbox_head.loss(*loss_inputs, img_metas=img_metas) - losses.update(losses_pts) - # import ipdb;ipdb.set_trace() - k_one2many = self.pts_bbox_head.k_one2many - multi_gt_bboxes_3d = copy.deepcopy(gt_bboxes_3d) - multi_gt_labels_3d = copy.deepcopy(gt_labels_3d) - for i, (each_gt_bboxes_3d, each_gt_labels_3d) in enumerate(zip(multi_gt_bboxes_3d, multi_gt_labels_3d)): - each_gt_bboxes_3d.instance_list = each_gt_bboxes_3d.instance_list * k_one2many - each_gt_bboxes_3d.instance_labels = each_gt_bboxes_3d.instance_labels * k_one2many - multi_gt_labels_3d[i] = each_gt_labels_3d.repeat(k_one2many) - # import ipdb;ipdb.set_trace() - one2many_outs = outs['one2many_outs'] - loss_one2many_inputs = [multi_gt_bboxes_3d, multi_gt_labels_3d, gt_seg_mask, gt_pv_seg_mask, one2many_outs] - loss_dict_one2many = self.pts_bbox_head.loss(*loss_one2many_inputs, img_metas=img_metas) - - lambda_one2many = self.pts_bbox_head.lambda_one2many - for key, value in loss_dict_one2many.items(): - if key + "_one2many" in losses.keys(): - losses[key + "_one2many"] += value * lambda_one2many - else: - losses[key + "_one2many"] = value * lambda_one2many - # import ipdb;ipdb.set_trace() - return losses - - def forward_dummy(self, img): - dummy_metas = None - return self.forward_test(img=img, img_metas=[[dummy_metas]]) - - def forward(self, return_loss=True, **kwargs): - """Calls either forward_train or forward_test depending on whether - return_loss=True. - Note this setting will change the expected inputs. When - `return_loss=True`, img and img_metas are single-nested (i.e. - torch.Tensor and list[dict]), and when `resturn_loss=False`, img and - img_metas should be double nested (i.e. list[torch.Tensor], - list[list[dict]]), with the outer list indicating test time - augmentations. - """ - if return_loss: - return self.forward_train(**kwargs) - else: - return self.forward_test(**kwargs) - - def obtain_history_bev(self, imgs_queue, img_metas_list): - """Obtain history BEV features iteratively. To save GPU memory, gradients are not calculated. - """ - self.eval() - - with torch.no_grad(): - prev_bev = None - bs, len_queue, num_cams, C, H, W = imgs_queue.shape - imgs_queue = imgs_queue.reshape(bs*len_queue, num_cams, C, H, W) - img_feats_list = self.extract_feat(img=imgs_queue, len_queue=len_queue) - for i in range(len_queue): - img_metas = [each[i] for each in img_metas_list] - # img_feats = self.extract_feat(img=img, img_metas=img_metas) - img_feats = [each_scale[:, i] for each_scale in img_feats_list] - prev_bev = self.pts_bbox_head( - img_feats, img_metas, prev_bev, only_bev=True) - self.train() - return prev_bev - - @torch.no_grad() - @force_fp32() - def voxelize(self, points): - feats, coords, sizes = [], [], [] - for k, res in enumerate(points): - ret = self.lidar_modal_extractor["voxelize"](res) - if len(ret) == 3: - # hard voxelize - f, c, n = ret - else: - assert len(ret) == 2 - f, c = ret - n = None - feats.append(f) - coords.append(F.pad(c, (1, 0), mode="constant", value=k)) - if n is not None: - sizes.append(n) - - feats = torch.cat(feats, dim=0) - coords = torch.cat(coords, dim=0) - if len(sizes) > 0: - sizes = torch.cat(sizes, dim=0) - if self.voxelize_reduce: - feats = feats.sum(dim=1, keepdim=False) / sizes.type_as(feats).view( - -1, 1 - ) - feats = feats.contiguous() - - return feats, coords, sizes - @auto_fp16(apply_to=('points'), out_fp32=True) - def extract_lidar_feat(self,points): - feats, coords, sizes = self.voxelize(points) - # voxel_features = self.lidar_modal_extractor["voxel_encoder"](feats, sizes, coords) - batch_size = coords[-1, 0] + 1 - lidar_feat = self.lidar_modal_extractor["backbone"](feats, coords, batch_size, sizes=sizes) - - return lidar_feat - - # @auto_fp16(apply_to=('img', 'points')) - @force_fp32(apply_to=('img','points','prev_bev')) - def forward_train(self, - points=None, - img_metas=None, - gt_bboxes_3d=None, - gt_labels_3d=None, - gt_labels=None, - gt_bboxes=None, - img=None, - proposals=None, - gt_bboxes_ignore=None, - img_depth=None, - img_mask=None, - gt_depth=None, - gt_seg_mask=None, - gt_pv_seg_mask=None, - ): - """Forward training function. - Args: - points (list[torch.Tensor], optional): Points of each sample. - Defaults to None. - img_metas (list[dict], optional): Meta information of each sample. - Defaults to None. - gt_bboxes_3d (list[:obj:`BaseInstance3DBoxes`], optional): - Ground truth 3D boxes. Defaults to None. - gt_labels_3d (list[torch.Tensor], optional): Ground truth labels - of 3D boxes. Defaults to None. - gt_labels (list[torch.Tensor], optional): Ground truth labels - of 2D boxes in images. Defaults to None. - gt_bboxes (list[torch.Tensor], optional): Ground truth 2D boxes in - images. Defaults to None. - img (torch.Tensor optional): Images of each sample with shape - (N, C, H, W). Defaults to None. - proposals ([list[torch.Tensor], optional): Predicted proposals - used for training Fast RCNN. Defaults to None. - gt_bboxes_ignore (list[torch.Tensor], optional): Ground truth - 2D boxes in images to be ignored. Defaults to None. - Returns: - dict: Losses of different branches. - """ - lidar_feat = None - if self.modality == 'fusion': - lidar_feat = self.extract_lidar_feat(points) - - len_queue = img.size(1) - prev_img = img[:, :-1, ...] - img = img[:, -1, ...] - - prev_img_metas = copy.deepcopy(img_metas) - # prev_bev = self.obtain_history_bev(prev_img, prev_img_metas) - # import pdb;pdb.set_trace() - prev_bev = self.obtain_history_bev(prev_img, prev_img_metas) if len_queue>1 else None - - img_metas = [each[len_queue-1] for each in img_metas] - img_feats = self.extract_feat(img=img, img_metas=img_metas) - losses = dict() - losses_pts = self.forward_pts_train(img_feats, lidar_feat, gt_bboxes_3d, - gt_labels_3d, img_metas, - gt_bboxes_ignore, prev_bev, gt_depth,gt_seg_mask,gt_pv_seg_mask) - - losses.update(losses_pts) - return losses - - def forward_test(self, img_metas, img=None,points=None, **kwargs): - for var, name in [(img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - img = [img] if img is None else img - points = [points] if points is None else points - if img_metas[0][0]['scene_token'] != self.prev_frame_info['scene_token']: - # the first sample of each scene is truncated - self.prev_frame_info['prev_bev'] = None - # update idx - self.prev_frame_info['scene_token'] = img_metas[0][0]['scene_token'] - - # do not use temporal information - if not self.video_test_mode: - self.prev_frame_info['prev_bev'] = None - - # Get the delta of ego position and angle between two timestamps. - tmp_pos = copy.deepcopy(img_metas[0][0]['can_bus'][:3]) - tmp_angle = copy.deepcopy(img_metas[0][0]['can_bus'][-1]) - if self.prev_frame_info['prev_bev'] is not None: - img_metas[0][0]['can_bus'][:3] -= self.prev_frame_info['prev_pos'] - img_metas[0][0]['can_bus'][-1] -= self.prev_frame_info['prev_angle'] - else: - img_metas[0][0]['can_bus'][-1] = 0 - img_metas[0][0]['can_bus'][:3] = 0 - - new_prev_bev, bbox_results = self.simple_test( - img_metas[0], img[0], points[0], prev_bev=self.prev_frame_info['prev_bev'], **kwargs) - # During inference, we save the BEV features and ego motion of each timestamp. - self.prev_frame_info['prev_pos'] = tmp_pos - self.prev_frame_info['prev_angle'] = tmp_angle - self.prev_frame_info['prev_bev'] = new_prev_bev - return bbox_results - - def pred2result(self, bboxes, scores, labels, pts, attrs=None): - """Convert detection results to a list of numpy arrays. - - Args: - bboxes (torch.Tensor): Bounding boxes with shape of (n, 5). - labels (torch.Tensor): Labels with shape of (n, ). - scores (torch.Tensor): Scores with shape of (n, ). - attrs (torch.Tensor, optional): Attributes with shape of (n, ). \ - Defaults to None. - - Returns: - dict[str, torch.Tensor]: Bounding box results in cpu mode. - - - boxes_3d (torch.Tensor): 3D boxes. - - scores (torch.Tensor): Prediction scores. - - labels_3d (torch.Tensor): Box labels. - - attrs_3d (torch.Tensor, optional): Box attributes. - """ - result_dict = dict( - boxes_3d=bboxes.to('cpu'), - scores_3d=scores.cpu(), - labels_3d=labels.cpu(), - pts_3d=pts.to('cpu')) - - if attrs is not None: - result_dict['attrs_3d'] = attrs.cpu() - - return result_dict - def simple_test_pts(self, x, lidar_feat, img_metas, prev_bev=None, rescale=False): - """Test function""" - outs = self.pts_bbox_head(x, lidar_feat, img_metas, prev_bev=prev_bev) - - bbox_list = self.pts_bbox_head.get_bboxes( - outs, img_metas, rescale=rescale) - - bbox_results = [ - self.pred2result(bboxes, scores, labels, pts) - for bboxes, scores, labels, pts in bbox_list - ] - # import pdb;pdb.set_trace() - return outs['bev_embed'], bbox_results - def simple_test(self, img_metas, img=None, points=None, prev_bev=None, rescale=False, **kwargs): - """Test function without augmentaiton.""" - lidar_feat = None - if self.modality =='fusion': - lidar_feat = self.extract_lidar_feat(points) - img_feats = self.extract_feat(img=img, img_metas=img_metas) - - bbox_list = [dict() for i in range(len(img_metas))] - new_prev_bev, bbox_pts = self.simple_test_pts( - img_feats, lidar_feat, img_metas, prev_bev, rescale=rescale) - for result_dict, pts_bbox in zip(bbox_list, bbox_pts): - result_dict['pts_bbox'] = pts_bbox - return new_prev_bev, bbox_list - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/__init__.py deleted file mode 100644 index e79f523f5978aec1c1be86cd2b52253160c4c6d7..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .map_loss import MyChamferDistance -from .map_loss import MyChamferDistanceCost -from .map_loss import OrderedPtsL1Cost, PtsL1Cost -from .map_loss import OrderedPtsL1Loss, PtsL1Loss -from .map_loss import OrderedPtsSmoothL1Cost, OrderedPtsL1Loss -from .map_loss import PtsDirCosLoss -from .simple_loss import SimpleLoss \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/simple_loss.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/simple_loss.py deleted file mode 100644 index 4f3025525db02e15bad9aa7eb9c9af55bc89dcb5..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/losses/simple_loss.py +++ /dev/null @@ -1,115 +0,0 @@ -import torch -import torch.nn as nn -from mmdet.models.builder import LOSSES -import torch.nn.functional as F -from mmdet.models.losses import FocalLoss, weight_reduce_loss - -def py_sigmoid_focal_loss(pred, - target, - weight=None, - gamma=2.0, - alpha=0.25, - reduction='mean', - avg_factor=None): - """PyTorch version of `Focal Loss `_. - - Args: - pred (torch.Tensor): The prediction with shape (N, C), C is the - number of classes - target (torch.Tensor): The learning label of the prediction. - weight (torch.Tensor, optional): Sample-wise loss weight. - gamma (float, optional): The gamma for calculating the modulating - factor. Defaults to 2.0. - alpha (float, optional): A balanced form for Focal Loss. - Defaults to 0.25. - reduction (str, optional): The method used to reduce the loss into - a scalar. Defaults to 'mean'. - avg_factor (int, optional): Average factor that is used to average - the loss. Defaults to None. - """ - pred_sigmoid = pred.sigmoid() - target = target.type_as(pred) - pt = (1 - pred_sigmoid) * target + pred_sigmoid * (1 - target) - focal_weight = (alpha * target + (1 - alpha) * - (1 - target)) * pt.pow(gamma) - loss = F.binary_cross_entropy_with_logits( - pred, target, reduction='none') * focal_weight - if weight is not None: - if weight.shape != loss.shape: - if weight.size(0) == loss.size(0): - # For most cases, weight is of shape (num_priors, ), - # which means it does not have the second axis num_class - weight = weight.view(-1, 1) - else: - # Sometimes, weight per anchor per class is also needed. e.g. - # in FSAF. But it may be flattened of shape - # (num_priors x num_class, ), while loss is still of shape - # (num_priors, num_class). - assert weight.numel() == loss.numel() - weight = weight.view(loss.size(0), -1) - assert weight.ndim == loss.ndim - loss = weight_reduce_loss(loss, weight, reduction, avg_factor) - return loss - -@LOSSES.register_module(force=True) -class SimpleLoss_v1(nn.Module): - def __init__(self, pos_weight, loss_weight): - super(SimpleLoss_v1, self).__init__() - # self.loss_fn = torch.nn.BCEWithLogitsLoss(pos_weight=torch.Tensor([pos_weight])) - # self.loss_fn = torch.nn.CrossEntroyLoss(reduction="none") - self.loss_weight = loss_weight - - def forward(self, ypred, ytgt): - bs, pred_class_num, bev_h, bev_w = ypred.shape - ypred = ypred.permute(0, 2, 3, 1).reshape(bs*bev_h*bev_w, pred_class_num).contiguous() - ytgt = ytgt.view(-1) - ytgt = F.one_hot(ytgt.long(), num_classes=pred_class_num+1).view(-1, pred_class_num+1)[:, 1:] - fg_mask = torch.max(ytgt, dim=1).values > 0.0 - ypred = ypred[fg_mask] - ytgt = ytgt[fg_mask] - loss = F.binary_cross_entropy_with_logits(ypred, ytgt.float(), reduction='none',).sum() / max(1.0, fg_mask.sum()) - return loss*self.loss_weight - -@LOSSES.register_module() -class SimpleLoss(torch.nn.Module): - def __init__(self, pos_weight, loss_weight): - super(SimpleLoss, self).__init__() - self.loss_fn = torch.nn.BCEWithLogitsLoss(pos_weight=torch.Tensor([pos_weight])) - self.loss_weight = loss_weight - - def forward(self, ypred, ytgt): - # import ipdb;ipdb.set_trace() - loss = self.loss_fn(ypred, ytgt) - return loss*self.loss_weight - -@LOSSES.register_module() -class MaskFocalLoss(FocalLoss): - def __init__(self,**kwargs): - super(MaskFocalLoss, self).__init__(**kwargs) - - def forward(self, - pred, - target, - weight=None, - avg_factor=None, - reduction_override=None): - assert reduction_override in (None, 'none', 'mean', 'sum') - reduction = ( - reduction_override if reduction_override else self.reduction) - if not self.use_sigmoid: - raise NotImplementedError - - num_classes = pred.size(1) - loss = 0 - for index in range(num_classes): - loss += self.loss_weight * py_sigmoid_focal_loss( - pred[:,index], - target[:,index], - weight, - gamma=self.gamma, - alpha=self.alpha, - reduction=reduction, - avg_factor=avg_factor) - # import ipdb; ipdb.set_trace() - loss /= num_classes - return loss \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/__init__.py deleted file mode 100644 index f2c624f877c9f8b6f99f1e4868c91ea9d5d396d1..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .transformer import MapTRPerceptionTransformer -from .decoder import MapTRDecoder, DecoupledDetrTransformerDecoderLayer -from .geometry_kernel_attention import GeometrySptialCrossAttention, GeometryKernelAttention -from .builder import build_fuser -from .encoder import LSSTransform \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/builder.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/builder.py deleted file mode 100644 index 99f9b41592053e1e1bde5be289bf0584d45f7db6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/builder.py +++ /dev/null @@ -1,5 +0,0 @@ -import torch.nn as nn -from mmcv.utils import Registry, build_from_cfg -FUSERS = Registry("fusers") -def build_fuser(cfg): - return FUSERS.build(cfg) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/decoder.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/decoder.py deleted file mode 100644 index 34176995dab50f43ce5ca7b84bf1de34a5ed7fc4..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/decoder.py +++ /dev/null @@ -1,266 +0,0 @@ -import torch -from mmcv.cnn.bricks.registry import (ATTENTION, - TRANSFORMER_LAYER, - POSITIONAL_ENCODING, - TRANSFORMER_LAYER_SEQUENCE) -from mmdet.models.utils.transformer import inverse_sigmoid -from mmcv.cnn.bricks.transformer import TransformerLayerSequence, BaseTransformerLayer - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class MapTRDecoder(TransformerLayerSequence): - """Implements the decoder in DETR3D transformer. - Args: - return_intermediate (bool): Whether to return intermediate outputs. - coder_norm_cfg (dict): Config of last normalization layer. Default: - `LN`. - """ - - def __init__(self, *args, return_intermediate=False, **kwargs): - super(MapTRDecoder, self).__init__(*args, **kwargs) - self.return_intermediate = return_intermediate - self.fp16_enabled = False - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def forward(self, - query, - *args, - reference_points=None, - reg_branches=None, - key_padding_mask=None, - **kwargs): - """Forward function for `Detr3DTransformerDecoder`. - Args: - query (Tensor): Input query with shape - `(num_query, bs, embed_dims)`. - reference_points (Tensor): The reference - points of offset. has shape - (bs, num_query, 4) when as_two_stage, - otherwise has shape ((bs, num_query, 2). - reg_branch: (obj:`nn.ModuleList`): Used for - refining the regression results. Only would - be passed when with_box_refine is True, - otherwise would be passed a `None`. - Returns: - Tensor: Results with shape [1, num_query, bs, embed_dims] when - return_intermediate is `False`, otherwise it has shape - [num_layers, num_query, bs, embed_dims]. - """ - output = query - intermediate = [] - intermediate_reference_points = [] - for lid, layer in enumerate(self.layers): - - reference_points_input = reference_points[..., :2].unsqueeze( - 2) # BS NUM_QUERY NUM_LEVEL 2 - output = layer( - output, - *args, - reference_points=reference_points_input, - key_padding_mask=key_padding_mask, - **kwargs) - output = output.permute(1, 0, 2) - - if reg_branches is not None: - tmp = reg_branches[lid](output) - - # assert reference_points.shape[-1] == 2 - - new_reference_points = torch.zeros_like(reference_points) - new_reference_points = tmp + inverse_sigmoid(reference_points) - # new_reference_points[..., 2:3] = tmp[ - # ..., 4:5] + inverse_sigmoid(reference_points[..., 2:3]) - - new_reference_points = new_reference_points.sigmoid() - - reference_points = new_reference_points.detach() - - output = output.permute(1, 0, 2) - if self.return_intermediate: - intermediate.append(output) - intermediate_reference_points.append(reference_points) - - if self.return_intermediate: - return torch.stack(intermediate), torch.stack( - intermediate_reference_points) - - return output, reference_points - - - -@TRANSFORMER_LAYER.register_module() -class DecoupledDetrTransformerDecoderLayer(BaseTransformerLayer): - """Implements decoder layer in DETR transformer. - Args: - attn_cfgs (list[`mmcv.ConfigDict`] | list[dict] | dict )): - Configs for self_attention or cross_attention, the order - should be consistent with it in `operation_order`. If it is - a dict, it would be expand to the number of attention in - `operation_order`. - feedforward_channels (int): The hidden dimension for FFNs. - ffn_dropout (float): Probability of an element to be zeroed - in ffn. Default 0.0. - operation_order (tuple[str]): The execution order of operation - in transformer. Such as ('self_attn', 'norm', 'ffn', 'norm'). - Default:None - act_cfg (dict): The activation config for FFNs. Default: `LN` - norm_cfg (dict): Config dict for normalization layer. - Default: `LN`. - ffn_num_fcs (int): The number of fully-connected layers in FFNs. - Default:2. - """ - - def __init__(self, - attn_cfgs, - feedforward_channels, - num_vec=50, - num_pts_per_vec=20, - ffn_dropout=0.0, - operation_order=None, - act_cfg=dict(type='ReLU', inplace=True), - norm_cfg=dict(type='LN'), - ffn_num_fcs=2, - **kwargs): - super(DecoupledDetrTransformerDecoderLayer, self).__init__( - attn_cfgs=attn_cfgs, - feedforward_channels=feedforward_channels, - ffn_dropout=ffn_dropout, - operation_order=operation_order, - act_cfg=act_cfg, - norm_cfg=norm_cfg, - ffn_num_fcs=ffn_num_fcs, - **kwargs) - assert len(operation_order) == 8 - assert set(operation_order) == set( - ['self_attn', 'norm', 'cross_attn', 'ffn']) - - self.num_vec = num_vec - self.num_pts_per_vec = num_pts_per_vec - - def forward(self, - query, - key=None, - value=None, - query_pos=None, - key_pos=None, - attn_masks=None, - query_key_padding_mask=None, - key_padding_mask=None, - **kwargs): - """Forward function for `TransformerDecoderLayer`. - **kwargs contains some specific arguments of attentions. - Args: - query (Tensor): The input query with shape - [num_queries, bs, embed_dims] if - self.batch_first is False, else - [bs, num_queries embed_dims]. - key (Tensor): The key tensor with shape [num_keys, bs, - embed_dims] if self.batch_first is False, else - [bs, num_keys, embed_dims] . - value (Tensor): The value tensor with same shape as `key`. - query_pos (Tensor): The positional encoding for `query`. - Default: None. - key_pos (Tensor): The positional encoding for `key`. - Default: None. - attn_masks (List[Tensor] | None): 2D Tensor used in - calculation of corresponding attention. The length of - it should equal to the number of `attention` in - `operation_order`. Default: None. - query_key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_queries]. Only used in `self_attn` layer. - Defaults to None. - key_padding_mask (Tensor): ByteTensor for `query`, with - shape [bs, num_keys]. Default: None. - Returns: - Tensor: forwarded results with shape [num_queries, bs, embed_dims]. - """ - - norm_index = 0 - attn_index = 0 - ffn_index = 0 - identity = query - if attn_masks is None: - attn_masks = [None for _ in range(self.num_attn)] - elif isinstance(attn_masks, torch.Tensor): - attn_masks = [ - copy.deepcopy(attn_masks) for _ in range(self.num_attn) - ] - warnings.warn(f'Use same attn_mask in all attentions in ' - f'{self.__class__.__name__} ') - else: - assert len(attn_masks) == self.num_attn, f'The length of ' \ - f'attn_masks {len(attn_masks)} must be equal ' \ - f'to the number of attention in ' \ - f'operation_order {self.num_attn}' - # - num_vec = kwargs['num_vec'] - num_pts_per_vec = kwargs['num_pts_per_vec'] - for layer in self.operation_order: - if layer == 'self_attn': - # import ipdb;ipdb.set_trace() - if attn_index == 0: - n_pts, n_batch, n_dim = query.shape - query = query.view(num_vec, num_pts_per_vec,n_batch,n_dim).flatten(1,2) - query_pos = query_pos.view(num_vec, num_pts_per_vec,n_batch,n_dim).flatten(1,2) - temp_key = temp_value = query - query = self.attentions[attn_index]( - query, - temp_key, - temp_value, - identity if self.pre_norm else None, - query_pos=query_pos, - key_pos=query_pos, - attn_mask=kwargs['self_attn_mask'], - key_padding_mask=query_key_padding_mask, - **kwargs) - # import ipdb;ipdb.set_trace() - query = query.view(num_vec, num_pts_per_vec, n_batch, n_dim).flatten(0,1) - query_pos = query_pos.view(num_vec, num_pts_per_vec, n_batch, n_dim).flatten(0,1) - attn_index += 1 - identity = query - else: - # import ipdb;ipdb.set_trace() - n_pts, n_batch, n_dim = query.shape - query = query.view(num_vec, num_pts_per_vec,n_batch,n_dim).permute(1,0,2,3).contiguous().flatten(1,2) - query_pos = query_pos.view(num_vec, num_pts_per_vec,n_batch,n_dim).permute(1,0,2,3).contiguous().flatten(1,2) - temp_key = temp_value = query - query = self.attentions[attn_index]( - query, - temp_key, - temp_value, - identity if self.pre_norm else None, - query_pos=query_pos, - key_pos=query_pos, - attn_mask=attn_masks[attn_index], - key_padding_mask=query_key_padding_mask, - **kwargs) - # import ipdb;ipdb.set_trace() - query = query.view(num_pts_per_vec, num_vec, n_batch, n_dim).permute(1,0,2,3).contiguous().flatten(0,1) - query_pos = query_pos.view(num_pts_per_vec, num_vec, n_batch, n_dim).permute(1,0,2,3).contiguous().flatten(0,1) - attn_index += 1 - identity = query - - elif layer == 'norm': - query = self.norms[norm_index](query) - norm_index += 1 - - elif layer == 'cross_attn': - query = self.attentions[attn_index]( - query, - key, - value, - identity if self.pre_norm else None, - query_pos=query_pos, - key_pos=key_pos, - attn_mask=attn_masks[attn_index], - key_padding_mask=key_padding_mask, - **kwargs) - attn_index += 1 - identity = query - - elif layer == 'ffn': - query = self.ffns[ffn_index]( - query, identity if self.pre_norm else None) - ffn_index += 1 - - return query - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/encoder.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/encoder.py deleted file mode 100644 index d2d41328f8762acc17236cedae272b927c78b585..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/encoder.py +++ /dev/null @@ -1,1479 +0,0 @@ -import torch -import numpy as np -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential -import torch.nn as nn -from mmcv.cnn.bricks.registry import (ATTENTION, - TRANSFORMER_LAYER, - TRANSFORMER_LAYER_SEQUENCE) -from mmdet3d.ops import bev_pool -from mmdet3d.ops.bev_pool_v2.bev_pool import bev_pool_v2 -from mmcv.runner import force_fp32, auto_fp16 -from torch.cuda.amp.autocast_mode import autocast -from mmcv.cnn import build_conv_layer -from mmdet.models.backbones.resnet import BasicBlock, Bottleneck -import torch.nn.functional as F - -from projects.mmdet3d_plugin.bevformer.modules.encoder import BEVFormerEncoder - -torch.set_float32_matmul_precision('high') - -def gen_dx_bx(xbound, ybound, zbound): - dx = torch.Tensor([row[2] for row in [xbound, ybound, zbound]]) - bx = torch.Tensor([row[0] + row[2] / 2.0 for row in [xbound, ybound, zbound]]) - nx = torch.Tensor( - [int((row[1] - row[0]) / row[2]) for row in [xbound, ybound, zbound]] - ) - return dx, bx, nx - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class BaseTransform(BaseModule): - def __init__( - self, - in_channels, - out_channels, - feat_down_sample, - pc_range, - voxel_size, - dbound, - ): - super(BaseTransform, self).__init__() - self.in_channels = in_channels - self.feat_down_sample = feat_down_sample - # self.image_size = image_size - # self.feature_size = feature_size - self.xbound = [pc_range[0],pc_range[3], voxel_size[0]] - self.ybound = [pc_range[1],pc_range[4], voxel_size[1]] - self.zbound = [pc_range[2],pc_range[5], voxel_size[2]] - self.dbound = dbound - - dx, bx, nx = gen_dx_bx(self.xbound, self.ybound, self.zbound) - self.dx = nn.Parameter(dx, requires_grad=False) - self.bx = nn.Parameter(bx, requires_grad=False) - self.nx = nn.Parameter(nx, requires_grad=False) - - - self.C = out_channels - self.frustum = None - self.D = int((dbound[1] - dbound[0]) / dbound[2]) - # self.frustum = self.create_frustum() - # self.D = self.frustum.shape[0] - self.fp16_enabled = False - - @force_fp32() - def create_frustum(self,fH,fW,img_metas): - # iH, iW = self.image_size - # fH, fW = self.feature_size - iH = img_metas[0]['img_shape'][0][0] - iW = img_metas[0]['img_shape'][0][1] - assert iH // self.feat_down_sample == fH - # import pdb;pdb.set_trace() - ds = ( - torch.arange(*self.dbound, dtype=torch.float) - .view(-1, 1, 1) - .expand(-1, fH, fW) - ) - D, _, _ = ds.shape - - xs = ( - torch.linspace(0, iW - 1, fW, dtype=torch.float) - .view(1, 1, fW) - .expand(D, fH, fW) - ) - ys = ( - torch.linspace(0, iH - 1, fH, dtype=torch.float) - .view(1, fH, 1) - .expand(D, fH, fW) - ) - - frustum = torch.stack((xs, ys, ds), -1) - # return nn.Parameter(frustum, requires_grad=False) - return frustum - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def matmul_1(self, x, y, trans): - B, N, _ = trans.shape - points = torch.matmul(x.view(B, N, 1, 1, 1, 3, 3), y.unsqueeze(-1)) - points = torch.cat( - ( - points[:, :, :, :, :, :2] * points[:, :, :, :, :, 2:3], - points[:, :, :, :, :, 2:3], - ), - 5, - ) - return points - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def matmul_2(self, x, y, trans, lidar2ego_trans, points): - B, N, _ = trans.shape - combine = torch.matmul(x, y) - points = torch.matmul(combine.view(B, N, 1, 1, 1, 3, 3), points).squeeze(-1) - points += trans.view(B, N, 1, 1, 1, 3) - points -= lidar2ego_trans.view(B, 1, 1, 1, 1, 3) - return points - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def matmul_3(self, x, y, trans): - B, N, _ = trans.shape - points = torch.matmul(x.view(B, 1, 1, 1, 1, 3, 3), y.unsqueeze(-1)).squeeze(-1) - return points - - @force_fp32() - def get_geometry_v1( - self, - fH, - fW, - rots, - trans, - intrins, - post_rots, - post_trans, - lidar2ego_rots, - lidar2ego_trans, - img_metas, - **kwargs, - ): - B, N, _ = trans.shape - device = trans.device - if self.frustum == None: - self.frustum = self.create_frustum(fH,fW,img_metas) - self.frustum = self.frustum.to(device) - # self.D = self.frustum.shape[0] - - # undo post-transformation - # B x N x D x H x W x 3 - points = self.frustum - post_trans.view(B, N, 1, 1, 1, 3) - post_rots = torch.inverse(post_rots) - points = self.matmul_1(post_rots, points, trans) - # points = torch.matmul(post_rots.view(B, N, 1, 1, 1, 3, 3), points.unsqueeze(-1)) - - - # # cam_to_ego - # points = torch.cat( - # ( - # points[:, :, :, :, :, :2] * points[:, :, :, :, :, 2:3], - # points[:, :, :, :, :, 2:3], - # ), - # 5, - # ) - intrins = torch.inverse(intrins) - # combine = torch.matmul(rots, intrins) - # points = torch.matmul(combine.view(B, N, 1, 1, 1, 3, 3), points).squeeze(-1) - # points += trans.view(B, N, 1, 1, 1, 3) - # # ego_to_lidar - # points -= lidar2ego_trans.view(B, 1, 1, 1, 1, 3) - points = self.matmul_2(rots, intrins, trans, lidar2ego_trans, points) - lidar2ego_rots = torch.inverse(lidar2ego_rots) - points = self.matmul_3(lidar2ego_rots, points, trans) - - if "extra_rots" in kwargs: - extra_rots = kwargs["extra_rots"] - points = torch.matmul(extra_rots.view(B, 1, 1, 1, 1, 3, 3).repeat(1, N, 1, 1, 1, 1, 1), points.unsqueeze(-1)).squeeze(-1) - if "extra_trans" in kwargs: - extra_trans = kwargs["extra_trans"] - points += extra_trans.view(B, 1, 1, 1, 1, 3).repeat(1, N, 1, 1, 1, 1) - - return points - - @force_fp32() - def get_geometry( - self, - fH, - fW, - lidar2img, - img_metas, - ): - B, N, _, _ = lidar2img.shape - device = lidar2img.device - # import pdb;pdb.set_trace() - if self.frustum == None: - self.frustum = self.create_frustum(fH,fW,img_metas) - self.frustum = self.frustum.to(device) - # self.D = self.frustum.shape[0] - - points = self.frustum.view(1,1,self.D, fH, fW, 3) \ - .repeat(B,N,1,1,1,1) - lidar2img = lidar2img.view(B,N,1,1,1,4,4) - # img2lidar = torch.inverse(lidar2img) - points = torch.cat( - (points, torch.ones_like(points[..., :1])), -1) - points = torch.linalg.solve(lidar2img.to(torch.float32), - points.unsqueeze(-1).to(torch.float32)).squeeze(-1) - # points = torch.matmul(img2lidar.to(torch.float32), - # points.unsqueeze(-1).to(torch.float32)).squeeze(-1) - # import pdb;pdb.set_trace() - eps = 1e-5 - points = points[..., 0:3] / torch.maximum( - points[..., 3:4], torch.ones_like(points[..., 3:4]) * eps) - - return points - - def get_cam_feats(self, x): - raise NotImplementedError - - def get_mlp_input(self, sensor2ego, intrin, post_rot, post_tran, bda): - raise NotImplementedError - - @force_fp32() - def bev_pool(self, geom_feats, x): - B, N, D, H, W, C = x.shape - Nprime = B * N * D * H * W - - # flatten x - x = x.reshape(Nprime, C) - - # flatten indices - geom_feats = ((geom_feats - (self.bx - self.dx / 2.0)) / self.dx).long() - geom_feats = geom_feats.view(Nprime, 3) - batch_ix = torch.cat( - [ - torch.full([Nprime // B, 1], ix, device=x.device, dtype=torch.long) - for ix in range(B) - ] - ) - geom_feats = torch.cat((geom_feats, batch_ix), 1) - - # filter out points that are outside box - kept = ( - (geom_feats[:, 0] >= 0) - & (geom_feats[:, 0] < self.nx[0]) - & (geom_feats[:, 1] >= 0) - & (geom_feats[:, 1] < self.nx[1]) - & (geom_feats[:, 2] >= 0) - & (geom_feats[:, 2] < self.nx[2]) - ) - - x = x[kept] - geom_feats = geom_feats[kept] - # idx = torch.where(kept)[0] - # x = x.index_select(0, idx) - # geom_feats = geom_feats.index_select(0, idx) - - x = bev_pool(x, geom_feats, B, self.nx[2], self.nx[0], self.nx[1]) - - # # collapse Z - # x = x.permute(0, 4, 1, 2, 3).contiguous() - # final = torch.cat(x.unbind(dim=2), 1) - - return x - - def stack_metas(self, metas, key, device, dtype): - tensors = [] - for meta in metas: - val = meta[key] - if isinstance(val, np.ndarray): - val = torch.from_numpy(val) - elif isinstance(val, list): - val = torch.stack([torch.from_numpy(v) if isinstance(v, np.ndarray) else v for v in val], dim=0) - tensors.append(val) - return torch.stack(tensors, dim=0).to(device=device, dtype=dtype) - - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def extract_metas(self, images, img_metas): - device = images.device - dtype = images.dtype - - lidar2img = self.stack_metas(img_metas, 'lidar2img', device, dtype) - camera2ego = self.stack_metas(img_metas, 'camera2ego', device, dtype) - camera_intrinsics = self.stack_metas(img_metas, 'camera_intrinsics', device, dtype) - img_aug_matrix = self.stack_metas(img_metas, 'img_aug_matrix', device, dtype) - lidar2ego = self.stack_metas(img_metas, 'lidar2ego', device, dtype) - - rots = camera2ego[..., :3, :3] - trans = camera2ego[..., :3, 3] - intrins = camera_intrinsics[..., :3, :3] - post_rots = img_aug_matrix[..., :3, :3] - post_trans = img_aug_matrix[..., :3, 3] - lidar2ego_rots = lidar2ego[..., :3, :3] - lidar2ego_trans = lidar2ego[..., :3, 3] - - return rots, trans, intrins, post_rots, post_trans, lidar2ego_rots, lidar2ego_trans, camera2ego, camera_intrinsics - - @force_fp32() - def forward( - self, - images, - img_metas - ): - B, N, C, fH, fW = images.shape - rots, trans, intrins, post_rots, post_trans, lidar2ego_rots, lidar2ego_trans, camera2ego, camera_intrinsics = self.extract_metas(images, img_metas) - geom = self.get_geometry_v1( - fH, - fW, - rots, - trans, - intrins, - post_rots, - post_trans, - lidar2ego_rots, - lidar2ego_trans, - img_metas - ) - mlp_input = self.get_mlp_input(camera2ego, camera_intrinsics, post_rots, post_trans) - x, depth = self.get_cam_feats(images, mlp_input) - x = self.bev_pool(geom, x) - # x = x.permute(0,1,3,2).contiguous() - - return x, depth - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class BaseTransformV2(BaseModule): - def __init__( - self, - input_size, - in_channels, - out_channels, - feat_down_sample, - pc_range, - voxel_size, - dbound, - sid=False, - ): - super(BaseTransformV2, self).__init__() - self.in_channels = in_channels - self.feat_down_sample = feat_down_sample - # self.image_size = image_size - # self.feature_size = feature_size - - xbound = [pc_range[0],pc_range[3], voxel_size[0]] - ybound = [pc_range[1],pc_range[4], voxel_size[1]] - zbound = [pc_range[2],pc_range[5], voxel_size[2]] - grid_config = [xbound, ybound, zbound] - self.create_grid_infos(*grid_config) - self.dbound = dbound - self.sid = sid - self.frustum = self.create_frustum(dbound, - input_size, feat_down_sample) - self.C = out_channels - self.D = round((dbound[1] - dbound[0]) / dbound[2]) - self.fp16_enabled = False - - def create_grid_infos(self, x, y, z, **kwargs): - """Generate the grid information including the lower bound, interval, - and size. - - Args: - x (tuple(float)): Config of grid alone x axis in format of - (lower_bound, upper_bound, interval). - y (tuple(float)): Config of grid alone y axis in format of - (lower_bound, upper_bound, interval). - z (tuple(float)): Config of grid alone z axis in format of - (lower_bound, upper_bound, interval). - **kwargs: Container for other potential parameters - """ - self.grid_lower_bound = torch.Tensor([cfg[0] for cfg in [x, y, z]]) - self.grid_interval = torch.Tensor([cfg[2] for cfg in [x, y, z]]) - self.grid_size = torch.Tensor([(cfg[1] - cfg[0]) / cfg[2] - for cfg in [x, y, z]]) - - # @force_fp32() - def create_frustum(self, depth_cfg, input_size, downsample): - """Generate the frustum template for each image. - - Args: - depth_cfg (tuple(float)): Config of grid alone depth axis in format - of (lower_bound, upper_bound, interval). - input_size (tuple(int)): Size of input images in format of (height, - width). - downsample (int): Down sample scale factor from the input size to - the feature size. - """ - H_in, W_in = input_size - H_feat, W_feat = H_in // downsample, W_in // downsample - d = torch.arange(*depth_cfg, dtype=torch.float)\ - .view(-1, 1, 1).expand(-1, H_feat, W_feat) - self.D = d.shape[0] - if self.sid: - d_sid = torch.arange(self.D).float() - depth_cfg_t = torch.tensor(depth_cfg).float() - d_sid = torch.exp(torch.log(depth_cfg_t[0]) + d_sid / (self.D-1) * - torch.log((depth_cfg_t[1]-1) / depth_cfg_t[0])) - d = d_sid.view(-1, 1, 1).expand(-1, H_feat, W_feat) - x = torch.linspace(0, W_in - 1, W_feat, dtype=torch.float)\ - .view(1, 1, W_feat).expand(self.D, H_feat, W_feat) - y = torch.linspace(0, H_in - 1, H_feat, dtype=torch.float)\ - .view(1, H_feat, 1).expand(self.D, H_feat, W_feat) - - # D x H x W x 3 - return torch.stack((x, y, d), -1) - - def get_lidar_coor(self, - fH, - fW, - rots, - trans, - intrins, - post_rots, - post_trans, - lidar2ego_rots, - lidar2ego_trans, - img_metas): - B, N, _, _ = sensor2ego.shape - - # post-transformation - # B x N x D x H x W x 3 - points = self.frustum.to(sensor2ego) - post_trans.view(B, N, 1, 1, 1, 3) - points = torch.inverse(post_rots).view(B, N, 1, 1, 1, 3, 3)\ - .matmul(points.unsqueeze(-1)) - - # cam_to_ego - points = torch.cat( - (points[..., :2, :] * points[..., 2:3, :], points[..., 2:3, :]), 5) - combine = rots.matmul(torch.inverse(intrins)) - points = combine.view(B, N, 1, 1, 1, 3, 3).matmul(points).squeeze(-1) - points += trans.view(B, N, 1, 1, 1, 3) - # ego_to_lidar - points -= lidar2ego_trans.view(B, 1, 1, 1, 1, 3) - points = ( - torch.inverse(lidar2ego_rots) - .view(B, 1, 1, 1, 1, 3, 3) - .matmul(points.unsqueeze(-1)) - .squeeze(-1) - ) - return points - - @force_fp32() - def get_geometry_v1( - self, - fH, - fW, - rots, - trans, - intrins, - post_rots, - post_trans, - lidar2ego_rots, - lidar2ego_trans, - img_metas, - **kwargs, - ): - B, N, _ = trans.shape - device = trans.device - # if self.frustum == None: - # self.frustum = self.create_frustum(fH,fW,img_metas) - # self.frustum = self.frustum.to(device) - # # self.D = self.frustum.shape[0] - - # undo post-transformation - # B x N x D x H x W x 3 - points = self.frustum.to(device)- post_trans.view(B, N, 1, 1, 1, 3) - points = ( - torch.inverse(post_rots) - .view(B, N, 1, 1, 1, 3, 3) - .matmul(points.unsqueeze(-1)) - ) - # cam_to_ego - points = torch.cat( - ( - points[:, :, :, :, :, :2] * points[:, :, :, :, :, 2:3], - points[:, :, :, :, :, 2:3], - ), - 5, - ) - combine = rots.matmul(torch.inverse(intrins)) - points = combine.view(B, N, 1, 1, 1, 3, 3).matmul(points).squeeze(-1) - points += trans.view(B, N, 1, 1, 1, 3) - # ego_to_lidar - points -= lidar2ego_trans.view(B, 1, 1, 1, 1, 3) - points = ( - torch.inverse(lidar2ego_rots) - .view(B, 1, 1, 1, 1, 3, 3) - .matmul(points.unsqueeze(-1)) - .squeeze(-1) - ) - - if "extra_rots" in kwargs: - extra_rots = kwargs["extra_rots"] - points = ( - extra_rots.view(B, 1, 1, 1, 1, 3, 3) - .repeat(1, N, 1, 1, 1, 1, 1) - .matmul(points.unsqueeze(-1)) - .squeeze(-1) - ) - if "extra_trans" in kwargs: - extra_trans = kwargs["extra_trans"] - points += extra_trans.view(B, 1, 1, 1, 1, 3).repeat(1, N, 1, 1, 1, 1) - - return points - - @force_fp32() - def get_geometry( - self, - fH, - fW, - lidar2img, - img_metas, - ): - B, N, _, _ = lidar2img.shape - device = lidar2img.device - if self.frustum == None: - self.frustum = self.create_frustum(fH,fW,img_metas) - self.frustum = self.frustum.to(device) - # self.D = self.frustum.shape[0] - - points = self.frustum.view(1,1,self.D, fH, fW, 3) \ - .repeat(B,N,1,1,1,1) - lidar2img = lidar2img.view(B,N,1,1,1,4,4) - # img2lidar = torch.inverse(lidar2img) - points = torch.cat( - (points, torch.ones_like(points[..., :1])), -1) - points = torch.linalg.solve(lidar2img.to(torch.float32), - points.unsqueeze(-1).to(torch.float32)).squeeze(-1) - # points = torch.matmul(img2lidar.to(torch.float32), - # points.unsqueeze(-1).to(torch.float32)).squeeze(-1) - eps = 1e-5 - points = points[..., 0:3] / torch.maximum( - points[..., 3:4], torch.ones_like(points[..., 3:4]) * eps) - - return points - - def get_cam_feats(self, x): - raise NotImplementedError - - def get_mlp_input(self, sensor2ego, intrin, post_rot, post_tran, bda): - raise NotImplementedError - - - def voxel_pooling_prepare_v2(self, coor): - """Data preparation for voxel pooling. - - Args: - coor (torch.tensor): Coordinate of points in the lidar space in - shape (B, N, D, H, W, 3). - - Returns: - tuple[torch.tensor]: Rank of the voxel that a point is belong to - in shape (N_Points); Reserved index of points in the depth - space in shape (N_Points). Reserved index of points in the - feature space in shape (N_Points). - """ - B, N, D, H, W, _ = coor.shape - num_points = B * N * D * H * W - # record the index of selected points for acceleration purpose - ranks_depth = torch.range( - 0, num_points - 1, dtype=torch.int, device=coor.device) - ranks_feat = torch.range( - 0, num_points // D - 1, dtype=torch.int, device=coor.device) - ranks_feat = ranks_feat.reshape(B, N, 1, H, W) - ranks_feat = ranks_feat.expand(B, N, D, H, W).flatten() - # convert coordinate into the voxel space - coor = ((coor - self.grid_lower_bound.to(coor)) / - self.grid_interval.to(coor)) - coor = coor.long().view(num_points, 3) - batch_idx = torch.range(0, B - 1).reshape(B, 1). \ - expand(B, num_points // B).reshape(num_points, 1).to(coor) - coor = torch.cat((coor, batch_idx), 1) - - # filter out points that are outside box - kept = (coor[:, 0] >= 0) & (coor[:, 0] < self.grid_size[0]) & \ - (coor[:, 1] >= 0) & (coor[:, 1] < self.grid_size[1]) & \ - (coor[:, 2] >= 0) & (coor[:, 2] < self.grid_size[2]) - if len(kept) == 0: - return None, None, None, None, None - coor, ranks_depth, ranks_feat = \ - coor[kept], ranks_depth[kept], ranks_feat[kept] - # get tensors from the same voxel next to each other - ranks_bev = coor[:, 3] * ( - self.grid_size[2] * self.grid_size[1] * self.grid_size[0]) - ranks_bev += coor[:, 2] * (self.grid_size[1] * self.grid_size[0]) - ranks_bev += coor[:, 1] * self.grid_size[0] + coor[:, 0] - order = ranks_bev.argsort() - ranks_bev, ranks_depth, ranks_feat = \ - ranks_bev[order], ranks_depth[order], ranks_feat[order] - - kept = torch.ones( - ranks_bev.shape[0], device=ranks_bev.device, dtype=torch.bool) - kept[1:] = ranks_bev[1:] != ranks_bev[:-1] - interval_starts = torch.where(kept)[0].int() - if len(interval_starts) == 0: - return None, None, None, None, None - interval_lengths = torch.zeros_like(interval_starts) - interval_lengths[:-1] = interval_starts[1:] - interval_starts[:-1] - interval_lengths[-1] = ranks_bev.shape[0] - interval_starts[-1] - return ranks_bev.int().contiguous(), ranks_depth.int().contiguous( - ), ranks_feat.int().contiguous(), interval_starts.int().contiguous( - ), interval_lengths.int().contiguous() - - - @force_fp32() - def voxel_pooling_v2(self, coor, depth, feat): - ranks_bev, ranks_depth, ranks_feat, \ - interval_starts, interval_lengths = \ - self.voxel_pooling_prepare_v2(coor) - if ranks_feat is None: - print('warning ---> no points within the predefined ' - 'bev receptive field') - dummy = torch.zeros(size=[ - feat.shape[0], feat.shape[2], - int(self.grid_size[2]), - int(self.grid_size[0]), - int(self.grid_size[1]) - ]).to(feat) - dummy = torch.cat(dummy.unbind(dim=2), 1) - return dummy - feat = feat.permute(0, 1, 3, 4, 2) - bev_feat_shape = (depth.shape[0], int(self.grid_size[2]), - int(self.grid_size[1]), int(self.grid_size[0]), - feat.shape[-1]) # (B, Z, Y, X, C) - bev_feat = bev_pool_v2(depth, feat, ranks_depth, ranks_feat, ranks_bev, - bev_feat_shape, interval_starts, - interval_lengths) - # collapse Z - # if self.collapse_z: - bev_feat = torch.cat(bev_feat.unbind(dim=2), 1) - return bev_feat - @force_fp32() - def bev_pool(self, geom_feats, x): - B, N, D, H, W, C = x.shape - Nprime = B * N * D * H * W - # flatten x - x = x.reshape(Nprime, C) - - # flatten indices - geom_feats = ((geom_feats - (self.bx - self.dx / 2.0)) / self.dx).long() - geom_feats = geom_feats.view(Nprime, 3) - batch_ix = torch.cat( - [ - torch.full([Nprime // B, 1], ix, device=x.device, dtype=torch.long) - for ix in range(B) - ] - ) - geom_feats = torch.cat((geom_feats, batch_ix), 1) - - # filter out points that are outside box - kept = ( - (geom_feats[:, 0] >= 0) - & (geom_feats[:, 0] < self.nx[0]) - & (geom_feats[:, 1] >= 0) - & (geom_feats[:, 1] < self.nx[1]) - & (geom_feats[:, 2] >= 0) - & (geom_feats[:, 2] < self.nx[2]) - ) - x = x[kept] - geom_feats = geom_feats[kept] - - x = bev_pool(x, geom_feats, B, self.nx[2], self.nx[0], self.nx[1]) - - # collapse Z - final = torch.cat(x.unbind(dim=2), 1) - - return final - - - @force_fp32() - def forward( - self, - images, - img_metas - ): - B, N, C, fH, fW = images.shape - lidar2img = [] - camera2ego = [] - camera_intrinsics = [] - img_aug_matrix = [] - lidar2ego = [] - - for img_meta in img_metas: - lidar2img.append(img_meta['lidar2img']) - camera2ego.append(img_meta['camera2ego']) - camera_intrinsics.append(img_meta['camera_intrinsics']) - img_aug_matrix.append(img_meta['img_aug_matrix']) - lidar2ego.append(img_meta['lidar2ego']) - - lidar2img = np.asarray(lidar2img) - lidar2img = images.new_tensor(lidar2img) # (B, N, 4, 4) - camera2ego = np.asarray(camera2ego) - camera2ego = images.new_tensor(camera2ego) # (B, N, 4, 4) - camera_intrinsics = np.asarray(camera_intrinsics) - camera_intrinsics = images.new_tensor(camera_intrinsics) # (B, N, 4, 4) - img_aug_matrix = np.asarray(img_aug_matrix) - img_aug_matrix = images.new_tensor(img_aug_matrix) # (B, N, 4, 4) - lidar2ego = np.asarray(lidar2ego) - lidar2ego = images.new_tensor(lidar2ego) # (B, N, 4, 4) - - # lidar2cam = torch.linalg.solve(camera2ego, lidar2ego.view(B,1,4,4).repeat(1,N,1,1)) - # lidar2oriimg = torch.matmul(camera_intrinsics,lidar2cam) - # mylidar2img = torch.matmul(img_aug_matrix,lidar2oriimg) - - rots = camera2ego[..., :3, :3] - trans = camera2ego[..., :3, 3] - intrins = camera_intrinsics[..., :3, :3] - post_rots = img_aug_matrix[..., :3, :3] - post_trans = img_aug_matrix[..., :3, 3] - lidar2ego_rots = lidar2ego[..., :3, :3] - lidar2ego_trans = lidar2ego[..., :3, 3] - - sensor_config = [fH, fW, rots, trans, intrins, post_rots, post_trans, lidar2ego_rots, lidar2ego_trans, img_metas] - - # coor = self.get_lidar_coor(*sensor_config) - # # tmpgeom = self.get_geometry( - # # fH, - # # fW, - # # mylidar2img, - # # img_metas, - # # ) - - coor = self.get_geometry_v1( - fH, - fW, - rots, - trans, - intrins, - post_rots, - post_trans, - lidar2ego_rots, - lidar2ego_trans, - img_metas - ) - mlp_input = self.get_mlp_input(camera2ego, camera_intrinsics, post_rots, post_trans) - tran_feat, depth = self.get_cam_feats(images, mlp_input) - - bev_feat = self.voxel_pooling_v2( - coor, depth, - tran_feat) - # x = self.bev_pool(geom, x) - # import ipdb;ipdb.set_trace() - # bev_feat = bev_feat.permute(0,1,3,2).contiguous() - - return bev_feat, depth - - - -class Mlp(nn.Module): - - def __init__(self, - in_features, - hidden_features=None, - out_features=None, - act_layer=nn.ReLU, - drop=0.0): - super().__init__() - out_features = out_features or in_features - hidden_features = hidden_features or in_features - self.fc1 = nn.Linear(in_features, hidden_features) - self.act = act_layer() - self.drop1 = nn.Dropout(drop) - self.fc2 = nn.Linear(hidden_features, out_features) - self.drop2 = nn.Dropout(drop) - - def forward(self, x): - x = self.fc1(x) - x = self.act(x) - x = self.drop1(x) - x = self.fc2(x) - x = self.drop2(x) - return x - - -class SELayer(nn.Module): - - def __init__(self, channels, act_layer=nn.ReLU, gate_layer=nn.Sigmoid): - super().__init__() - self.conv_reduce = nn.Conv2d(channels, channels, 1, bias=True) - self.act1 = act_layer() - self.conv_expand = nn.Conv2d(channels, channels, 1, bias=True) - self.gate = gate_layer() - - def forward(self, x, x_se): - x_se = self.conv_reduce(x_se) - x_se = self.act1(x_se) - x_se = self.conv_expand(x_se) - return x * self.gate(x_se) - -class DepthNet(nn.Module): - - def __init__(self, - in_channels, - mid_channels, - context_channels, - depth_channels, - use_dcn=True, - use_aspp=True, - with_cp=False, - aspp_mid_channels=-1, - only_depth=False): - super(DepthNet, self).__init__() - self.reduce_conv = nn.Sequential( - nn.Conv2d( - in_channels, mid_channels, kernel_size=3, stride=1, padding=1), - nn.BatchNorm2d(mid_channels), - nn.ReLU(inplace=True), - ) - self.only_depth = only_depth or context_channels == 0 - if not self.only_depth: - self.context_conv = nn.Conv2d( - mid_channels, context_channels, kernel_size=1, stride=1, padding=0) - self.context_mlp = Mlp(22, mid_channels, mid_channels) - self.context_se = SELayer(mid_channels) # NOTE: add camera-aware - self.bn = nn.BatchNorm1d(22) - self.depth_mlp = Mlp(22, mid_channels, mid_channels) - self.depth_se = SELayer(mid_channels) # NOTE: add camera-aware - - depth_conv_list = [ - BasicBlock(mid_channels, mid_channels), - BasicBlock(mid_channels, mid_channels), - BasicBlock(mid_channels, mid_channels), - ] - if use_aspp: - if aspp_mid_channels<0: - aspp_mid_channels = mid_channels - depth_conv_list.append(ASPP(mid_channels, aspp_mid_channels)) - if use_dcn: - depth_conv_list.append( - build_conv_layer( - cfg=dict( - type='DCN', - in_channels=mid_channels, - out_channels=mid_channels, - kernel_size=3, - padding=1, - groups=4, - im2col_step=128, - ))) - depth_conv_list.append( - nn.Conv2d( - mid_channels, - depth_channels, - kernel_size=1, - stride=1, - padding=0)) - self.depth_conv = nn.Sequential(*depth_conv_list) - self.with_cp = with_cp - - def forward(self, x, mlp_input): - mlp_input = self.bn(mlp_input.reshape(-1, mlp_input.shape[-1])) - x = self.reduce_conv(x) - if not self.only_depth: - context_se = self.context_mlp(mlp_input)[..., None, None] - context = self.context_se(x, context_se) - context = self.context_conv(context) - depth_se = self.depth_mlp(mlp_input)[..., None, None] - depth = self.depth_se(x, depth_se) - if self.with_cp: - depth = checkpoint(self.depth_conv, depth) - else: - depth = self.depth_conv(depth) - if not self.only_depth: - return torch.cat([depth, context], dim=1) - else: - return depth - - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class BEVFormerEncoderDepth(BEVFormerEncoder): - - def __init__(self, *args, in_channels=256, out_channels=256, feat_down_sample=32, loss_depth_weight = 3.0, - depthnet_cfg=dict(),grid_config=None,**kwargs): - - super(BEVFormerEncoderDepth, self).__init__(*args, **kwargs) - - self.fp16_enabled = False - - self.loss_depth_weight = loss_depth_weight - self.feat_down_sample = feat_down_sample - self.grid_config = grid_config - self.D = int((grid_config['depth'][1] - grid_config['depth'][0]) / grid_config['depth'][2]) - self.depth_net = DepthNet(in_channels, in_channels, - 0, self.D, **depthnet_cfg) - - - @auto_fp16() - def forward(self, - bev_query, - key, - value, - *args, - mlvl_feats=None, - bev_h=None, - bev_w=None, - bev_pos=None, - spatial_shapes=None, - level_start_index=None, - valid_ratios=None, - prev_bev=None, - shift=0., - **kwargs): - """Forward function for `TransformerDecoder`. - Args: - bev_query (Tensor): Input BEV query with shape - `(num_query, bs, embed_dims)`. - key & value (Tensor): Input multi-cameta features with shape - (num_cam, num_value, bs, embed_dims) - reference_points (Tensor): The reference - points of offset. has shape - (bs, num_query, 4) when as_two_stage, - otherwise has shape ((bs, num_query, 2). - valid_ratios (Tensor): The radios of valid - points on the feature map, has shape - (bs, num_levels, 2) - Returns: - Tensor: Results with shape [1, num_query, bs, embed_dims] when - return_intermediate is `False`, otherwise it has shape - [num_layers, num_query, bs, embed_dims]. - """ - - bev_embed = super().forward( - bev_query, - key, - value, - bev_h=bev_h, - bev_w=bev_w, - bev_pos=bev_pos, - spatial_shapes=spatial_shapes, - level_start_index=level_start_index, - prev_bev=prev_bev, - shift=shift, - **kwargs) - # import ipdb; ipdb.set_trace() - images = mlvl_feats[0] - img_metas = kwargs['img_metas'] - B, N, C, fH, fW = images.shape - lidar2img = [] - camera2ego = [] - camera_intrinsics = [] - img_aug_matrix = [] - lidar2ego = [] - - for img_meta in img_metas: - lidar2img.append(img_meta['lidar2img']) - camera2ego.append(img_meta['camera2ego']) - camera_intrinsics.append(img_meta['camera_intrinsics']) - img_aug_matrix.append(img_meta['img_aug_matrix']) - lidar2ego.append(img_meta['lidar2ego']) - lidar2img = np.asarray(lidar2img) - lidar2img = images.new_tensor(lidar2img) # (B, N, 4, 4) - camera2ego = np.asarray(camera2ego) - camera2ego = images.new_tensor(camera2ego) # (B, N, 4, 4) - camera_intrinsics = np.asarray(camera_intrinsics) - camera_intrinsics = images.new_tensor(camera_intrinsics) # (B, N, 4, 4) - img_aug_matrix = np.asarray(img_aug_matrix) - img_aug_matrix = images.new_tensor(img_aug_matrix) # (B, N, 4, 4) - lidar2ego = np.asarray(lidar2ego) - lidar2ego = images.new_tensor(lidar2ego) # (B, N, 4, 4) - - rots = camera2ego[..., :3, :3] - trans = camera2ego[..., :3, 3] - intrins = camera_intrinsics[..., :3, :3] - post_rots = img_aug_matrix[..., :3, :3] - post_trans = img_aug_matrix[..., :3, 3] - lidar2ego_rots = lidar2ego[..., :3, :3] - lidar2ego_trans = lidar2ego[..., :3, 3] - - mlp_input = self.get_mlp_input(camera2ego, camera_intrinsics, post_rots, post_trans) - depth = self.get_cam_feats(images, mlp_input) - ret_dict = dict( - bev=bev_embed['bev'], - depth=depth, - ) - # import ipdb; ipdb.set_trace() - return ret_dict - - @force_fp32() - def get_cam_feats(self, x, mlp_input): - B, N, C, fH, fW = x.shape - - x = x.view(B * N, C, fH, fW) - - x = self.depth_net(x, mlp_input) - depth = x[:, : self.D].softmax(dim=1) - depth = depth.view(B, N, self.D, fH, fW) - return depth - def get_downsampled_gt_depth(self, gt_depths): - """ - Input: - gt_depths: [B, N, H, W] - Output: - gt_depths: [B*N*h*w, d] - """ - B, N, H, W = gt_depths.shape - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - self.feat_down_sample, W // self.feat_down_sample, - self.feat_down_sample, 1) - gt_depths = gt_depths.permute(0, 1, 3, 5, 2, 4).contiguous() - gt_depths = gt_depths.view(-1, self.feat_down_sample * self.feat_down_sample) - # 把gt_depth做feat_down_sample倍数的采样 - gt_depths_tmp = torch.where(gt_depths == 0.0, - 1e5 * torch.ones_like(gt_depths), - gt_depths) - # 因为深度很稀疏,大部分的点都是0,所以把0变成10000,下一步取-1维度上的最小就是深度的值 - gt_depths = torch.min(gt_depths_tmp, dim=-1).values - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - W // self.feat_down_sample) - - gt_depths = ( - gt_depths - - (self.grid_config['depth'][0] - - self.grid_config['depth'][2])) / self.grid_config['depth'][2] - gt_depths = torch.where((gt_depths < self.D + 1) & (gt_depths >= 0.0), - gt_depths, torch.zeros_like(gt_depths)) - gt_depths = F.one_hot( - gt_depths.long(), num_classes=self.D + 1).view(-1, self.D + 1)[:, - 1:] - return gt_depths.float() - - - @force_fp32() - def get_depth_loss(self, depth_labels, depth_preds): - # import pdb;pdb.set_trace() - if depth_preds is None: - return 0 - - depth_labels = self.get_downsampled_gt_depth(depth_labels) - depth_preds = depth_preds.permute(0, 1, 3, 4, 2).contiguous().view(-1, self.D) - # fg_mask = torch.max(depth_labels, dim=1).values > 0.0 # 只计算有深度的前景的深度loss - # import pdb;pdb.set_trace() - fg_mask = depth_labels > 0.0 # 只计算有深度的前景的深度loss - depth_labels = depth_labels[fg_mask] - depth_preds = depth_preds[fg_mask] - with autocast(enabled=False): - depth_loss = F.binary_cross_entropy( - depth_preds, - depth_labels, - reduction='none', - ).sum() / max(1.0, fg_mask.sum()) - # if depth_loss <= 0.: - # import pdb;pdb.set_trace() - return self.loss_depth_weight * depth_loss - - def get_mlp_input(self, sensor2ego, intrin, post_rot, post_tran): - B, N, _, _ = sensor2ego.shape - mlp_input = torch.stack([ - intrin[:, :, 0, 0], - intrin[:, :, 1, 1], - intrin[:, :, 0, 2], - intrin[:, :, 1, 2], - post_rot[:, :, 0, 0], - post_rot[:, :, 0, 1], - post_tran[:, :, 0], - post_rot[:, :, 1, 0], - post_rot[:, :, 1, 1], - post_tran[:, :, 1], - ], dim=-1) - sensor2ego = sensor2ego[:,:,:3,:].reshape(B, N, -1) - mlp_input = torch.cat([mlp_input, sensor2ego], dim=-1) - return mlp_input - - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class LSSTransform(BaseTransform): - def __init__( - self, - in_channels, - out_channels, - feat_down_sample, - pc_range, - voxel_size, - dbound, - downsample=1, - loss_depth_weight = 3.0, - depthnet_cfg=dict(), - grid_config=None, - ): - super(LSSTransform, self).__init__( - in_channels=in_channels, - out_channels=out_channels, - feat_down_sample=feat_down_sample, - pc_range=pc_range, - voxel_size=voxel_size, - dbound=dbound, - ) - # import pdb;pdb.set_trace() - self.loss_depth_weight = loss_depth_weight - self.grid_config = grid_config - self.depth_net = DepthNet(in_channels, in_channels, - self.C, self.D, **depthnet_cfg) - if downsample > 1: - assert downsample == 2, downsample - self.downsample = nn.Sequential( - nn.Conv2d(out_channels, out_channels, 3, padding=1, bias=False), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - nn.Conv2d( - out_channels, - out_channels, - 3, - stride=downsample, - padding=1, - bias=False, - ), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - nn.Conv2d(out_channels, out_channels, 3, padding=1, bias=False), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - ) - else: - self.downsample = nn.Identity() - - #@torch.compile(mode="max-autotune-no-cudagraphs") - @force_fp32() - def get_cam_feats(self, x, mlp_input): - B, N, C, fH, fW = x.shape - - x = x.view(B * N, C, fH, fW) - - x = self.depth_net(x, mlp_input) - depth = x[:, : self.D].softmax(dim=1) - x = depth.unsqueeze(1) * x[:, self.D : (self.D + self.C)].unsqueeze(2) - - x = x.view(B, N, self.C, self.D, fH, fW) - x = x.permute(0, 1, 3, 4, 5, 2) - depth = depth.view(B, N, self.D, fH, fW) - return x, depth - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def down_sample(self, x): - input = x - B, N, H, W, C = x.shape - x = x.permute(0, 4, 1, 2, 3).contiguous() - x = torch.cat(x.unbind(dim=2), 1) - x = x.permute(0,1,3,2).contiguous() - return self.downsample(x) - - def forward(self, images, img_metas): - x, depth = super().forward(images, img_metas) - # x = self.downsample(x) - x = self.down_sample(x) - ret_dict = dict( - bev=x, - depth=depth, - ) - return ret_dict - - def get_downsampled_gt_depth(self, gt_depths): - """ - Input: - gt_depths: [B, N, H, W] - Output: - gt_depths: [B*N*h*w, d] - """ - B, N, H, W = gt_depths.shape - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - self.feat_down_sample, W // self.feat_down_sample, - self.feat_down_sample, 1) - gt_depths = gt_depths.permute(0, 1, 3, 5, 2, 4).contiguous() - gt_depths = gt_depths.view(-1, self.feat_down_sample * self.feat_down_sample) - # 把gt_depth做feat_down_sample倍数的采样 - gt_depths_tmp = torch.where(gt_depths == 0.0, - 1e5 * torch.ones_like(gt_depths), - gt_depths) - # 因为深度很稀疏,大部分的点都是0,所以把0变成10000,下一步取-1维度上的最小就是深度的值 - gt_depths = torch.min(gt_depths_tmp, dim=-1).values - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - W // self.feat_down_sample) - - gt_depths = ( - gt_depths - - (self.grid_config['depth'][0] - - self.grid_config['depth'][2])) / self.grid_config['depth'][2] - gt_depths = torch.where((gt_depths < self.D + 1) & (gt_depths >= 0.0), - gt_depths, torch.zeros_like(gt_depths)) - gt_depths = F.one_hot( - gt_depths.long(), num_classes=self.D + 1).view(-1, self.D + 1)[:, - 1:] - return gt_depths.float() - - @force_fp32() - def get_depth_loss(self, depth_labels, depth_preds): - # import pdb;pdb.set_trace() - if depth_preds is None: - return 0 - - depth_labels = self.get_downsampled_gt_depth(depth_labels) - depth_preds = depth_preds.permute(0, 1, 3, 4, 2).contiguous().view(-1, self.D) - # fg_mask = torch.max(depth_labels, dim=1).values > 0.0 # 只计算有深度的前景的深度loss - # import pdb;pdb.set_trace() - fg_mask = depth_labels > 0.0 # 只计算有深度的前景的深度loss - depth_labels = depth_labels[fg_mask] - depth_preds = depth_preds[fg_mask] - with autocast(enabled=False): - depth_loss = F.binary_cross_entropy( - depth_preds, - depth_labels, - reduction='none', - ).sum() / max(1.0, fg_mask.sum()) - # if depth_loss <= 0.: - # import pdb;pdb.set_trace() - return self.loss_depth_weight * depth_loss - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def get_mlp_input(self, sensor2ego, intrin, post_rot, post_tran): - B, N, _, _ = sensor2ego.shape - mlp_input = torch.stack([ - intrin[:, :, 0, 0], - intrin[:, :, 1, 1], - intrin[:, :, 0, 2], - intrin[:, :, 1, 2], - post_rot[:, :, 0, 0], - post_rot[:, :, 0, 1], - post_tran[:, :, 0], - post_rot[:, :, 1, 0], - post_rot[:, :, 1, 1], - post_tran[:, :, 1], - ], dim=-1) - sensor2ego = sensor2ego[:,:,:3,:].reshape(B, N, -1) - mlp_input = torch.cat([mlp_input, sensor2ego], dim=-1) - return mlp_input - - -@TRANSFORMER_LAYER_SEQUENCE.register_module() -class LSSTransformV2(BaseTransformV2): - def __init__( - self, - input_size, - in_channels, - out_channels, - feat_down_sample, - pc_range, - voxel_size, - dbound, - downsample=1, - loss_depth_weight = 3.0, - depthnet_cfg=dict(), - grid_config = None, - sid=False, - ): - super(LSSTransformV2, self).__init__( - input_size=input_size, - in_channels=in_channels, - out_channels=out_channels, - feat_down_sample=feat_down_sample, - pc_range=pc_range, - voxel_size=voxel_size, - dbound=dbound, - sid=sid, - ) - self.loss_depth_weight = loss_depth_weight - self.grid_config = grid_config - self.depth_net = DepthNet(self.in_channels, self.in_channels, - self.C, self.D, **depthnet_cfg) - if downsample > 1: - assert downsample == 2, downsample - self.downsample = nn.Sequential( - nn.Conv2d(out_channels, out_channels, 3, padding=1, bias=False), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - nn.Conv2d( - out_channels, - out_channels, - 3, - stride=downsample, - padding=1, - bias=False, - ), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - nn.Conv2d(out_channels, out_channels, 3, padding=1, bias=False), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - ) - else: - self.downsample = nn.Identity() - - @force_fp32() - def get_cam_feats(self, x, mlp_input): - B, N, C, fH, fW = x.shape - x = x.view(B * N, C, fH, fW) - x = self.depth_net(x, mlp_input) - depth = x[:, : self.D].softmax(dim=1) - tran_feat = x[:, self.D : (self.D + self.C)] - - tran_feat = tran_feat.view(B, N, self.C, fH, fW) - # x = x.permute(0, 1, 3, 4, 5, 2) - depth = depth.view(B, N, self.D, fH, fW) - return tran_feat, depth - - def forward(self, images, img_metas): - x, depth = super().forward(images, img_metas) - x = self.downsample(x) - ret_dict = dict( - bev=x, - depth=depth, - ) - return ret_dict - - def get_downsampled_gt_depth(self, gt_depths): - """ - Input: - gt_depths: [B, N, H, W] - Output: - gt_depths: [B*N*h*w, d] - """ - B, N, H, W = gt_depths.shape - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - self.feat_down_sample, W // self.feat_down_sample, - self.feat_down_sample, 1) - gt_depths = gt_depths.permute(0, 1, 3, 5, 2, 4).contiguous() - gt_depths = gt_depths.view(-1, self.feat_down_sample * self.feat_down_sample) - # 把gt_depth做feat_down_sample倍数的采样 - gt_depths_tmp = torch.where(gt_depths == 0.0, - 1e5 * torch.ones_like(gt_depths), - gt_depths) - # 因为深度很稀疏,大部分的点都是0,所以把0变成10000,下一步取-1维度上的最小就是深度的值 - gt_depths = torch.min(gt_depths_tmp, dim=-1).values - gt_depths = gt_depths.view(B * N, H // self.feat_down_sample, - W // self.feat_down_sample) - - gt_depths = ( - gt_depths - - (self.grid_config['depth'][0] - - self.grid_config['depth'][2])) / self.grid_config['depth'][2] - gt_depths = torch.where((gt_depths < self.D + 1) & (gt_depths >= 0.0), - gt_depths, torch.zeros_like(gt_depths)) - gt_depths = F.one_hot( - gt_depths.long(), num_classes=self.D + 1).view(-1, self.D + 1)[:, - 1:] - return gt_depths.float() - - @force_fp32() - def get_depth_loss(self, depth_labels, depth_preds): - # import pdb;pdb.set_trace() - if depth_preds is None: - return 0 - - depth_labels = self.get_downsampled_gt_depth(depth_labels) - depth_preds = depth_preds.permute(0, 1, 3, 4, 2).contiguous().view(-1, self.D) - # fg_mask = torch.max(depth_labels, dim=1).values > 0.0 # 只计算有深度的前景的深度loss - # import pdb;pdb.set_trace() - fg_mask = depth_labels > 0.0 # 只计算有深度的前景的深度loss - depth_labels = depth_labels[fg_mask] - depth_preds = depth_preds[fg_mask] - with autocast(enabled=False): - depth_loss = F.binary_cross_entropy( - depth_preds, - depth_labels, - reduction='none', - ).sum() / max(1.0, fg_mask.sum()) - # if depth_loss <= 0.: - # import pdb;pdb.set_trace() - return self.loss_depth_weight * depth_loss - - - def get_mlp_input(self, sensor2ego, intrin, post_rot, post_tran): - B, N, _, _ = sensor2ego.shape - mlp_input = torch.stack([ - intrin[:, :, 0, 0], - intrin[:, :, 1, 1], - intrin[:, :, 0, 2], - intrin[:, :, 1, 2], - post_rot[:, :, 0, 0], - post_rot[:, :, 0, 1], - post_tran[:, :, 0], - post_rot[:, :, 1, 0], - post_rot[:, :, 1, 1], - post_tran[:, :, 1], - ], dim=-1) - sensor2ego = sensor2ego[:,:,:3,:].reshape(B, N, -1) - mlp_input = torch.cat([mlp_input, sensor2ego], dim=-1) - return mlp_input - -class _ASPPModule(nn.Module): - - def __init__(self, inplanes, planes, kernel_size, padding, dilation, - BatchNorm): - super(_ASPPModule, self).__init__() - self.atrous_conv = nn.Conv2d( - inplanes, - planes, - kernel_size=kernel_size, - stride=1, - padding=padding, - dilation=dilation, - bias=False) - self.bn = BatchNorm(planes) - self.relu = nn.ReLU() - - self._init_weight() - - def forward(self, x): - x = self.atrous_conv(x) - x = self.bn(x) - - return self.relu(x) - - def _init_weight(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - torch.nn.init.kaiming_normal_(m.weight) - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - m.bias.data.zero_() - - -class ASPP(nn.Module): - - def __init__(self, inplanes, mid_channels=256, BatchNorm=nn.BatchNorm2d): - super(ASPP, self).__init__() - - dilations = [1, 6, 12, 18] - - self.aspp1 = _ASPPModule( - inplanes, - mid_channels, - 1, - padding=0, - dilation=dilations[0], - BatchNorm=BatchNorm) - self.aspp2 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[1], - dilation=dilations[1], - BatchNorm=BatchNorm) - self.aspp3 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[2], - dilation=dilations[2], - BatchNorm=BatchNorm) - self.aspp4 = _ASPPModule( - inplanes, - mid_channels, - 3, - padding=dilations[3], - dilation=dilations[3], - BatchNorm=BatchNorm) - - self.global_avg_pool = nn.Sequential( - nn.AdaptiveAvgPool2d((1, 1)), - nn.Conv2d(inplanes, mid_channels, 1, stride=1, bias=False), - BatchNorm(mid_channels), - nn.ReLU(), - ) - self.conv1 = nn.Conv2d( - int(mid_channels * 5), inplanes, 1, bias=False) - self.bn1 = BatchNorm(inplanes) - self.relu = nn.ReLU() - self.dropout = nn.Dropout(0.5) - self._init_weight() - - def forward(self, x): - x1 = self.aspp1(x) - x2 = self.aspp2(x) - x3 = self.aspp3(x) - x4 = self.aspp4(x) - x5 = self.global_avg_pool(x) - x5 = F.interpolate( - x5, size=x4.size()[2:], mode='bilinear', align_corners=True) - x = torch.cat((x1, x2, x3, x4, x5), dim=1) - - x = self.conv1(x) - x = self.bn1(x) - x = self.relu(x) - - return self.dropout(x) - - def _init_weight(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - torch.nn.init.kaiming_normal_(m.weight) - elif isinstance(m, nn.BatchNorm2d): - m.weight.data.fill_(1) - m.bias.data.zero_() - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/__init__.py deleted file mode 100644 index 7578beb75c41d3a145992e9ef3663c88fd556d6d..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .function import GeometricKernelAttentionFunc \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.cu b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.cu deleted file mode 100644 index 2e0e3ab7d4f26c07254115ea4cbb8193d3966d50..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.cu +++ /dev/null @@ -1,144 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include "geometric_kernel_attn_cuda_kernel.cuh" - - -at::Tensor geometric_kernel_attn_cuda_forward( - const at::Tensor &value, - const at::Tensor &spatial_shapes, - const at::Tensor &level_start_index, - const at::Tensor &sampling_loc, - const at::Tensor &attn_weight, - const int im2col_step) { - - AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); - AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); - AT_ASSERTM(level_start_index.is_contiguous(), "level_start_index tensor has to be contiguous"); - AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); - AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); - - AT_ASSERTM(value.type().is_cuda(), "value must be a CUDA tensor"); - AT_ASSERTM(spatial_shapes.type().is_cuda(), "spatial_shapes must be a CUDA tensor"); - AT_ASSERTM(level_start_index.type().is_cuda(), "level_start_index must be a CUDA tensor"); - AT_ASSERTM(sampling_loc.type().is_cuda(), "sampling_loc must be a CUDA tensor"); - AT_ASSERTM(attn_weight.type().is_cuda(), "attn_weight must be a CUDA tensor"); - - const int batch = value.size(0); - const int spatial_size = value.size(1); - const int num_heads = value.size(2); - const int channels = value.size(3); - - const int num_levels = spatial_shapes.size(0); - - const int num_query = sampling_loc.size(1); - const int num_point = sampling_loc.size(4); - - const int im2col_step_ = std::min(batch, im2col_step); - - AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); - - auto output = at::zeros({batch, num_query, num_heads, channels}, value.options()); - - const int batch_n = im2col_step_; - auto output_n = output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); - auto per_value_size = spatial_size * num_heads * channels; - auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; - auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; - for (int n = 0; n < batch/im2col_step_; ++n) - { - auto columns = output_n.select(0, n); - AT_DISPATCH_FLOATING_TYPES(value.type(), "multiscale_kernel_attn_forward_cuda", ([&] { - multiscale_kernel_attn_forward_cuda(at::cuda::getCurrentCUDAStream(), - value.data() + n * im2col_step_ * per_value_size, - spatial_shapes.data(), - level_start_index.data(), - sampling_loc.data() + n * im2col_step_ * per_sample_loc_size, - attn_weight.data() + n * im2col_step_ * per_attn_weight_size, - batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, - columns.data()); - - })); - } - - output = output.view({batch, num_query, num_heads*channels}); - - return output; - -} - -std::vector geometric_kernel_attn_cuda_backward( - const at::Tensor &value, - const at::Tensor &spatial_shapes, - const at::Tensor &level_start_index, - const at::Tensor &sampling_loc, - const at::Tensor &attn_weight, - const at::Tensor &grad_output, - const int im2col_step) { - - AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); - AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); - AT_ASSERTM(level_start_index.is_contiguous(), "level_start_index tensor has to be contiguous"); - AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); - AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); - AT_ASSERTM(grad_output.is_contiguous(), "grad_output tensor has to be contiguous"); - - AT_ASSERTM(value.type().is_cuda(), "value must be a CUDA tensor"); - AT_ASSERTM(spatial_shapes.type().is_cuda(), "spatial_shapes must be a CUDA tensor"); - AT_ASSERTM(level_start_index.type().is_cuda(), "level_start_index must be a CUDA tensor"); - AT_ASSERTM(sampling_loc.type().is_cuda(), "sampling_loc must be a CUDA tensor"); - AT_ASSERTM(attn_weight.type().is_cuda(), "attn_weight must be a CUDA tensor"); - AT_ASSERTM(grad_output.type().is_cuda(), "grad_output must be a CUDA tensor"); - - - const int batch = value.size(0); - const int spatial_size = value.size(1); - const int num_heads = value.size(2); - const int channels = value.size(3); - - const int num_levels = spatial_shapes.size(0); - - const int num_query = sampling_loc.size(1); - const int num_point = sampling_loc.size(4); - - const int im2col_step_ = std::min(batch, im2col_step); - - AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); - - auto grad_value = at::zeros_like(value); - auto grad_attn_weight = at::zeros_like(attn_weight); - - const int batch_n = im2col_step_; - auto per_value_size = spatial_size * num_heads * channels; - auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; - auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; - auto grad_output_n = grad_output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); - - for (int n = 0; n < batch/im2col_step_; ++n) - { - auto grad_output_g = grad_output_n.select(0, n); - AT_DISPATCH_FLOATING_TYPES(value.type(), "multiscale_kernel_attn_backward_cuda", ([&] { - multiscale_kernel_attn_backward_cuda(at::cuda::getCurrentCUDAStream(), - grad_output_g.data(), - value.data() + n * im2col_step_ * per_value_size, - spatial_shapes.data(), - level_start_index.data(), - sampling_loc.data() + n * im2col_step_ * per_sample_loc_size, - attn_weight.data() + n * im2col_step_ * per_attn_weight_size, - batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, - grad_value.data() + n * im2col_step_ * per_value_size, - grad_attn_weight.data() + n * im2col_step_ * per_attn_weight_size); - - })); - } - - return { - grad_value, grad_attn_weight - }; - -} diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.hip b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.hip deleted file mode 100644 index e1bf1463b57f87ab5bbc9d59a166f3f1a433d7ce..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda.hip +++ /dev/null @@ -1,146 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include -#include -#include - -#include -#include - -#include "geometric_kernel_attn_hip_kernel.cuh" - - -at::Tensor geometric_kernel_attn_cuda_forward( - const at::Tensor &value, - const at::Tensor &spatial_shapes, - const at::Tensor &level_start_index, - const at::Tensor &sampling_loc, - const at::Tensor &attn_weight, - const int im2col_step) { - - AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); - AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); - AT_ASSERTM(level_start_index.is_contiguous(), "level_start_index tensor has to be contiguous"); - AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); - AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); - - AT_ASSERTM(value.type().is_cuda(), "value must be a CUDA tensor"); - AT_ASSERTM(spatial_shapes.type().is_cuda(), "spatial_shapes must be a CUDA tensor"); - AT_ASSERTM(level_start_index.type().is_cuda(), "level_start_index must be a CUDA tensor"); - AT_ASSERTM(sampling_loc.type().is_cuda(), "sampling_loc must be a CUDA tensor"); - AT_ASSERTM(attn_weight.type().is_cuda(), "attn_weight must be a CUDA tensor"); - - const int batch = value.size(0); - const int spatial_size = value.size(1); - const int num_heads = value.size(2); - const int channels = value.size(3); - - const int num_levels = spatial_shapes.size(0); - - const int num_query = sampling_loc.size(1); - const int num_point = sampling_loc.size(4); - - const int im2col_step_ = ::min(batch, im2col_step); - - AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); - - auto output = at::zeros({batch, num_query, num_heads, channels}, value.options()); - - const int batch_n = im2col_step_; - auto output_n = output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); - auto per_value_size = spatial_size * num_heads * channels; - auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; - auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; - for (int n = 0; n < batch/im2col_step_; ++n) - { - auto columns = output_n.select(0, n); - AT_DISPATCH_FLOATING_TYPES(value.type(), "multiscale_kernel_attn_forward_cuda", ([&] { - multiscale_kernel_attn_forward_cuda(at::hip::getCurrentHIPStreamMasqueradingAsCUDA(), - value.data() + n * im2col_step_ * per_value_size, - spatial_shapes.data(), - level_start_index.data(), - sampling_loc.data() + n * im2col_step_ * per_sample_loc_size, - attn_weight.data() + n * im2col_step_ * per_attn_weight_size, - batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, - columns.data()); - - })); - } - - output = output.view({batch, num_query, num_heads*channels}); - - return output; - -} - -std::vector geometric_kernel_attn_cuda_backward( - const at::Tensor &value, - const at::Tensor &spatial_shapes, - const at::Tensor &level_start_index, - const at::Tensor &sampling_loc, - const at::Tensor &attn_weight, - const at::Tensor &grad_output, - const int im2col_step) { - - AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); - AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); - AT_ASSERTM(level_start_index.is_contiguous(), "level_start_index tensor has to be contiguous"); - AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); - AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); - AT_ASSERTM(grad_output.is_contiguous(), "grad_output tensor has to be contiguous"); - - AT_ASSERTM(value.type().is_cuda(), "value must be a CUDA tensor"); - AT_ASSERTM(spatial_shapes.type().is_cuda(), "spatial_shapes must be a CUDA tensor"); - AT_ASSERTM(level_start_index.type().is_cuda(), "level_start_index must be a CUDA tensor"); - AT_ASSERTM(sampling_loc.type().is_cuda(), "sampling_loc must be a CUDA tensor"); - AT_ASSERTM(attn_weight.type().is_cuda(), "attn_weight must be a CUDA tensor"); - AT_ASSERTM(grad_output.type().is_cuda(), "grad_output must be a CUDA tensor"); - - - const int batch = value.size(0); - const int spatial_size = value.size(1); - const int num_heads = value.size(2); - const int channels = value.size(3); - - const int num_levels = spatial_shapes.size(0); - - const int num_query = sampling_loc.size(1); - const int num_point = sampling_loc.size(4); - - const int im2col_step_ = ::min(batch, im2col_step); - - AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); - - auto grad_value = at::zeros_like(value); - auto grad_attn_weight = at::zeros_like(attn_weight); - - const int batch_n = im2col_step_; - auto per_value_size = spatial_size * num_heads * channels; - auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; - auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; - auto grad_output_n = grad_output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); - - for (int n = 0; n < batch/im2col_step_; ++n) - { - auto grad_output_g = grad_output_n.select(0, n); - AT_DISPATCH_FLOATING_TYPES(value.type(), "multiscale_kernel_attn_backward_cuda", ([&] { - multiscale_kernel_attn_backward_cuda(at::hip::getCurrentHIPStreamMasqueradingAsCUDA(), - grad_output_g.data(), - value.data() + n * im2col_step_ * per_value_size, - spatial_shapes.data(), - level_start_index.data(), - sampling_loc.data() + n * im2col_step_ * per_sample_loc_size, - attn_weight.data() + n * im2col_step_ * per_attn_weight_size, - batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, - grad_value.data() + n * im2col_step_ * per_value_size, - grad_attn_weight.data() + n * im2col_step_ * per_attn_weight_size); - - })); - } - - return { - grad_value, grad_attn_weight - }; - -} diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda_kernel.cuh b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda_kernel.cuh deleted file mode 100644 index 7d6a77e1362eb023da47f41d4811322ac839ca70..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_cuda_kernel.cuh +++ /dev/null @@ -1,471 +0,0 @@ -#include -#include -#include - -#include -#include - -#include -#include - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -const int CUDA_NUM_THREADS = 1024; -inline int GET_BLOCKS(const int N, const int num_threads) { - return (N + num_threads - 1) / num_threads; -} - -__device__ int clip(int n, int lower, int upper) { - n = n >= lower ? n : lower; - return n < upper ? n : upper; -} - -template -__device__ scalar_t multi_scale_kernel_attn_sampling( - const scalar_t *&bottom_data, const int &height, const int &width, - const int &nheads, const int &channels, const int &h, - const int &w, const int &m, const int &c) { - const int w_stride = nheads * channels; - const int h_stride = width * w_stride; - - const int base_ptr = m * channels + c; - const int h_ptr_offset = h_stride * h; - const int w_ptr_offset = w_stride * w; - scalar_t val = bottom_data[base_ptr + h_ptr_offset + w_ptr_offset]; - - return val; -} - -template -__device__ void multiscale_kernel_attn_sampling_backward( - const scalar_t *&bottom_data, const int &height, const int &width, - const int &nheads, const int &channels, const int &h, - const int &w, const int &m, const int &c, const scalar_t &top_grad, - const scalar_t &attn_weight, scalar_t *&grad_value, scalar_t *grad_attn_weight) { - - const int w_stride = nheads * channels; - const int h_stride = width * w_stride; - const int h_ptr_offset = h_stride * h; - const int w_ptr_offset = w_stride * w; - const int base_ptr = m * channels + c; - const scalar_t top_grad_value = top_grad * attn_weight; - // scalar_t grad_h_weight = 0, grad_w_weight = 0; - - const int ptr = base_ptr + h_ptr_offset + w_ptr_offset; - scalar_t val = bottom_data[ptr]; - atomicAdd(grad_value + ptr, top_grad_value); - *grad_attn_weight = top_grad * val; -} - - -template -__global__ void multiscale_kernel_attn_forward_gpu_kernel( - const int n, const scalar_t *data_value, const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, const int batch_size, - const int spatial_size, const int num_heads, const int channels, - const int num_levels, const int num_query, const int num_point, - scalar_t *data_col) { - CUDA_KERNEL_LOOP(index, n) { - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - scalar_t *data_col_ptr = data_col + index; - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - scalar_t col = 0; - - for (int l_col = 0; l_col < num_levels; ++l_col) { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const scalar_t *data_value_ptr = - data_value + - (data_value_ptr_init_offset + level_start_id * qid_stride); - for (int p_col = 0; p_col < num_point; ++p_col) { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - col += multi_scale_kernel_attn_sampling(data_value_ptr, spatial_h, spatial_w, num_heads, - channels, loc_h_, loc_w_, m_col, c_col) * weight; - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - } - } - *data_col_ptr = col; - } -} - -template -__global__ void multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2(const int n, - const scalar_t *grad_col, - const scalar_t *data_value, - const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, - const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t *grad_value, - scalar_t *grad_attn_weight) -{ - CUDA_KERNEL_LOOP(index, n) - { - __shared__ scalar_t cache_grad_attn_weight[blockSize]; - unsigned int tid = threadIdx.x; - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - const scalar_t top_grad = grad_col[index]; - - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int grad_sampling_ptr = data_weight_ptr; - // grad_sampling_loc += grad_sampling_ptr << 1; - grad_attn_weight += grad_sampling_ptr; - const int grad_weight_stride = 1; - // const int grad_loc_stride = 2; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - - for (int l_col=0; l_col < num_levels; ++l_col) - { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; - const scalar_t *data_value_ptr = data_value + value_ptr_offset; - scalar_t *grad_value_ptr = grad_value + value_ptr_offset; - - for (int p_col=0; p_col < num_point; ++p_col) - { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - *(cache_grad_attn_weight+threadIdx.x)=0; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - multiscale_kernel_attn_sampling_backward( - data_value_ptr, spatial_h, spatial_w, num_heads, channels, loc_h_, loc_w_, m_col, c_col, - top_grad, weight, grad_value_ptr, cache_grad_attn_weight+threadIdx.x); - __syncthreads(); - - for (unsigned int s=blockSize/2; s>0; s>>=1) - { - if (tid < s) { - // const unsigned int xid1 = tid << 1; - //const unsigned int xid2 = (tid + s) << 1; - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; - } - __syncthreads(); - } - - if (tid == 0) - { - *grad_attn_weight = cache_grad_attn_weight[0]; - } - __syncthreads(); - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - grad_attn_weight += grad_weight_stride; - } - } - } -} - - -template -__global__ void multiscale_kernel_attn_backward_gpu_kernel_shm_reduce_v2( - const int n, - const scalar_t *grad_col, - const scalar_t *data_value, - const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, - const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t *grad_value, - scalar_t *grad_attn_weight) -{ - CUDA_KERNEL_LOOP(index, n) - { - extern __shared__ int _s[]; - scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; - scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; - unsigned int tid = threadIdx.x; - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - const scalar_t top_grad = grad_col[index]; - - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int grad_sampling_ptr = data_weight_ptr; - // grad_sampling_loc += grad_sampling_ptr << 1; - grad_attn_weight += grad_sampling_ptr; - const int grad_weight_stride = 1; - // const int grad_loc_stride = 2; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - - for (int l_col=0; l_col < num_levels; ++l_col) - { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; - const scalar_t *data_value_ptr = data_value + value_ptr_offset; - scalar_t *grad_value_ptr = grad_value + value_ptr_offset; - - for (int p_col=0; p_col < num_point; ++p_col) - { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - *(cache_grad_attn_weight+threadIdx.x)=0; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - multiscale_kernel_attn_sampling_backward( - data_value_ptr, spatial_h, spatial_w, num_heads, channels, loc_h_, loc_w_, m_col, c_col, - top_grad, weight, grad_value_ptr, cache_grad_attn_weight+threadIdx.x); - __syncthreads(); - - for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) - { - if (tid < s) { - // const unsigned int xid1 = tid << 1; - // const unsigned int xid2 = (tid + s) << 1; - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; - if (tid + (s << 1) < spre) - { - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; - - } - } - __syncthreads(); - } - - if (tid == 0) - { - *grad_attn_weight = cache_grad_attn_weight[0]; - } - __syncthreads(); - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - grad_attn_weight += grad_weight_stride; - } - } - } -} - - -template -void multiscale_kernel_attn_forward_cuda(cudaStream_t stream, - const scalar_t* data_value, - const int64_t* data_spatial_shapes, - const int64_t* data_level_start_index, - const int64_t* data_sampling_loc, - const scalar_t* data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t* data_col) -{ - const int num_kernels = batch_size * num_query * num_heads * channels; - const int num_actual_kernels = batch_size * num_query * num_heads * channels; - const int num_threads = CUDA_NUM_THREADS; - multiscale_kernel_attn_forward_gpu_kernel - <<>>( - num_kernels, data_value, data_spatial_shapes, data_level_start_index, data_sampling_loc, data_attn_weight, - batch_size, spatial_size, num_heads, channels, num_levels, num_query, num_point, data_col); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in multiscale_kernel_attn_forward_cuda: %s\n", cudaGetErrorString(err)); - } - -} - - -template -void multiscale_kernel_attn_backward_cuda(cudaStream_t stream, - const scalar_t* grad_col, - const scalar_t* data_value, - const int64_t * data_spatial_shapes, - const int64_t * data_level_start_index, - const int64_t * data_sampling_loc, - const scalar_t * data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t* grad_value, - scalar_t* grad_attn_weight) -{ - const int num_threads = (channels > CUDA_NUM_THREADS)?CUDA_NUM_THREADS:channels; - const int num_kernels = batch_size * num_query * num_heads * channels; - const int num_actual_kernels = batch_size * num_query * num_heads * channels; - switch(channels) { - case 128: - multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2 - <<>>( - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 256: - multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2 - <<>>( - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 512: - multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2 - <<>>( - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 1024: - multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2 - <<>>( - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - default: - multiscale_kernel_attn_backward_gpu_kernel_shm_reduce_v2 - <<>>( - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - } - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in multiscale_kernel_attn_backward_cuda: %s\n", cudaGetErrorString(err)); - } - -} diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_hip_kernel.cuh b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_hip_kernel.cuh deleted file mode 100644 index 29657383095b06dab2b43d5519215fb250d498d6..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/ops/geometric_kernel_attn/src/geometric_kernel_attn_hip_kernel.cuh +++ /dev/null @@ -1,474 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include "hip/hip_runtime.h" -#include -#include -#include - -#include -#include - -#include -#include - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -const int CUDA_NUM_THREADS = 1024; -inline int GET_BLOCKS(const int N, const int num_threads) { - return (N + num_threads - 1) / num_threads; -} - -__device__ int clip(int n, int lower, int upper) { - n = n >= lower ? n : lower; - return n < upper ? n : upper; -} - -template -__device__ scalar_t multi_scale_kernel_attn_sampling( - const scalar_t *&bottom_data, const int &height, const int &width, - const int &nheads, const int &channels, const int &h, - const int &w, const int &m, const int &c) { - const int w_stride = nheads * channels; - const int h_stride = width * w_stride; - - const int base_ptr = m * channels + c; - const int h_ptr_offset = h_stride * h; - const int w_ptr_offset = w_stride * w; - scalar_t val = bottom_data[base_ptr + h_ptr_offset + w_ptr_offset]; - - return val; -} - -template -__device__ void multiscale_kernel_attn_sampling_backward( - const scalar_t *&bottom_data, const int &height, const int &width, - const int &nheads, const int &channels, const int &h, - const int &w, const int &m, const int &c, const scalar_t &top_grad, - const scalar_t &attn_weight, scalar_t *&grad_value, scalar_t *grad_attn_weight) { - - const int w_stride = nheads * channels; - const int h_stride = width * w_stride; - const int h_ptr_offset = h_stride * h; - const int w_ptr_offset = w_stride * w; - const int base_ptr = m * channels + c; - const scalar_t top_grad_value = top_grad * attn_weight; - // scalar_t grad_h_weight = 0, grad_w_weight = 0; - - const int ptr = base_ptr + h_ptr_offset + w_ptr_offset; - scalar_t val = bottom_data[ptr]; - atomicAdd(grad_value + ptr, top_grad_value); - *grad_attn_weight = top_grad * val; -} - - -template -__global__ void multiscale_kernel_attn_forward_gpu_kernel( - const int n, const scalar_t *data_value, const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, const int batch_size, - const int spatial_size, const int num_heads, const int channels, - const int num_levels, const int num_query, const int num_point, - scalar_t *data_col) { - CUDA_KERNEL_LOOP(index, n) { - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - scalar_t *data_col_ptr = data_col + index; - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - scalar_t col = 0; - - for (int l_col = 0; l_col < num_levels; ++l_col) { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const scalar_t *data_value_ptr = - data_value + - (data_value_ptr_init_offset + level_start_id * qid_stride); - for (int p_col = 0; p_col < num_point; ++p_col) { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - col += multi_scale_kernel_attn_sampling(data_value_ptr, spatial_h, spatial_w, num_heads, - channels, loc_h_, loc_w_, m_col, c_col) * weight; - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - } - } - *data_col_ptr = col; - } -} - -template -__global__ void multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2(const int n, - const scalar_t *grad_col, - const scalar_t *data_value, - const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, - const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t *grad_value, - scalar_t *grad_attn_weight) -{ - CUDA_KERNEL_LOOP(index, n) - { - __shared__ scalar_t cache_grad_attn_weight[blockSize]; - unsigned int tid = threadIdx.x; - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - const scalar_t top_grad = grad_col[index]; - - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int grad_sampling_ptr = data_weight_ptr; - // grad_sampling_loc += grad_sampling_ptr << 1; - grad_attn_weight += grad_sampling_ptr; - const int grad_weight_stride = 1; - // const int grad_loc_stride = 2; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - - for (int l_col=0; l_col < num_levels; ++l_col) - { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; - const scalar_t *data_value_ptr = data_value + value_ptr_offset; - scalar_t *grad_value_ptr = grad_value + value_ptr_offset; - - for (int p_col=0; p_col < num_point; ++p_col) - { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - *(cache_grad_attn_weight+threadIdx.x)=0; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - multiscale_kernel_attn_sampling_backward( - data_value_ptr, spatial_h, spatial_w, num_heads, channels, loc_h_, loc_w_, m_col, c_col, - top_grad, weight, grad_value_ptr, cache_grad_attn_weight+threadIdx.x); - __syncthreads(); - - for (unsigned int s=blockSize/2; s>0; s>>=1) - { - if (tid < s) { - // const unsigned int xid1 = tid << 1; - //const unsigned int xid2 = (tid + s) << 1; - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; - } - __syncthreads(); - } - - if (tid == 0) - { - *grad_attn_weight = cache_grad_attn_weight[0]; - } - __syncthreads(); - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - grad_attn_weight += grad_weight_stride; - } - } - } -} - - -template -__global__ void multiscale_kernel_attn_backward_gpu_kernel_shm_reduce_v2( - const int n, - const scalar_t *grad_col, - const scalar_t *data_value, - const int64_t *data_spatial_shapes, - const int64_t *data_level_start_index, - const int64_t *data_sampling_loc, - const scalar_t *data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t *grad_value, - scalar_t *grad_attn_weight) -{ - CUDA_KERNEL_LOOP(index, n) - { - extern __shared__ int _s[]; - scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; - scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; - unsigned int tid = threadIdx.x; - int _temp = index; - const int c_col = _temp % channels; - _temp /= channels; - const int sampling_index = _temp; - const int m_col = _temp % num_heads; - _temp /= num_heads; - const int q_col = _temp % num_query; - _temp /= num_query; - const int b_col = _temp; - - const scalar_t top_grad = grad_col[index]; - - int data_weight_ptr = sampling_index * num_levels * num_point; - int data_loc_w_ptr = data_weight_ptr << 1; - const int grad_sampling_ptr = data_weight_ptr; - // grad_sampling_loc += grad_sampling_ptr << 1; - grad_attn_weight += grad_sampling_ptr; - const int grad_weight_stride = 1; - // const int grad_loc_stride = 2; - const int qid_stride = num_heads * channels; - const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; - - for (int l_col=0; l_col < num_levels; ++l_col) - { - const int level_start_id = data_level_start_index[l_col]; - const int spatial_h_ptr = l_col << 1; - const int spatial_h = data_spatial_shapes[spatial_h_ptr]; - const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; - const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; - const scalar_t *data_value_ptr = data_value + value_ptr_offset; - scalar_t *grad_value_ptr = grad_value + value_ptr_offset; - - for (int p_col=0; p_col < num_point; ++p_col) - { - const int loc_w = data_sampling_loc[data_loc_w_ptr]; - const int loc_h = data_sampling_loc[data_loc_w_ptr + 1]; - const scalar_t weight = data_attn_weight[data_weight_ptr]; - *(cache_grad_attn_weight+threadIdx.x)=0; - const int loc_h_ = clip(loc_h, 0, spatial_h-1); - const int loc_w_ = clip(loc_w, 0, spatial_w-1); - multiscale_kernel_attn_sampling_backward( - data_value_ptr, spatial_h, spatial_w, num_heads, channels, loc_h_, loc_w_, m_col, c_col, - top_grad, weight, grad_value_ptr, cache_grad_attn_weight+threadIdx.x); - __syncthreads(); - - for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) - { - if (tid < s) { - // const unsigned int xid1 = tid << 1; - // const unsigned int xid2 = (tid + s) << 1; - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; - if (tid + (s << 1) < spre) - { - cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; - - } - } - __syncthreads(); - } - - if (tid == 0) - { - *grad_attn_weight = cache_grad_attn_weight[0]; - } - __syncthreads(); - - data_weight_ptr += 1; - data_loc_w_ptr += 2; - grad_attn_weight += grad_weight_stride; - } - } - } -} - - -template -void multiscale_kernel_attn_forward_cuda(hipStream_t stream, - const scalar_t* data_value, - const int64_t* data_spatial_shapes, - const int64_t* data_level_start_index, - const int64_t* data_sampling_loc, - const scalar_t* data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t* data_col) -{ - const int num_kernels = batch_size * num_query * num_heads * channels; - const int num_actual_kernels = batch_size * num_query * num_heads * channels; - const int num_threads = CUDA_NUM_THREADS; - hipLaunchKernelGGL(( multiscale_kernel_attn_forward_gpu_kernel) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads), - 0, stream, - num_kernels, data_value, data_spatial_shapes, data_level_start_index, data_sampling_loc, data_attn_weight, - batch_size, spatial_size, num_heads, channels, num_levels, num_query, num_point, data_col); - - hipError_t err = hipGetLastError(); - if (err != hipSuccess) - { - printf("error in multiscale_kernel_attn_forward_cuda: %s\n", hipGetErrorString(err)); - } - -} - - -template -void multiscale_kernel_attn_backward_cuda(hipStream_t stream, - const scalar_t* grad_col, - const scalar_t* data_value, - const int64_t * data_spatial_shapes, - const int64_t * data_level_start_index, - const int64_t * data_sampling_loc, - const scalar_t * data_attn_weight, - const int batch_size, - const int spatial_size, - const int num_heads, - const int channels, - const int num_levels, - const int num_query, - const int num_point, - scalar_t* grad_value, - scalar_t* grad_attn_weight) -{ - const int num_threads = (channels > CUDA_NUM_THREADS)?CUDA_NUM_THREADS:channels; - const int num_kernels = batch_size * num_query * num_heads * channels; - const int num_actual_kernels = batch_size * num_query * num_heads * channels; - switch(channels) { - case 128: - hipLaunchKernelGGL(( multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads), - 0, stream, - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 256: - hipLaunchKernelGGL(( multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads),0, stream, - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 512: - hipLaunchKernelGGL(( multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads), 0, stream, - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - case 1024: - hipLaunchKernelGGL(( multiscale_kernel_attn_backward_gpu_kernel_shm_blocksize_aware_reduce_v2) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads), 0, stream, - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - break; - default: - hipLaunchKernelGGL(( multiscale_kernel_attn_backward_gpu_kernel_shm_reduce_v2) - , dim3(GET_BLOCKS(num_actual_kernels, num_threads)), dim3(num_threads), num_threads*3*sizeof(scalar_t), stream, - num_kernels, - grad_col, - data_value, - data_spatial_shapes, - data_level_start_index, - data_sampling_loc, - data_attn_weight, - batch_size, - spatial_size, - num_heads, - channels, - num_levels, - num_query, - num_point, - grad_value, - grad_attn_weight); - } - - hipError_t err = hipGetLastError(); - if (err != hipSuccess) - { - printf("error in multiscale_kernel_attn_backward_cuda: %s\n", hipGetErrorString(err)); - } - -} diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/transformer.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/transformer.py deleted file mode 100644 index 6b1724ec42ab888b07ed4b480957a8cd23bcc865..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/maptr/modules/transformer.py +++ /dev/null @@ -1,433 +0,0 @@ -import copy -import torch -import torch.nn as nn -import numpy as np -from torch.nn.init import normal_ -import torch.nn.functional as F -from mmdet.models.utils.builder import TRANSFORMER -from mmcv.cnn import Linear, bias_init_with_prob, xavier_init, constant_init -from mmcv.runner.base_module import BaseModule, ModuleList, Sequential -from mmcv.cnn.bricks.transformer import build_transformer_layer_sequence -from torchvision.transforms.functional import rotate -from projects.mmdet3d_plugin.bevformer.modules.temporal_self_attention import TemporalSelfAttention -from projects.mmdet3d_plugin.bevformer.modules.spatial_cross_attention import MSDeformableAttention3D -from projects.mmdet3d_plugin.bevformer.modules.decoder import CustomMSDeformableAttention -from .builder import build_fuser, FUSERS -from typing import List - -@FUSERS.register_module() -class ConvFuser(nn.Sequential): - def __init__(self, in_channels: int, out_channels: int) -> None: - self.in_channels = in_channels - self.out_channels = out_channels - super().__init__( - nn.Conv2d(sum(in_channels), out_channels, 3, padding=1, bias=False), - nn.BatchNorm2d(out_channels), - nn.ReLU(True), - ) - - def forward(self, inputs: List[torch.Tensor]) -> torch.Tensor: - return super().forward(torch.cat(inputs, dim=1)) - - - -@TRANSFORMER.register_module() -class MapTRPerceptionTransformer(BaseModule): - """Implements the Detr3D transformer. - Args: - as_two_stage (bool): Generate query from encoder features. - Default: False. - num_feature_levels (int): Number of feature maps from FPN: - Default: 4. - two_stage_num_proposals (int): Number of proposals when set - `as_two_stage` as True. Default: 300. - """ - - def __init__(self, - num_feature_levels=4, - num_cams=6, - z_cfg=dict( - pred_z_flag=False, - gt_z_flag=False, - ), - two_stage_num_proposals=300, - fuser=None, - encoder=None, - decoder=None, - embed_dims=256, - rotate_prev_bev=True, - use_shift=True, - use_can_bus=True, - can_bus_norm=True, - use_cams_embeds=True, - rotate_center=[100, 100], - modality='vision', - feat_down_sample_indice=-1, - **kwargs): - super(MapTRPerceptionTransformer, self).__init__(**kwargs) - if modality == 'fusion': - self.fuser = build_fuser(fuser) #TODO - # self.use_attn_bev = encoder['type'] == 'BEVFormerEncoder' - self.use_attn_bev = 'BEVFormerEncoder' in encoder['type'] - self.encoder = build_transformer_layer_sequence(encoder) - self.decoder = build_transformer_layer_sequence(decoder) - self.embed_dims = embed_dims - self.num_feature_levels = num_feature_levels - self.num_cams = num_cams - self.fp16_enabled = False - - self.rotate_prev_bev = rotate_prev_bev - self.use_shift = use_shift - self.use_can_bus = use_can_bus - self.can_bus_norm = can_bus_norm - self.use_cams_embeds = use_cams_embeds - - self.two_stage_num_proposals = two_stage_num_proposals - self.z_cfg=z_cfg - self.init_layers() - self.rotate_center = rotate_center - self.feat_down_sample_indice = feat_down_sample_indice - - def init_layers(self): - """Initialize layers of the Detr3DTransformer.""" - self.level_embeds = nn.Parameter(torch.Tensor( - self.num_feature_levels, self.embed_dims)) - self.cams_embeds = nn.Parameter( - torch.Tensor(self.num_cams, self.embed_dims)) - self.reference_points = nn.Linear(self.embed_dims, 2) if not self.z_cfg['gt_z_flag'] \ - else nn.Linear(self.embed_dims, 3) - self.can_bus_mlp = nn.Sequential( - nn.Linear(18, self.embed_dims // 2), - nn.ReLU(inplace=True), - nn.Linear(self.embed_dims // 2, self.embed_dims), - nn.ReLU(inplace=True), - ) - if self.can_bus_norm: - self.can_bus_mlp.add_module('norm', nn.LayerNorm(self.embed_dims)) - - def init_weights(self): - """Initialize the transformer weights.""" - for p in self.parameters(): - if p.dim() > 1: - nn.init.xavier_uniform_(p) - for m in self.modules(): - if isinstance(m, MSDeformableAttention3D) or isinstance(m, TemporalSelfAttention) \ - or isinstance(m, CustomMSDeformableAttention): - try: - m.init_weight() - except AttributeError: - m.init_weights() - normal_(self.level_embeds) - normal_(self.cams_embeds) - xavier_init(self.reference_points, distribution='uniform', bias=0.) - xavier_init(self.can_bus_mlp, distribution='uniform', bias=0.) - # TODO apply fp16 to this module cause grad_norm NAN - # @auto_fp16(apply_to=('mlvl_feats', 'bev_queries', 'prev_bev', 'bev_pos'), out_fp32=True) - def attn_bev_encode( - self, - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - prev_bev=None, - **kwargs): - bs = mlvl_feats[0].size(0) - bev_queries = bev_queries.unsqueeze(1).repeat(1, bs, 1) - bev_pos = bev_pos.flatten(2).permute(2, 0, 1) - - # obtain rotation angle and shift with ego motion - delta_x = np.array([each['can_bus'][0] - for each in kwargs['img_metas']]) - delta_y = np.array([each['can_bus'][1] - for each in kwargs['img_metas']]) - ego_angle = np.array( - [each['can_bus'][-2] / np.pi * 180 for each in kwargs['img_metas']]) - grid_length_y = grid_length[0] - grid_length_x = grid_length[1] - translation_length = np.sqrt(delta_x ** 2 + delta_y ** 2) - translation_angle = np.arctan2(delta_y, delta_x) / np.pi * 180 - bev_angle = ego_angle - translation_angle - shift_y = translation_length * \ - np.cos(bev_angle / 180 * np.pi) / grid_length_y / bev_h - shift_x = translation_length * \ - np.sin(bev_angle / 180 * np.pi) / grid_length_x / bev_w - shift_y = shift_y * self.use_shift - shift_x = shift_x * self.use_shift - shift = bev_queries.new_tensor( - [shift_x, shift_y]).permute(1, 0) # xy, bs -> bs, xy - - if prev_bev is not None: - if prev_bev.shape[1] == bev_h * bev_w: - prev_bev = prev_bev.permute(1, 0, 2) - if self.rotate_prev_bev: - for i in range(bs): - # num_prev_bev = prev_bev.size(1) - rotation_angle = kwargs['img_metas'][i]['can_bus'][-1] - tmp_prev_bev = prev_bev[:, i].reshape( - bev_h, bev_w, -1).permute(2, 0, 1) - tmp_prev_bev = rotate(tmp_prev_bev, rotation_angle, - center=self.rotate_center) - tmp_prev_bev = tmp_prev_bev.permute(1, 2, 0).reshape( - bev_h * bev_w, 1, -1) - prev_bev[:, i] = tmp_prev_bev[:, 0] - - # add can bus signals - can_bus = bev_queries.new_tensor( - [each['can_bus'] for each in kwargs['img_metas']]) # [:, :] - can_bus = self.can_bus_mlp(can_bus)[None, :, :] - bev_queries = bev_queries + can_bus * self.use_can_bus - - feat_flatten = [] - spatial_shapes = [] - for lvl, feat in enumerate(mlvl_feats): - bs, num_cam, c, h, w = feat.shape - spatial_shape = (h, w) - feat = feat.flatten(3).permute(1, 0, 3, 2) - if self.use_cams_embeds: - feat = feat + self.cams_embeds[:, None, None, :].to(feat.dtype) - feat = feat + self.level_embeds[None, - None, lvl:lvl + 1, :].to(feat.dtype) - spatial_shapes.append(spatial_shape) - feat_flatten.append(feat) - - feat_flatten = torch.cat(feat_flatten, 2) - spatial_shapes = torch.as_tensor( - spatial_shapes, dtype=torch.long, device=bev_pos.device) - level_start_index = torch.cat((spatial_shapes.new_zeros( - (1,)), spatial_shapes.prod(1).cumsum(0)[:-1])) - - feat_flatten = feat_flatten.permute( - 0, 2, 1, 3) # (num_cam, H*W, bs, embed_dims) - - ret_dict = self.encoder( - bev_queries, - feat_flatten, - feat_flatten, - mlvl_feats=mlvl_feats, - bev_h=bev_h, - bev_w=bev_w, - bev_pos=bev_pos, - spatial_shapes=spatial_shapes, - level_start_index=level_start_index, - prev_bev=prev_bev, - shift=shift, - **kwargs - ) - return ret_dict - - def lss_bev_encode( - self, - mlvl_feats, - prev_bev=None, - **kwargs): - # import ipdb;ipdb.set_trace() - # assert len(mlvl_feats) == 1, 'Currently we only use last single level feat in LSS' - # import ipdb;ipdb.set_trace() - images = mlvl_feats[self.feat_down_sample_indice] - img_metas = kwargs['img_metas'] - encoder_outputdict = self.encoder(images,img_metas) - bev_embed = encoder_outputdict['bev'] - depth = encoder_outputdict['depth'] - bs, c, _,_ = bev_embed.shape - bev_embed = bev_embed.view(bs,c,-1).permute(0,2,1).contiguous() - ret_dict = dict( - bev=bev_embed, - depth=depth - ) - return ret_dict - - def get_bev_features( - self, - mlvl_feats, - lidar_feat, - bev_queries, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - prev_bev=None, - **kwargs): - """ - obtain bev features. - """ - if self.use_attn_bev: - ret_dict = self.attn_bev_encode( - mlvl_feats, - bev_queries, - bev_h, - bev_w, - grid_length=grid_length, - bev_pos=bev_pos, - prev_bev=prev_bev, - **kwargs) - bev_embed = ret_dict['bev'] - depth = ret_dict['depth'] - else: - ret_dict = self.lss_bev_encode( - mlvl_feats, - prev_bev=prev_bev, - **kwargs) - bev_embed = ret_dict['bev'] - depth = ret_dict['depth'] - if lidar_feat is not None: - bs = mlvl_feats[0].size(0) - bev_embed = bev_embed.view(bs, bev_h, bev_w, -1).permute(0,3,1,2).contiguous() - lidar_feat = lidar_feat.permute(0,1,3,2).contiguous() # B C H W - lidar_feat = nn.functional.interpolate(lidar_feat, size=(bev_h,bev_w), mode='bicubic', align_corners=False) - fused_bev = self.fuser([bev_embed, lidar_feat]) - fused_bev = fused_bev.flatten(2).permute(0,2,1).contiguous() - bev_embed = fused_bev - ret_dict = dict( - bev=bev_embed, - depth=depth - ) - return ret_dict - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def format_feats(self, mlvl_feats): - bs = mlvl_feats[0].size(0) - - feat_flatten = [] - spatial_shapes = [] - for lvl, feat in enumerate(mlvl_feats): - bs, num_cam, c, h, w = feat.shape - spatial_shape = (h, w) - feat = feat.flatten(3).permute(1, 0, 3, 2) - if self.use_cams_embeds: - feat = feat + self.cams_embeds[:, None, None, :].to(feat.dtype) - feat = feat + self.level_embeds[None, - None, lvl:lvl + 1, :].to(feat.dtype) - spatial_shapes.append(spatial_shape) - feat_flatten.append(feat) - - feat_flatten = torch.cat(feat_flatten, 2) - spatial_shapes = torch.as_tensor( - spatial_shapes, dtype=torch.long, device=feat.device) - level_start_index = torch.cat((spatial_shapes.new_zeros( - (1,)), spatial_shapes.prod(1).cumsum(0)[:-1])) - - feat_flatten = feat_flatten.permute( - 0, 2, 1, 3) # (num_cam, H*W, bs, embed_dims) - return feat_flatten, spatial_shapes, level_start_index - # TODO apply fp16 to this module cause grad_norm NAN - # @auto_fp16(apply_to=('mlvl_feats', 'bev_queries', 'object_query_embed', 'prev_bev', 'bev_pos')) - - #@torch.compile(mode="max-autotune-no-cudagraphs") - def initialize_queries_and_bev(self, object_query_embed, bev_embed, bs, bev_h, bev_w): - query_pos, query = torch.split( - object_query_embed, self.embed_dims, dim=1) - query_pos = query_pos.unsqueeze(0).expand(bs, -1, -1) - query = query.unsqueeze(0).expand(bs, -1, -1) - reference_points = self.reference_points(query_pos) - reference_points = reference_points.sigmoid() - init_reference_out = reference_points - - query = query.permute(1, 0, 2) - query_pos = query_pos.permute(1, 0, 2) - bev_embed = bev_embed.permute(1, 0, 2) - - spatial_shapes=torch.tensor([[bev_h, bev_w]], device=query.device) - level_start_index=torch.tensor([0], device=query.device) - - return query, bev_embed, query_pos, reference_points, spatial_shapes, level_start_index, init_reference_out - - def forward(self, - mlvl_feats, - lidar_feat, - bev_queries, - object_query_embed, - bev_h, - bev_w, - grid_length=[0.512, 0.512], - bev_pos=None, - reg_branches=None, - cls_branches=None, - prev_bev=None, - **kwargs): - """Forward function for `Detr3DTransformer`. - Args: - mlvl_feats (list(Tensor)): Input queries from - different level. Each element has shape - [bs, num_cams, embed_dims, h, w]. - bev_queries (Tensor): (bev_h*bev_w, c) - bev_pos (Tensor): (bs, embed_dims, bev_h, bev_w) - object_query_embed (Tensor): The query embedding for decoder, - with shape [num_query, c]. - reg_branches (obj:`nn.ModuleList`): Regression heads for - feature maps from each decoder layer. Only would - be passed when `with_box_refine` is True. Default to None. - Returns: - tuple[Tensor]: results of decoder containing the following tensor. - - bev_embed: BEV features - - inter_states: Outputs from decoder. If - return_intermediate_dec is True output has shape \ - (num_dec_layers, bs, num_query, embed_dims), else has \ - shape (1, bs, num_query, embed_dims). - - init_reference_out: The initial value of reference \ - points, has shape (bs, num_queries, 4). - - inter_references_out: The internal value of reference \ - points in decoder, has shape \ - (num_dec_layers, bs,num_query, embed_dims) - - enc_outputs_class: The classification score of \ - proposals generated from \ - encoder's feature maps, has shape \ - (batch, h*w, num_classes). \ - Only would be returned when `as_two_stage` is True, \ - otherwise None. - - enc_outputs_coord_unact: The regression results \ - generated from encoder's feature maps., has shape \ - (batch, h*w, 4). Only would \ - be returned when `as_two_stage` is True, \ - otherwise None. - """ - - ouput_dic = self.get_bev_features( - mlvl_feats, - lidar_feat, - bev_queries, - bev_h, - bev_w, - grid_length=grid_length, - bev_pos=bev_pos, - prev_bev=prev_bev, - **kwargs) # bev_embed shape: bs, bev_h*bev_w, embed_dims - bev_embed = ouput_dic['bev'] - depth = ouput_dic['depth'] - bs = mlvl_feats[0].size(0) - # query_pos, query = torch.split( - # object_query_embed, self.embed_dims, dim=1) - # query_pos = query_pos.unsqueeze(0).expand(bs, -1, -1) - # query = query.unsqueeze(0).expand(bs, -1, -1) - # reference_points = self.reference_points(query_pos) - # reference_points = reference_points.sigmoid() - # init_reference_out = reference_points - - # query = query.permute(1, 0, 2) - # query_pos = query_pos.permute(1, 0, 2) - # bev_embed = bev_embed.permute(1, 0, 2) - query, bev_embed, query_pos, reference_points, spatial_shapes, level_start_index, init_reference_out = self.initialize_queries_and_bev(object_query_embed, bev_embed, bs, bev_h, bev_w) - - feat_flatten, feat_spatial_shapes, feat_level_start_index \ - = self.format_feats(mlvl_feats) - - inter_states, inter_references = self.decoder( - query=query, - key=None, - value=bev_embed, - query_pos=query_pos, - reference_points=reference_points, - reg_branches=reg_branches, - cls_branches=cls_branches, - spatial_shapes=spatial_shapes, - level_start_index=level_start_index, - mlvl_feats=mlvl_feats, - feat_flatten=feat_flatten, - feat_spatial_shapes=feat_spatial_shapes, - feat_level_start_index=feat_level_start_index, - **kwargs) - - inter_references_out = inter_references - - return bev_embed, depth, inter_states, init_reference_out, inter_references_out diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/__init__.py deleted file mode 100644 index 4a9169d02a0cfb21e91c61431109b4d9ae304f1d..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .vovnet import VoVNet -from .efficientnet import EfficientNet -from .swin import SwinTransformer -__all__ = ['VoVNet'] \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/swin.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/swin.py deleted file mode 100644 index 166950599a35a5ea92cfb1f3aeaacea527929e0f..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/swin.py +++ /dev/null @@ -1,825 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import warnings -from copy import deepcopy - -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import build_norm_layer, trunc_normal_init -from mmcv.cnn.bricks.transformer import FFN, build_dropout -from mmcv.cnn.utils.weight_init import constant_init -from mmcv.runner import _load_checkpoint -from mmcv.runner.base_module import BaseModule, ModuleList -from torch.nn.modules.linear import Linear -from torch.nn.modules.normalization import LayerNorm -from torch.nn.modules.utils import _pair as to_2tuple -import torch.utils.checkpoint as checkpoint - -from mmseg.ops import resize -from mmdet3d.utils import get_root_logger -from mmdet.models.builder import BACKBONES -from mmcv.cnn.bricks.registry import ATTENTION -from ..utils import PatchEmbed, swin_convert - - -class PatchMerging(BaseModule): - """Merge patch feature map. - - This layer use nn.Unfold to group feature map by kernel_size, and use norm - and linear layer to embed grouped feature map. - Args: - in_channels (int): The num of input channels. - out_channels (int): The num of output channels. - stride (int | tuple): the stride of the sliding length in the - unfold layer. Defaults: 2. (Default to be equal with kernel_size). - bias (bool, optional): Whether to add bias in linear layer or not. - Defaults: False. - norm_cfg (dict, optional): Config dict for normalization layer. - Defaults: dict(type='LN'). - init_cfg (dict, optional): The extra config for initialization. - Defaults: None. - """ - - def __init__(self, - in_channels, - out_channels, - stride=2, - bias=False, - norm_cfg=dict(type='LN'), - init_cfg=None): - super().__init__(init_cfg) - self.in_channels = in_channels - self.out_channels = out_channels - self.stride = stride - - self.sampler = nn.Unfold( - kernel_size=stride, dilation=1, padding=0, stride=stride) - - sample_dim = stride**2 * in_channels - - if norm_cfg is not None: - self.norm = build_norm_layer(norm_cfg, sample_dim)[1] - else: - self.norm = None - - self.reduction = nn.Linear(sample_dim, out_channels, bias=bias) - - def forward(self, x, hw_shape): - """ - x: x.shape -> [B, H*W, C] - hw_shape: (H, W) - """ - B, L, C = x.shape - H, W = hw_shape - assert L == H * W, 'input feature has wrong size' - - x = x.view(B, H, W, C).permute([0, 3, 1, 2]) # B, C, H, W - - # stride is fixed to be equal to kernel_size. - if (H % self.stride != 0) or (W % self.stride != 0): - x = F.pad(x, (0, W % self.stride, 0, H % self.stride)) - - # Use nn.Unfold to merge patch. About 25% faster than original method, - # but need to modify pretrained model for compatibility - x = self.sampler(x) # B, 4*C, H/2*W/2 - x = x.transpose(1, 2) # B, H/2*W/2, 4*C - - x = self.norm(x) if self.norm else x - x = self.reduction(x) - - down_hw_shape = (H + 1) // 2, (W + 1) // 2 - return x, down_hw_shape - - -@ATTENTION.register_module() -class WindowMSA(BaseModule): - """Window based multi-head self-attention (W-MSA) module with relative - position bias. - - Args: - embed_dims (int): Number of input channels. - window_size (tuple[int]): The height and width of the window. - num_heads (int): Number of attention heads. - qkv_bias (bool, optional): If True, add a learnable bias to q, k, v. - Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - attn_drop_rate (float, optional): Dropout ratio of attention weight. - Default: 0.0 - proj_drop_rate (float, optional): Dropout ratio of output. Default: 0.0 - init_cfg (dict | None, optional): The Config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - window_size, - qkv_bias=True, - qk_scale=None, - attn_drop_rate=0., - proj_drop_rate=0., - init_cfg=None): - - super().__init__() - self.embed_dims = embed_dims - self.window_size = window_size # Wh, Ww - self.num_heads = num_heads - head_embed_dims = embed_dims // num_heads - self.scale = qk_scale or head_embed_dims**-0.5 - self.init_cfg = init_cfg - - # define a parameter table of relative position bias - self.relative_position_bias_table = nn.Parameter( - torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), - num_heads)) # 2*Wh-1 * 2*Ww-1, nH - - # About 2x faster than original impl - Wh, Ww = self.window_size - rel_index_coords = self.double_step_seq(2 * Ww - 1, Wh, 1, Ww) - rel_position_index = rel_index_coords + rel_index_coords.T - rel_position_index = rel_position_index.flip(1).contiguous() - self.register_buffer('relative_position_index', rel_position_index) - - self.qkv = nn.Linear(embed_dims, embed_dims * 3, bias=qkv_bias) - self.attn_drop = nn.Dropout(attn_drop_rate) - self.proj = nn.Linear(embed_dims, embed_dims) - self.proj_drop = nn.Dropout(proj_drop_rate) - - self.softmax = nn.Softmax(dim=-1) - - def init_weights(self): - trunc_normal_init(self.relative_position_bias_table, std=0.02) - - def forward(self, x, mask=None): - """ - Args: - - x (tensor): input features with shape of (num_windows*B, N, C) - mask (tensor | None, Optional): mask with shape of (num_windows, - Wh*Ww, Wh*Ww), value should be between (-inf, 0]. - """ - B, N, C = x.shape - qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, - C // self.num_heads).permute(2, 0, 3, 1, 4) - q, k, v = qkv[0], qkv[1], qkv[ - 2] # make torchscript happy (cannot use tensor as tuple) - - q = q * self.scale - attn = (q @ k.transpose(-2, -1)) - - relative_position_bias = self.relative_position_bias_table[ - self.relative_position_index.view(-1)].view( - self.window_size[0] * self.window_size[1], - self.window_size[0] * self.window_size[1], - -1) # Wh*Ww,Wh*Ww,nH - relative_position_bias = relative_position_bias.permute( - 2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww - attn = attn + relative_position_bias.unsqueeze(0) - - if mask is not None: - nW = mask.shape[0] - attn = attn.view(B // nW, nW, self.num_heads, N, - N) + mask.unsqueeze(1).unsqueeze(0) - attn = attn.view(-1, self.num_heads, N, N) - attn = self.softmax(attn) - else: - attn = self.softmax(attn) - - attn = self.attn_drop(attn) - - x = (attn @ v).transpose(1, 2).reshape(B, N, C) - x = self.proj(x) - x = self.proj_drop(x) - return x - - @staticmethod - def double_step_seq(step1, len1, step2, len2): - seq1 = torch.arange(0, step1 * len1, step1) - seq2 = torch.arange(0, step2 * len2, step2) - return (seq1[:, None] + seq2[None, :]).reshape(1, -1) - - -@ATTENTION.register_module() -class ShiftWindowMSA(BaseModule): - """Shift Window Multihead Self-Attention Module. - - Args: - embed_dims (int): Number of input channels. - num_heads (int): Number of attention heads. - window_size (int): The height and width of the window. - shift_size (int, optional): The shift step of each window towards - right-bottom. If zero, act as regular window-msa. Defaults to 0. - qkv_bias (bool, optional): If True, add a learnable bias to q, k, v. - Default: True - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Defaults: None. - attn_drop_rate (float, optional): Dropout ratio of attention weight. - Defaults: 0. - proj_drop_rate (float, optional): Dropout ratio of output. - Defaults: 0. - dropout_layer (dict, optional): The dropout_layer used before output. - Defaults: dict(type='DropPath', drop_prob=0.). - init_cfg (dict, optional): The extra config for initialization. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - window_size, - shift_size=0, - qkv_bias=True, - qk_scale=None, - attn_drop_rate=0, - proj_drop_rate=0, - dropout_layer=dict(type='DropPath', drop_prob=0.), - init_cfg=None): - super().__init__(init_cfg) - - self.window_size = window_size - self.shift_size = shift_size - assert 0 <= self.shift_size < self.window_size - - self.w_msa = WindowMSA( - embed_dims=embed_dims, - num_heads=num_heads, - window_size=to_2tuple(window_size), - qkv_bias=qkv_bias, - qk_scale=qk_scale, - attn_drop_rate=attn_drop_rate, - proj_drop_rate=proj_drop_rate, - init_cfg=None) - - self.drop = build_dropout(dropout_layer) - - def forward(self, query, hw_shape): - B, L, C = query.shape - H, W = hw_shape - assert L == H * W, 'input feature has wrong size' - query = query.view(B, H, W, C) - - # pad feature maps to multiples of window size - pad_r = (self.window_size - W % self.window_size) % self.window_size - pad_b = (self.window_size - H % self.window_size) % self.window_size - query = F.pad(query, (0, 0, 0, pad_r, 0, pad_b)) - H_pad, W_pad = query.shape[1], query.shape[2] - - # cyclic shift - if self.shift_size > 0: - shifted_query = torch.roll( - query, - shifts=(-self.shift_size, -self.shift_size), - dims=(1, 2)) - - # calculate attention mask for SW-MSA - img_mask = torch.zeros((1, H_pad, W_pad, 1), - device=query.device) # 1 H W 1 - h_slices = (slice(0, -self.window_size), - slice(-self.window_size, - -self.shift_size), slice(-self.shift_size, None)) - w_slices = (slice(0, -self.window_size), - slice(-self.window_size, - -self.shift_size), slice(-self.shift_size, None)) - # w_slices = (slice(0, -self.window_size), - # slice(-self.window_size, None)) - cnt = 0 - for h in h_slices: - for w in w_slices: - img_mask[:, h, w, :] = cnt - cnt += 1 - - # nW, window_size, window_size, 1 - mask_windows = self.window_partition(img_mask) - mask_windows = mask_windows.view( - -1, self.window_size * self.window_size) - attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2) - attn_mask = attn_mask.masked_fill(attn_mask != 0, - float(-100.0)).masked_fill( - attn_mask == 0, float(0.0)) - else: - shifted_query = query - attn_mask = None - - # nW*B, window_size, window_size, C - query_windows = self.window_partition(shifted_query) - # nW*B, window_size*window_size, C - query_windows = query_windows.view(-1, self.window_size**2, C) - - # W-MSA/SW-MSA (nW*B, window_size*window_size, C) - attn_windows = self.w_msa(query_windows, mask=attn_mask) - - # merge windows - attn_windows = attn_windows.view(-1, self.window_size, - self.window_size, C) - - # B H' W' C - shifted_x = self.window_reverse(attn_windows, H_pad, W_pad) - # reverse cyclic shift - if self.shift_size > 0: - x = torch.roll( - shifted_x, - shifts=(self.shift_size, self.shift_size), - dims=(1, 2)) - else: - x = shifted_x - - if pad_r > 0 or pad_b: - x = x[:, :H, :W, :].contiguous() - - x = x.view(B, H * W, C) - - x = self.drop(x) - return x - - def window_reverse(self, windows, H, W): - """ - Args: - windows: (num_windows*B, window_size, window_size, C) - window_size (int): Window size - H (int): Height of image - W (int): Width of image - Returns: - x: (B, H, W, C) - """ - window_size = self.window_size - B = int(windows.shape[0] / (H * W / window_size / window_size)) - x = windows.view(B, H // window_size, W // window_size, window_size, - window_size, -1) - x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1) - return x - - def window_partition(self, x): - """ - Args: - x: (B, H, W, C) - window_size (int): window size - Returns: - windows: (num_windows*B, window_size, window_size, C) - """ - B, H, W, C = x.shape - window_size = self.window_size - x = x.view(B, H // window_size, window_size, W // window_size, - window_size, C) - windows = x.permute(0, 1, 3, 2, 4, 5).contiguous() - windows = windows.view(-1, window_size, window_size, C) - return windows - - -class SwinBlock(BaseModule): - """" - Args: - embed_dims (int): The feature dimension. - num_heads (int): Parallel attention heads. - feedforward_channels (int): The hidden dimension for FFNs. - window size (int, optional): The local window scale. Default: 7. - shift (bool): whether to shift window or not. Default False. - qkv_bias (int, optional): enable bias for qkv if True. Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - drop_rate (float, optional): Dropout rate. Default: 0. - attn_drop_rate (float, optional): Attention dropout rate. Default: 0. - drop_path_rate (float, optional): Stochastic depth rate. Default: 0.2. - act_cfg (dict, optional): The config dict of activation function. - Default: dict(type='GELU'). - norm_cfg (dict, optional): The config dict of nomalization. - Default: dict(type='LN'). - init_cfg (dict | list | None, optional): The init config. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - feedforward_channels, - window_size=7, - shift=False, - qkv_bias=True, - qk_scale=None, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0., - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - init_cfg=None): - - super(SwinBlock, self).__init__() - - self.init_cfg = init_cfg - - self.norm1 = build_norm_layer(norm_cfg, embed_dims)[1] - self.attn = ShiftWindowMSA( - embed_dims=embed_dims, - num_heads=num_heads, - window_size=window_size, - shift_size=window_size // 2 if shift else 0, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - attn_drop_rate=attn_drop_rate, - proj_drop_rate=drop_rate, - dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate), - init_cfg=None) - - self.norm2 = build_norm_layer(norm_cfg, embed_dims)[1] - self.ffn = FFN( - embed_dims=embed_dims, - feedforward_channels=feedforward_channels, - num_fcs=2, - ffn_drop=drop_rate, - dropout_layer=dict(type='DropPath', drop_prob=drop_path_rate), - act_cfg=act_cfg, - add_identity=True, - init_cfg=None) - self.hw_shape = None - - def forward(self, x): - hw_shape = self.hw_shape - identity = x - x = self.norm1(x) - x = self.attn(x, hw_shape) - - x = x + identity - - identity = x - x = self.norm2(x) - x = self.ffn(x, identity=identity) - - return x - - -class SwinBlockSequence(BaseModule): - """Implements one stage in Swin Transformer. - - Args: - embed_dims (int): The feature dimension. - num_heads (int): Parallel attention heads. - feedforward_channels (int): The hidden dimension for FFNs. - depth (int): The number of blocks in this stage. - window size (int): The local window scale. Default: 7. - qkv_bias (int): enable bias for qkv if True. Default: True. - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - drop_rate (float, optional): Dropout rate. Default: 0. - attn_drop_rate (float, optional): Attention dropout rate. Default: 0. - drop_path_rate (float, optional): Stochastic depth rate. Default: 0.2. - downsample (BaseModule | None, optional): The downsample operation - module. Default: None. - act_cfg (dict, optional): The config dict of activation function. - Default: dict(type='GELU'). - norm_cfg (dict, optional): The config dict of nomalization. - Default: dict(type='LN'). - init_cfg (dict | list | None, optional): The init config. - Default: None. - """ - - def __init__(self, - embed_dims, - num_heads, - feedforward_channels, - depth, - window_size=7, - qkv_bias=True, - qk_scale=None, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0., - downsample=None, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - init_cfg=None, - with_cp=True): - super().__init__() - - self.init_cfg = init_cfg - - drop_path_rate = drop_path_rate if isinstance( - drop_path_rate, - list) else [deepcopy(drop_path_rate) for _ in range(depth)] - - self.blocks = ModuleList() - for i in range(depth): - block = SwinBlock( - embed_dims=embed_dims, - num_heads=num_heads, - feedforward_channels=feedforward_channels, - window_size=window_size, - shift=False if i % 2 == 0 else True, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - drop_rate=drop_rate, - attn_drop_rate=attn_drop_rate, - drop_path_rate=drop_path_rate[i], - act_cfg=act_cfg, - norm_cfg=norm_cfg, - init_cfg=None) - self.blocks.append(block) - - self.downsample = downsample - self.with_cp = with_cp - - def forward(self, x, hw_shape): - for block in self.blocks: - block.hw_shape=hw_shape - if self.with_cp: - x = checkpoint.checkpoint(block, x) - else: - x = block(x) - - if self.downsample: - x_down, down_hw_shape = self.downsample(x, hw_shape) - return x_down, down_hw_shape, x, hw_shape - else: - return x, hw_shape, x, hw_shape - - -@BACKBONES.register_module(force=True) -class SwinTransformer(BaseModule): - """ Swin Transformer - A PyTorch implement of : `Swin Transformer: - Hierarchical Vision Transformer using Shifted Windows` - - https://arxiv.org/abs/2103.14030 - - Inspiration from - https://github.com/microsoft/Swin-Transformer - - Args: - pretrain_img_size (int | tuple[int]): The size of input image when - pretrain. Defaults: 224. - in_channels (int): The num of input channels. - Defaults: 3. - embed_dims (int): The feature dimension. Default: 96. - patch_size (int | tuple[int]): Patch size. Default: 4. - window_size (int): Window size. Default: 7. - mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. - Default: 4. - depths (tuple[int]): Depths of each Swin Transformer stage. - Default: (2, 2, 6, 2). - num_heads (tuple[int]): Parallel attention heads of each Swin - Transformer stage. Default: (3, 6, 12, 24). - strides (tuple[int]): The patch merging or patch embedding stride of - each Swin Transformer stage. (In swin, we set kernel size equal to - stride.) Default: (4, 2, 2, 2). - out_indices (tuple[int]): Output from which stages. - Default: (0, 1, 2, 3). - qkv_bias (bool, optional): If True, add a learnable bias to query, key, - value. Default: True - qk_scale (float | None, optional): Override default qk scale of - head_dim ** -0.5 if set. Default: None. - patch_norm (bool): If add a norm layer for patch embed and patch - merging. Default: True. - drop_rate (float): Dropout rate. Defaults: 0. - attn_drop_rate (float): Attention dropout rate. Default: 0. - drop_path_rate (float): Stochastic depth rate. Defaults: 0.1. - use_abs_pos_embed (bool): If True, add absolute position embedding to - the patch embedding. Defaults: False. - act_cfg (dict): Config dict for activation layer. - Default: dict(type='LN'). - norm_cfg (dict): Config dict for normalization layer at - output of backone. Defaults: dict(type='LN'). - pretrain_style (str): Choose to use official or mmcls pretrain weights. - Default: official. - pretrained (str, optional): model pretrained path. Default: None. - init_cfg (dict, optional): The Config for initialization. - Defaults to None. - """ - - def __init__(self, - pretrain_img_size=224, - in_channels=3, - embed_dims=96, - patch_size=4, - window_size=7, - mlp_ratio=4, - depths=(2, 2, 6, 2), - num_heads=(3, 6, 12, 24), - strides=(4, 2, 2, 2), - out_indices=(0, 1, 2, 3), - qkv_bias=True, - qk_scale=None, - patch_norm=True, - drop_rate=0., - attn_drop_rate=0., - drop_path_rate=0.1, - use_abs_pos_embed=False, - act_cfg=dict(type='GELU'), - norm_cfg=dict(type='LN'), - pretrain_style='official', - pretrained=None, - init_cfg=None, - with_cp=True, - output_missing_index_as_none=False, - frozen_stages=-1): - super(SwinTransformer, self).__init__() - - if isinstance(pretrain_img_size, int): - pretrain_img_size = to_2tuple(pretrain_img_size) - elif isinstance(pretrain_img_size, tuple): - if len(pretrain_img_size) == 1: - pretrain_img_size = to_2tuple(pretrain_img_size[0]) - assert len(pretrain_img_size) == 2, \ - f'The size of image should have length 1 or 2, ' \ - f'but got {len(pretrain_img_size)}' - - assert pretrain_style in ['official', 'mmcls'], 'We only support load ' - 'official ckpt and mmcls ckpt.' - - if isinstance(pretrained, str) or pretrained is None: - warnings.warn('DeprecationWarning: pretrained is a deprecated, ' - 'please use "init_cfg" instead') - else: - raise TypeError('pretrained must be a str or None') - - num_layers = len(depths) - self.out_indices = out_indices - self.use_abs_pos_embed = use_abs_pos_embed - self.pretrain_style = pretrain_style - self.pretrained = pretrained - self.init_cfg = init_cfg - - self.frozen_stages = frozen_stages - - assert strides[0] == patch_size, 'Use non-overlapping patch embed.' - - self.patch_embed = PatchEmbed( - in_channels=in_channels, - embed_dims=embed_dims, - conv_type='Conv2d', - kernel_size=patch_size, - stride=strides[0], - pad_to_patch_size=True, - norm_cfg=norm_cfg if patch_norm else None, - init_cfg=None) - - if self.use_abs_pos_embed: - patch_row = pretrain_img_size[0] // patch_size - patch_col = pretrain_img_size[1] // patch_size - num_patches = patch_row * patch_col - self.absolute_pos_embed = nn.Parameter( - torch.zeros((1, num_patches, embed_dims))) - - self.drop_after_pos = nn.Dropout(p=drop_rate) - - # stochastic depth - total_depth = sum(depths) - dpr = [ - x.item() for x in torch.linspace(0, drop_path_rate, total_depth) - ] # stochastic depth decay rule - - self.stages = ModuleList() - in_channels = embed_dims - for i in range(num_layers): - if i < num_layers - 1: - downsample = PatchMerging( - in_channels=in_channels, - out_channels=2 * in_channels, - stride=strides[i + 1], - norm_cfg=norm_cfg if patch_norm else None, - init_cfg=None) - else: - downsample = None - - stage = SwinBlockSequence( - embed_dims=in_channels, - num_heads=num_heads[i], - feedforward_channels=mlp_ratio * in_channels, - depth=depths[i], - window_size=window_size, - qkv_bias=qkv_bias, - qk_scale=qk_scale, - drop_rate=drop_rate, - attn_drop_rate=attn_drop_rate, - drop_path_rate=dpr[:depths[i]], - downsample=downsample, - act_cfg=act_cfg, - norm_cfg=norm_cfg, - init_cfg=None, - with_cp=with_cp) - self.stages.append(stage) - - dpr = dpr[depths[i]:] - if downsample: - in_channels = downsample.out_channels - - self.num_features = [int(embed_dims * 2**i) for i in range(num_layers)] - # Add a norm layer for each output - for i in out_indices: - layer = build_norm_layer(norm_cfg, self.num_features[i])[1] - layer_name = f'norm{i}' - self.add_module(layer_name, layer) - self.output_missing_index_as_none = output_missing_index_as_none - - self._freeze_stages() - - def _freeze_stages(self): - if self.frozen_stages >= 0: - self.patch_embed.eval() - for param in self.patch_embed.parameters(): - param.requires_grad = False - - if self.frozen_stages >= 1 and self.use_abs_pos_embed: - self.absolute_pos_embed.requires_grad = False - - if self.frozen_stages >= 2: - self.drop_after_pos.eval() - for i in range(0, self.frozen_stages - 1): - m = self.stages[i] - m.eval() - for param in m.parameters(): - param.requires_grad = False - - def init_weights(self): - if self.pretrained is None: - super().init_weights() - if self.use_abs_pos_embed: - trunc_normal_init(self.absolute_pos_embed, std=0.02) - for m in self.modules(): - if isinstance(m, Linear): - trunc_normal_init(m.weight, std=.02) - if m.bias is not None: - constant_init(m.bias, 0) - elif isinstance(m, LayerNorm): - constant_init(m.bias, 0) - constant_init(m.weight, 1.0) - elif isinstance(self.pretrained, str): - logger = get_root_logger() - ckpt = _load_checkpoint( - self.pretrained, logger=logger, map_location='cpu') - if 'state_dict' in ckpt: - state_dict = ckpt['state_dict'] - elif 'model' in ckpt: - state_dict = ckpt['model'] - else: - state_dict = ckpt - - if self.pretrain_style == 'official': - state_dict = swin_convert(state_dict) - - # strip prefix of state_dict - if list(state_dict.keys())[0].startswith('module.'): - state_dict = {k[7:]: v for k, v in state_dict.items()} - - # reshape absolute position embedding - if state_dict.get('absolute_pos_embed') is not None: - absolute_pos_embed = state_dict['absolute_pos_embed'] - N1, L, C1 = absolute_pos_embed.size() - N2, C2, H, W = self.absolute_pos_embed.size() - if N1 != N2 or C1 != C2 or L != H * W: - logger.warning('Error in loading absolute_pos_embed, pass') - else: - state_dict['absolute_pos_embed'] = absolute_pos_embed.view( - N2, H, W, C2).permute(0, 3, 1, 2).contiguous() - - # interpolate position bias table if needed - relative_position_bias_table_keys = [ - k for k in state_dict.keys() - if 'relative_position_bias_table' in k - ] - for table_key in relative_position_bias_table_keys: - table_pretrained = state_dict[table_key] - table_current = self.state_dict()[table_key] - L1, nH1 = table_pretrained.size() - L2, nH2 = table_current.size() - if nH1 != nH2: - logger.warning(f'Error in loading {table_key}, pass') - else: - if L1 != L2: - S1 = int(L1**0.5) - S2 = int(L2**0.5) - table_pretrained_resized = resize( - table_pretrained.permute(1, 0).reshape( - 1, nH1, S1, S1), - size=(S2, S2), - mode='bicubic') - state_dict[table_key] = table_pretrained_resized.view( - nH2, L2).permute(1, 0).contiguous() - - # load state_dict - self.load_state_dict(state_dict, False) - - def forward(self, x): - x = self.patch_embed(x) - - hw_shape = (self.patch_embed.DH, self.patch_embed.DW) - if self.use_abs_pos_embed: - x = x + self.absolute_pos_embed - x = self.drop_after_pos(x) - - outs = [] - for i, stage in enumerate(self.stages): - x, hw_shape, out, out_hw_shape = stage(x, hw_shape) - if i in self.out_indices: - norm_layer = getattr(self, f'norm{i}') - out = norm_layer(out) - out = out.view(-1, *out_hw_shape, - self.num_features[i]).permute(0, 3, 1, - 2).contiguous() - outs.append(out) - elif self.output_missing_index_as_none: - outs.append(None) - return outs - - def train(self, mode=True): - """Convert the model into training mode while keep normalization layer - freezed.""" - super(SwinTransformer, self).train(mode) - self._freeze_stages() \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/vovnet.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/vovnet.py deleted file mode 100644 index 879d186a37b49addaf27362cc6ae1e5465b2168e..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/backbones/vovnet.py +++ /dev/null @@ -1,375 +0,0 @@ - -from collections import OrderedDict -from mmcv.runner import BaseModule -from mmdet.models.builder import BACKBONES -import torch -import torch.nn as nn -import torch.nn.functional as F -from torch.nn.modules.batchnorm import _BatchNorm - - -VoVNet19_slim_dw_eSE = { - 'stem': [64, 64, 64], - 'stage_conv_ch': [64, 80, 96, 112], - 'stage_out_ch': [112, 256, 384, 512], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": True -} - -VoVNet19_dw_eSE = { - 'stem': [64, 64, 64], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": True -} - -VoVNet19_slim_eSE = { - 'stem': [64, 64, 128], - 'stage_conv_ch': [64, 80, 96, 112], - 'stage_out_ch': [112, 256, 384, 512], - 'layer_per_block': 3, - 'block_per_stage': [1, 1, 1, 1], - 'eSE': True, - "dw": False -} - -VoVNet19_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 3, - "block_per_stage": [1, 1, 1, 1], - "eSE": True, - "dw": False -} - -VoVNet39_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 1, 2, 2], - "eSE": True, - "dw": False -} - -VoVNet57_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 1, 4, 3], - "eSE": True, - "dw": False -} - -VoVNet99_eSE = { - 'stem': [64, 64, 128], - "stage_conv_ch": [128, 160, 192, 224], - "stage_out_ch": [256, 512, 768, 1024], - "layer_per_block": 5, - "block_per_stage": [1, 3, 9, 3], - "eSE": True, - "dw": False -} - -_STAGE_SPECS = { - "V-19-slim-dw-eSE": VoVNet19_slim_dw_eSE, - "V-19-dw-eSE": VoVNet19_dw_eSE, - "V-19-slim-eSE": VoVNet19_slim_eSE, - "V-19-eSE": VoVNet19_eSE, - "V-39-eSE": VoVNet39_eSE, - "V-57-eSE": VoVNet57_eSE, - "V-99-eSE": VoVNet99_eSE, -} - - -def dw_conv3x3(in_channels, out_channels, module_name, postfix, stride=1, kernel_size=3, padding=1): - """3x3 convolution with padding""" - return [ - ( - '{}_{}/dw_conv3x3'.format(module_name, postfix), - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=out_channels, - bias=False - ) - ), - ( - '{}_{}/pw_conv1x1'.format(module_name, postfix), - nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0, groups=1, bias=False) - ), - ('{}_{}/pw_norm'.format(module_name, postfix), nn.BatchNorm2d(out_channels)), - ('{}_{}/pw_relu'.format(module_name, postfix), nn.ReLU(inplace=True)), - ] - - -def conv3x3(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=3, padding=1): - """3x3 convolution with padding""" - return [ - ( - f"{module_name}_{postfix}/conv", - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=groups, - bias=False, - ), - ), - (f"{module_name}_{postfix}/norm", nn.BatchNorm2d(out_channels)), - (f"{module_name}_{postfix}/relu", nn.ReLU(inplace=True)), - ] - - -def conv1x1(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=1, padding=0): - """1x1 convolution with padding""" - return [ - ( - f"{module_name}_{postfix}/conv", - nn.Conv2d( - in_channels, - out_channels, - kernel_size=kernel_size, - stride=stride, - padding=padding, - groups=groups, - bias=False, - ), - ), - (f"{module_name}_{postfix}/norm", nn.BatchNorm2d(out_channels)), - (f"{module_name}_{postfix}/relu", nn.ReLU(inplace=True)), - ] - - -class Hsigmoid(nn.Module): - def __init__(self, inplace=True): - super(Hsigmoid, self).__init__() - self.inplace = inplace - - def forward(self, x): - return F.relu6(x + 3.0, inplace=self.inplace) / 6.0 - - -class eSEModule(nn.Module): - def __init__(self, channel, reduction=4): - super(eSEModule, self).__init__() - self.avg_pool = nn.AdaptiveAvgPool2d(1) - self.fc = nn.Conv2d(channel, channel, kernel_size=1, padding=0) - self.hsigmoid = Hsigmoid() - - def forward(self, x): - input = x - x = self.avg_pool(x) - x = self.fc(x) - x = self.hsigmoid(x) - return input * x - - -class _OSA_module(nn.Module): - def __init__( - self, in_ch, stage_ch, concat_ch, layer_per_block, module_name, SE=False, identity=False, depthwise=False - ): - - super(_OSA_module, self).__init__() - - self.identity = identity - self.depthwise = depthwise - self.isReduced = False - self.layers = nn.ModuleList() - in_channel = in_ch - if self.depthwise and in_channel != stage_ch: - self.isReduced = True - self.conv_reduction = nn.Sequential( - OrderedDict(conv1x1(in_channel, stage_ch, "{}_reduction".format(module_name), "0")) - ) - for i in range(layer_per_block): - if self.depthwise: - self.layers.append(nn.Sequential(OrderedDict(dw_conv3x3(stage_ch, stage_ch, module_name, i)))) - else: - self.layers.append(nn.Sequential(OrderedDict(conv3x3(in_channel, stage_ch, module_name, i)))) - in_channel = stage_ch - - # feature aggregation - in_channel = in_ch + layer_per_block * stage_ch - self.concat = nn.Sequential(OrderedDict(conv1x1(in_channel, concat_ch, module_name, "concat"))) - - self.ese = eSEModule(concat_ch) - - def forward(self, x): - - identity_feat = x - - output = [] - output.append(x) - if self.depthwise and self.isReduced: - x = self.conv_reduction(x) - for layer in self.layers: - x = layer(x) - output.append(x) - - x = torch.cat(output, dim=1) - xt = self.concat(x) - - xt = self.ese(xt) - - if self.identity: - xt = xt + identity_feat - - return xt - - -class _OSA_stage(nn.Sequential): - def __init__( - self, in_ch, stage_ch, concat_ch, block_per_stage, layer_per_block, stage_num, SE=False, depthwise=False - ): - - super(_OSA_stage, self).__init__() - - if not stage_num == 2: - self.add_module("Pooling", nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True)) - - if block_per_stage != 1: - SE = False - module_name = f"OSA{stage_num}_1" - self.add_module( - module_name, _OSA_module(in_ch, stage_ch, concat_ch, layer_per_block, module_name, SE, depthwise=depthwise) - ) - for i in range(block_per_stage - 1): - if i != block_per_stage - 2: # last block - SE = False - module_name = f"OSA{stage_num}_{i + 2}" - self.add_module( - module_name, - _OSA_module( - concat_ch, - stage_ch, - concat_ch, - layer_per_block, - module_name, - SE, - identity=True, - depthwise=depthwise - ), - ) - - -@BACKBONES.register_module() -class VoVNet(BaseModule): - def __init__(self, spec_name, input_ch=3, out_features=None, - frozen_stages=-1, norm_eval=True, pretrained=None, init_cfg=None): - """ - Args: - input_ch(int) : the number of input channel - out_features (list[str]): name of the layers whose outputs should - be returned in forward. Can be anything in "stem", "stage2" ... - """ - super(VoVNet, self).__init__(init_cfg) - self.frozen_stages = frozen_stages - self.norm_eval = norm_eval - - if isinstance(pretrained, str): - warnings.warn('DeprecationWarning: pretrained is deprecated, ' - 'please use "init_cfg" instead') - self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) - stage_specs = _STAGE_SPECS[spec_name] - - stem_ch = stage_specs["stem"] - config_stage_ch = stage_specs["stage_conv_ch"] - config_concat_ch = stage_specs["stage_out_ch"] - block_per_stage = stage_specs["block_per_stage"] - layer_per_block = stage_specs["layer_per_block"] - SE = stage_specs["eSE"] - depthwise = stage_specs["dw"] - - self._out_features = out_features - - # Stem module - conv_type = dw_conv3x3 if depthwise else conv3x3 - stem = conv3x3(input_ch, stem_ch[0], "stem", "1", 2) - stem += conv_type(stem_ch[0], stem_ch[1], "stem", "2", 1) - stem += conv_type(stem_ch[1], stem_ch[2], "stem", "3", 2) - self.add_module("stem", nn.Sequential((OrderedDict(stem)))) - current_stirde = 4 - self._out_feature_strides = {"stem": current_stirde, "stage2": current_stirde} - self._out_feature_channels = {"stem": stem_ch[2]} - - stem_out_ch = [stem_ch[2]] - in_ch_list = stem_out_ch + config_concat_ch[:-1] - # OSA stages - self.stage_names = [] - for i in range(4): # num_stages - name = "stage%d" % (i + 2) # stage 2 ... stage 5 - self.stage_names.append(name) - self.add_module( - name, - _OSA_stage( - in_ch_list[i], - config_stage_ch[i], - config_concat_ch[i], - block_per_stage[i], - layer_per_block, - i + 2, - SE, - depthwise, - ), - ) - - self._out_feature_channels[name] = config_concat_ch[i] - if not i == 0: - self._out_feature_strides[name] = current_stirde = int(current_stirde * 2) - - # initialize weights - # self._initialize_weights() - - def _initialize_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - nn.init.kaiming_normal_(m.weight) - - def forward(self, x): - outputs = {} - x = self.stem(x) - if "stem" in self._out_features: - outputs["stem"] = x - for name in self.stage_names: - x = getattr(self, name)(x) - if name in self._out_features: - outputs[name] = x - - return outputs - - def _freeze_stages(self): - if self.frozen_stages >= 0: - m = getattr(self, 'stem') - m.eval() - for param in m.parameters(): - param.requires_grad = False - - for i in range(1, self.frozen_stages + 1): - m = getattr(self, f'stage{i+1}') - m.eval() - for param in m.parameters(): - param.requires_grad = False - - def train(self, mode=True): - """Convert the model into training mode while keep normalization layer - freezed.""" - super(VoVNet, self).train(mode) - self._freeze_stages() - if mode and self.norm_eval: - for m in self.modules(): - # trick: eval have effect on BatchNorm only - if isinstance(m, _BatchNorm): - m.eval() \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/__init__.py deleted file mode 100644 index 93b13c9c853d6f7eece8ae2dc7aa67d4e87db68b..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .hooks import GradChecker \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/hooks.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/hooks.py deleted file mode 100644 index 56ff7fd575c890e60ce49eb618df157b2cc2ca37..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/hooks/hooks.py +++ /dev/null @@ -1,13 +0,0 @@ -from mmcv.runner.hooks.hook import HOOKS, Hook -from projects.mmdet3d_plugin.models.utils import run_time - - -@HOOKS.register_module() -class GradChecker(Hook): - - def after_train_iter(self, runner): - for key, val in runner.model.named_parameters(): - if val.grad == None and val.requires_grad: - print('WARNNING: {key}\'s parameters are not be used!!!!'.format(key=key)) - - diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/__init__.py deleted file mode 100644 index c7dd426868a61772bbe0926e435ce89f15009805..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .adamw import AdamW2 \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/adamw.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/adamw.py deleted file mode 100644 index c890aeaf04721580c11ca329f2be09a6a280f773..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/adamw.py +++ /dev/null @@ -1,131 +0,0 @@ -try: - from torch.optim import _functional as F -except: - print('WARNING!!!, I recommend using torch>=1.8') - -import torch -from torch.optim.optimizer import Optimizer -from mmcv.runner.optimizer.builder import OPTIMIZERS - -@OPTIMIZERS.register_module() -class AdamW2(Optimizer): - r"""Implements AdamW algorithm. Solve the bug of torch 1.8 - - The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. - The AdamW variant was proposed in `Decoupled Weight Decay Regularization`_. - - Args: - params (iterable): iterable of parameters to optimize or dicts defining - parameter groups - lr (float, optional): learning rate (default: 1e-3) - betas (Tuple[float, float], optional): coefficients used for computing - running averages of gradient and its square (default: (0.9, 0.999)) - eps (float, optional): term added to the denominator to improve - numerical stability (default: 1e-8) - weight_decay (float, optional): weight decay coefficient (default: 1e-2) - amsgrad (boolean, optional): whether to use the AMSGrad variant of this - algorithm from the paper `On the Convergence of Adam and Beyond`_ - (default: False) - - .. _Adam\: A Method for Stochastic Optimization: - https://arxiv.org/abs/1412.6980 - .. _Decoupled Weight Decay Regularization: - https://arxiv.org/abs/1711.05101 - .. _On the Convergence of Adam and Beyond: - https://openreview.net/forum?id=ryQu7f-RZ - """ - - def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, - weight_decay=1e-2, amsgrad=False): - if not 0.0 <= lr: - raise ValueError("Invalid learning rate: {}".format(lr)) - if not 0.0 <= eps: - raise ValueError("Invalid epsilon value: {}".format(eps)) - if not 0.0 <= betas[0] < 1.0: - raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) - if not 0.0 <= betas[1] < 1.0: - raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) - if not 0.0 <= weight_decay: - raise ValueError("Invalid weight_decay value: {}".format(weight_decay)) - defaults = dict(lr=lr, betas=betas, eps=eps, - weight_decay=weight_decay, amsgrad=amsgrad) - super(AdamW2, self).__init__(params, defaults) - - def __setstate__(self, state): - super(AdamW2, self).__setstate__(state) - for group in self.param_groups: - group.setdefault('amsgrad', False) - - @torch.no_grad() - def step(self, closure=None): - """Performs a single optimization step. - - Args: - closure (callable, optional): A closure that reevaluates the model - and returns the loss. - """ - loss = None - if closure is not None: - with torch.enable_grad(): - loss = closure() - - for group in self.param_groups: - params_with_grad = [] - grads = [] - exp_avgs = [] - exp_avg_sqs = [] - state_sums = [] - max_exp_avg_sqs = [] - state_steps = [] - amsgrad = group['amsgrad'] - - # put this line here for solving bug - beta1, beta2 = group['betas'] - - for p in group['params']: - if p.grad is None: - continue - params_with_grad.append(p) - if p.grad.is_sparse: - raise RuntimeError('AdamW does not support sparse gradients') - grads.append(p.grad) - - state = self.state[p] - - # State initialization - if len(state) == 0: - state['step'] = 0 - # Exponential moving average of gradient values - state['exp_avg'] = torch.zeros_like(p, memory_format=torch.preserve_format) - # Exponential moving average of squared gradient values - state['exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - if amsgrad: - # Maintains max of all exp. moving avg. of sq. grad. values - state['max_exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - - exp_avgs.append(state['exp_avg']) - exp_avg_sqs.append(state['exp_avg_sq']) - - if amsgrad: - max_exp_avg_sqs.append(state['max_exp_avg_sq']) - - - # update the steps for each param group update - state['step'] += 1 - # record the step after step update - state_steps.append(state['step']) - - F.adamw(params_with_grad, - grads, - exp_avgs, - exp_avg_sqs, - max_exp_avg_sqs, - state_steps, - amsgrad, - beta1, - beta2, - group['lr'], - group['weight_decay'], - group['eps']) - - return loss \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/miopen_adam.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/miopen_adam.py deleted file mode 100644 index 78586163d97615940eeed1205d83cfb99d1576f9..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/opt/miopen_adam.py +++ /dev/null @@ -1,125 +0,0 @@ -import lightop -import torch -from torch.optim.optimizer import Optimizer -from mmcv.runner.optimizer.builder import OPTIMIZERS - -@OPTIMIZERS.register_module() -class Miopen_AdamW(Optimizer): - r"""Implements AdamW algorithm. Solve the bug of torch 1.8 - - The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. - The AdamW variant was proposed in `Decoupled Weight Decay Regularization`_. - - Args: - params (iterable): iterable of parameters to optimize or dicts defining - parameter groups - lr (float, optional): learning rate (default: 1e-3) - betas (Tuple[float, float], optional): coefficients used for computing - running averages of gradient and its square (default: (0.9, 0.999)) - eps (float, optional): term added to the denominator to improve - numerical stability (default: 1e-8) - weight_decay (float, optional): weight decay coefficient (default: 1e-2) - amsgrad (boolean, optional): whether to use the AMSGrad variant of this - algorithm from the paper `On the Convergence of Adam and Beyond`_ - (default: False) - - .. _Adam\: A Method for Stochastic Optimization: - https://arxiv.org/abs/1412.6980 - .. _Decoupled Weight Decay Regularization: - https://arxiv.org/abs/1711.05101 - .. _On the Convergence of Adam and Beyond: - https://openreview.net/forum?id=ryQu7f-RZ - """ - - def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, - weight_decay=1e-2, amsgrad=False): - if not 0.0 <= lr: - raise ValueError("Invalid learning rate: {}".format(lr)) - if not 0.0 <= eps: - raise ValueError("Invalid epsilon value: {}".format(eps)) - if not 0.0 <= betas[0] < 1.0: - raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) - if not 0.0 <= betas[1] < 1.0: - raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) - if not 0.0 <= weight_decay: - raise ValueError("Invalid weight_decay value: {}".format(weight_decay)) - defaults = dict(lr=lr, betas=betas, eps=eps, - weight_decay=weight_decay, amsgrad=amsgrad) - super(Miopen_AdamW, self).__init__(params, defaults) - - def __setstate__(self, state): - super(Miopen_AdamW, self).__setstate__(state) - for group in self.param_groups: - group.setdefault('amsgrad', False) - - @torch.no_grad() - def step(self, closure=None): - """Performs a single optimization step. - - Args: - closure (callable, optional): A closure that reevaluates the model - and returns the loss. - """ - loss = None - if closure is not None: - with torch.enable_grad(): - loss = closure() - - for group in self.param_groups: - params_with_grad = [] - grads = [] - exp_avgs = [] - exp_avg_sqs = [] - state_sums = [] - max_exp_avg_sqs = [] - state_steps = [] - amsgrad = group['amsgrad'] - - # put this line here for solving bug - beta1, beta2 = group['betas'] - - for p in group['params']: - if p.grad is None: - continue - params_with_grad.append(p.contiguous()) - if p.grad.is_sparse: - raise RuntimeError('AdamW does not support sparse gradients') - grads.append(p.grad.contiguous()) - - state = self.state[p] - - # State initialization - if len(state) == 0: - state['step'] = 0 - # Exponential moving average of gradient values - state['exp_avg'] = torch.zeros_like(p, memory_format=torch.preserve_format) - # Exponential moving average of squared gradient values - state['exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - if amsgrad: - # Maintains max of all exp. moving avg. of sq. grad. values - state['max_exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - - exp_avgs.append(state['exp_avg'].contiguous()) - exp_avg_sqs.append(state['exp_avg_sq'].contiguous()) - - if amsgrad: - max_exp_avg_sqs.append(state['max_exp_avg_sq'].contiguous()) - - # record the step after step update - state_steps.append(torch.tensor(state['step'])) - - lightop.miopen_adamw( - params=params_with_grad, - grads=grads, - exp_avgs=exp_avgs, - exp_avg_sqs=exp_avg_sqs, - max_exp_avg_sqs=max_exp_avg_sqs, - state_steps=state_steps, - amsgrad=amsgrad, - beta1=beta1, - beta2=beta2, - lr=group['lr'], - weight_decay=group['weight_decay'], - eps=group['eps']) - - return loss diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/__init__.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/__init__.py deleted file mode 100644 index 921aee7c215a2e2546e943589a85949c2eee7b05..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ - -from .bricks import run_time -from .grid_mask import GridMask -from .position_embedding import RelPositionEmbedding -from .visual import save_tensor -from .inverted_residual import InvertedResidual -from .se_layer import DyReLU, SELayer -from .make_divisible import make_divisible -from .ckpt_convert import swin_convert, vit_convert -from .embed import PatchEmbed \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/bricks.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/bricks.py deleted file mode 100644 index fd458813d9ffced23b79799daa84150ba887774e..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/bricks.py +++ /dev/null @@ -1,20 +0,0 @@ -import functools -import time -from collections import defaultdict -import torch -time_maps = defaultdict(lambda :0.) -count_maps = defaultdict(lambda :0.) -def run_time(name): - def middle(fn): - def wrapper(*args, **kwargs): - torch.cuda.synchronize() - start = time.time() - res = fn(*args, **kwargs) - torch.cuda.synchronize() - time_maps['%s : %s'%(name, fn.__name__) ] += time.time()-start - count_maps['%s : %s'%(name, fn.__name__) ] +=1 - print("%s : %s takes up %f "% (name, fn.__name__,time_maps['%s : %s'%(name, fn.__name__) ] /count_maps['%s : %s'%(name, fn.__name__) ] )) - return res - return wrapper - return middle - \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/inverted_residual.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/inverted_residual.py deleted file mode 100644 index 093c8efe85a24ea26c9fd18d6b9cd14c7ce68779..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/inverted_residual.py +++ /dev/null @@ -1,128 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import torch.nn as nn -import torch.utils.checkpoint as cp -from mmcv.cnn import ConvModule -from mmcv.cnn.bricks import DropPath -from mmcv.runner import BaseModule - -from .se_layer import SELayer - - -class InvertedResidual(BaseModule): - """Inverted Residual Block. - Args: - in_channels (int): The input channels of this Module. - out_channels (int): The output channels of this Module. - mid_channels (int): The input channels of the depthwise convolution. - kernel_size (int): The kernel size of the depthwise convolution. - Default: 3. - stride (int): The stride of the depthwise convolution. Default: 1. - se_cfg (dict): Config dict for se layer. Default: None, which means no - se layer. - with_expand_conv (bool): Use expand conv or not. If set False, - mid_channels must be the same with in_channels. - Default: True. - conv_cfg (dict): Config dict for convolution layer. Default: None, - which means using conv2d. - norm_cfg (dict): Config dict for normalization layer. - Default: dict(type='BN'). - act_cfg (dict): Config dict for activation layer. - Default: dict(type='ReLU'). - drop_path_rate (float): stochastic depth rate. Defaults to 0. - with_cp (bool): Use checkpoint or not. Using checkpoint will save some - memory while slowing down the training speed. Default: False. - init_cfg (dict or list[dict], optional): Initialization config dict. - Default: None - Returns: - Tensor: The output tensor. - """ - - def __init__(self, - in_channels, - out_channels, - mid_channels, - kernel_size=3, - stride=1, - se_cfg=None, - with_expand_conv=True, - conv_cfg=None, - norm_cfg=dict(type='BN'), - act_cfg=dict(type='ReLU'), - drop_path_rate=0., - with_cp=False, - init_cfg=None): - super(InvertedResidual, self).__init__(init_cfg) - self.with_res_shortcut = (stride == 1 and in_channels == out_channels) - assert stride in [1, 2], f'stride must in [1, 2]. ' \ - f'But received {stride}.' - self.with_cp = with_cp - self.drop_path = DropPath( - drop_path_rate) if drop_path_rate > 0 else nn.Identity() - self.with_se = se_cfg is not None - self.with_expand_conv = with_expand_conv - - if self.with_se: - assert isinstance(se_cfg, dict) - if not self.with_expand_conv: - assert mid_channels == in_channels - - if self.with_expand_conv: - self.expand_conv = ConvModule( - in_channels=in_channels, - out_channels=mid_channels, - kernel_size=1, - stride=1, - padding=0, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg) - self.depthwise_conv = ConvModule( - in_channels=mid_channels, - out_channels=mid_channels, - kernel_size=kernel_size, - stride=stride, - padding=kernel_size // 2, - groups=mid_channels, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg) - - if self.with_se: - self.se = SELayer(**se_cfg) - - self.linear_conv = ConvModule( - in_channels=mid_channels, - out_channels=out_channels, - kernel_size=1, - stride=1, - padding=0, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=None) - - def forward(self, x): - - def _inner_forward(x): - out = x - - if self.with_expand_conv: - out = self.expand_conv(out) - - out = self.depthwise_conv(out) - - if self.with_se: - out = self.se(out) - - out = self.linear_conv(out) - - if self.with_res_shortcut: - return x + self.drop_path(out) - else: - return out - - if self.with_cp and x.requires_grad: - out = cp.checkpoint(_inner_forward, x) - else: - out = _inner_forward(x) - - return out \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/make_divisible.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/make_divisible.py deleted file mode 100644 index 5bbc0a6c5b7cef48a9171ef4870201f2aa6cad85..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/make_divisible.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -def make_divisible(value, divisor, min_value=None, min_ratio=0.9): - """Make divisible function. - This function rounds the channel number to the nearest value that can be - divisible by the divisor. It is taken from the original tf repo. It ensures - that all layers have a channel number that is divisible by divisor. It can - be seen here: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py # noqa - Args: - value (int): The original channel number. - divisor (int): The divisor to fully divide the channel number. - min_value (int): The minimum value of the output channel. - Default: None, means that the minimum value equal to the divisor. - min_ratio (float): The minimum ratio of the rounded channel number to - the original channel number. Default: 0.9. - Returns: - int: The modified output channel number. - """ - - if min_value is None: - min_value = divisor - new_value = max(min_value, int(value + divisor / 2) // divisor * divisor) - # Make sure that round down does not go down by more than (1-min_ratio). - if new_value < min_ratio * value: - new_value += divisor - return new_value \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/position_embedding.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/position_embedding.py deleted file mode 100644 index 290110fef7cb86c5edafb0b33da3bed794e6f7a9..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/position_embedding.py +++ /dev/null @@ -1,34 +0,0 @@ -import torch -import torch.nn as nn -import math - -class RelPositionEmbedding(nn.Module): - def __init__(self, num_pos_feats=64, pos_norm=True): - super().__init__() - self.num_pos_feats = num_pos_feats - self.fc = nn.Linear(4, self.num_pos_feats,bias=False) - #nn.init.orthogonal_(self.fc.weight) - #self.fc.weight.requires_grad = False - self.pos_norm = pos_norm - if self.pos_norm: - self.norm = nn.LayerNorm(self.num_pos_feats) - def forward(self, tensor): - #mask = nesttensor.mask - B,C,H,W = tensor.shape - #print('tensor.shape', tensor.shape) - y_range = (torch.arange(H) / float(H - 1)).to(tensor.device) - #y_axis = torch.stack((y_range, 1-y_range),dim=1) - y_axis = torch.stack((torch.cos(y_range * math.pi), torch.sin(y_range * math.pi)), dim=1) - y_axis = y_axis.reshape(H, 1, 2).repeat(1, W, 1).reshape(H * W, 2) - - x_range = (torch.arange(W) / float(W - 1)).to(tensor.device) - #x_axis =torch.stack((x_range,1-x_range),dim=1) - x_axis = torch.stack((torch.cos(x_range * math.pi), torch.sin(x_range * math.pi)), dim=1) - x_axis = x_axis.reshape(1, W, 2).repeat(H, 1, 1).reshape(H * W, 2) - x_pos = torch.cat((y_axis, x_axis), dim=1) - x_pos = self.fc(x_pos) - - if self.pos_norm: - x_pos = self.norm(x_pos) - #print('xpos,', x_pos.max(),x_pos.min()) - return x_pos \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/se_layer.py b/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/se_layer.py deleted file mode 100644 index 86d10615f5a8606909af4e6af4163cf97ad73cc1..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/projects/mmdet3d_plugin/models/utils/se_layer.py +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import mmcv -import torch -import torch.nn as nn -from mmcv.cnn import ConvModule -from mmcv.runner import BaseModule - - -class SELayer(BaseModule): - """Squeeze-and-Excitation Module. - Args: - channels (int): The input (and output) channels of the SE layer. - ratio (int): Squeeze ratio in SELayer, the intermediate channel will be - ``int(channels/ratio)``. Default: 16. - conv_cfg (None or dict): Config dict for convolution layer. - Default: None, which means using conv2d. - act_cfg (dict or Sequence[dict]): Config dict for activation layer. - If act_cfg is a dict, two activation layers will be configurated - by this dict. If act_cfg is a sequence of dicts, the first - activation layer will be configurated by the first dict and the - second activation layer will be configurated by the second dict. - Default: (dict(type='ReLU'), dict(type='Sigmoid')) - init_cfg (dict or list[dict], optional): Initialization config dict. - Default: None - """ - - def __init__(self, - channels, - ratio=16, - conv_cfg=None, - act_cfg=(dict(type='ReLU'), dict(type='Sigmoid')), - init_cfg=None): - super(SELayer, self).__init__(init_cfg) - if isinstance(act_cfg, dict): - act_cfg = (act_cfg, act_cfg) - assert len(act_cfg) == 2 - assert mmcv.is_tuple_of(act_cfg, dict) - self.global_avgpool = nn.AdaptiveAvgPool2d(1) - self.conv1 = ConvModule( - in_channels=channels, - out_channels=int(channels / ratio), - kernel_size=1, - stride=1, - conv_cfg=conv_cfg, - act_cfg=act_cfg[0]) - self.conv2 = ConvModule( - in_channels=int(channels / ratio), - out_channels=channels, - kernel_size=1, - stride=1, - conv_cfg=conv_cfg, - act_cfg=act_cfg[1]) - - def forward(self, x): - out = self.global_avgpool(x) - out = self.conv1(out) - out = self.conv2(out) - return x * out - - -class DyReLU(BaseModule): - """Dynamic ReLU (DyReLU) module. - See `Dynamic ReLU `_ for details. - Current implementation is specialized for task-aware attention in DyHead. - HSigmoid arguments in default act_cfg follow DyHead official code. - https://github.com/microsoft/DynamicHead/blob/master/dyhead/dyrelu.py - Args: - channels (int): The input (and output) channels of DyReLU module. - ratio (int): Squeeze ratio in Squeeze-and-Excitation-like module, - the intermediate channel will be ``int(channels/ratio)``. - Default: 4. - conv_cfg (None or dict): Config dict for convolution layer. - Default: None, which means using conv2d. - act_cfg (dict or Sequence[dict]): Config dict for activation layer. - If act_cfg is a dict, two activation layers will be configurated - by this dict. If act_cfg is a sequence of dicts, the first - activation layer will be configurated by the first dict and the - second activation layer will be configurated by the second dict. - Default: (dict(type='ReLU'), dict(type='HSigmoid', bias=3.0, - divisor=6.0)) - init_cfg (dict or list[dict], optional): Initialization config dict. - Default: None - """ - - def __init__(self, - channels, - ratio=4, - conv_cfg=None, - act_cfg=(dict(type='ReLU'), - dict(type='HSigmoid', bias=3.0, divisor=6.0)), - init_cfg=None): - super().__init__(init_cfg=init_cfg) - if isinstance(act_cfg, dict): - act_cfg = (act_cfg, act_cfg) - assert len(act_cfg) == 2 - assert mmcv.is_tuple_of(act_cfg, dict) - self.channels = channels - self.expansion = 4 # for a1, b1, a2, b2 - self.global_avgpool = nn.AdaptiveAvgPool2d(1) - self.conv1 = ConvModule( - in_channels=channels, - out_channels=int(channels / ratio), - kernel_size=1, - stride=1, - conv_cfg=conv_cfg, - act_cfg=act_cfg[0]) - self.conv2 = ConvModule( - in_channels=int(channels / ratio), - out_channels=channels * self.expansion, - kernel_size=1, - stride=1, - conv_cfg=conv_cfg, - act_cfg=act_cfg[1]) - - def forward(self, x): - """Forward function.""" - coeffs = self.global_avgpool(x) - coeffs = self.conv1(coeffs) - coeffs = self.conv2(coeffs) - 0.5 # value range: [-0.5, 0.5] - a1, b1, a2, b2 = torch.split(coeffs, self.channels, dim=1) - a1 = a1 * 2.0 + 1.0 # [-1.0, 1.0] + 1.0 - a2 = a2 * 2.0 # [-1.0, 1.0] - out = torch.max(x * a1 + b1, x * a2 + b2) - return \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/requirement.txt b/docker-hub/MapTRv2/MapTR/requirement.txt deleted file mode 100644 index c1c4dfa3934deb5047cf7b60e1fe0e7a624e394b..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/requirement.txt +++ /dev/null @@ -1,2 +0,0 @@ -shapely==1.8.5.post1 -av2 \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/test.py b/docker-hub/MapTRv2/MapTR/test.py deleted file mode 100644 index f0badf7b41bf5adcaddd33bdd8f492e522fc6718..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/test.py +++ /dev/null @@ -1,7 +0,0 @@ -import torch - -x = torch.rand(2, 3) -y = torch.rand(3, 3) -z = [x, y] -z = torch.as_tensor(z, device="cuda") -print(z.shape) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/tools/data_converter/av2_converter.py b/docker-hub/MapTRv2/MapTR/tools/data_converter/av2_converter.py deleted file mode 100644 index 2c4898384fa943313a30a4f70297fa6463a2f476..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/data_converter/av2_converter.py +++ /dev/null @@ -1,204 +0,0 @@ -from functools import partial -from multiprocessing import Pool -import multiprocessing -from random import sample -import time -import mmcv -import logging -from pathlib import Path -from os import path as osp -import os -from av2.datasets.sensor.av2_sensor_dataloader import AV2SensorDataLoader -from av2.map.lane_segment import LaneMarkType, LaneSegment -from av2.map.map_api import ArgoverseStaticMap -from tqdm import tqdm -import argparse - -CAM_NAMES = ['ring_front_center', 'ring_front_right', 'ring_front_left', - 'ring_rear_right','ring_rear_left', 'ring_side_right', 'ring_side_left', - # 'stereo_front_left', 'stereo_front_right', - ] -# some fail logs as stated in av2 -# https://github.com/argoverse/av2-api/blob/05b7b661b7373adb5115cf13378d344d2ee43906/src/av2/map/README.md#training-online-map-inference-models -FAIL_LOGS = [ - '75e8adad-50a6-3245-8726-5e612db3d165', - '54bc6dbc-ebfb-3fba-b5b3-57f88b4b79ca', - 'af170aac-8465-3d7b-82c5-64147e94af7d', - '6e106cf8-f6dd-38f6-89c8-9be7a71e7275', - '01bb304d-7bd8-35f8-bbef-7086b688e35e', - '453e5558-6363-38e3-bf9b-42b5ba0a6f1d' -] - -def parse_args(): - parser = argparse.ArgumentParser(description='Data converter arg parser') - parser.add_argument( - '--data-root', - type=str, - help='specify the root path of dataset') - parser.add_argument( - '--nproc', - type=int, - default=64, - required=False, - help='workers to process data') - args = parser.parse_args() - return args - -def create_av2_infos_mp(root_path, - info_prefix, - dest_path=None, - split='train', - num_multithread=64): - """Create info file of av2 dataset. - - Given the raw data, generate its related info file in pkl format. - - Args: - root_path (str): Path of the data root. - info_prefix (str): Prefix of the info file to be generated. - dest_path (str): Path to store generated file, default to root_path - split (str): Split of the data. - Default: 'train' - """ - root_path = osp.join(root_path, split) - if dest_path is None: - dest_path = root_path - - loader = AV2SensorDataLoader(Path(root_path), Path(root_path)) - log_ids = list(loader.get_log_ids()) - # import pdb;pdb.set_trace() - for l in FAIL_LOGS: - if l in log_ids: - log_ids.remove(l) - - print('collecting samples...') - start_time = time.time() - print('num cpu:', multiprocessing.cpu_count()) - print(f'using {num_multithread} threads') - - # to supress logging from av2.utils.synchronization_database - sdb_logger = logging.getLogger('av2.utils.synchronization_database') - prev_level = sdb_logger.level - sdb_logger.setLevel(logging.CRITICAL) - - # FIXME: need to check the order - pool = Pool(num_multithread) - fn = partial(get_data_from_logid, loader=loader, data_root=root_path) - rt = pool.map_async(fn, log_ids) - pool.close() - pool.join() - results = rt.get() - - samples = [] - discarded = 0 - sample_idx = 0 - for _samples, _discarded in results: - for i in range(len(_samples)): - _samples[i]['sample_idx'] = sample_idx - sample_idx += 1 - samples += _samples - discarded += _discarded - - sdb_logger.setLevel(prev_level) - print(f'{len(samples)} available samples, {discarded} samples discarded') - - id2map = {} - for log_id in log_ids: - log_map_dirpath = Path(osp.join(root_path, log_id, "map")) - vector_data_fnames = sorted(log_map_dirpath.glob("log_map_archive_*.json")) - # vector_data_fnames = sorted(log_map_dirpath.glob("log_map_archive_*.json")) - if not len(vector_data_fnames) == 1: - raise RuntimeError(f"JSON file containing vector map data is missing (searched in {log_map_dirpath})") - vector_data_fname = vector_data_fnames[0] - vector_data_json_path = vector_data_fname - avm = ArgoverseStaticMap.from_json(vector_data_json_path) - # import pdb;pdb.set_trace() - map_elements = {} - map_elements['divider'] = get_divider(avm) - map_elements['ped_crossing'] = get_ped(avm) - map_elements['boundary'] = get_boundary(avm) - - # map_fname = osp.join(map_path_dir, map_fname) - id2map[log_id] = map_elements - - print('collected in {}s'.format(time.time()-start_time)) - infos = dict(samples=samples, id2map=id2map) - - info_path = osp.join(dest_path, - '{}_map_infos_{}.pkl'.format(info_prefix, split)) - print(f'saving results to {info_path}') - mmcv.dump(infos, info_path) - # mmcv.dump(samples, info_path) - -def get_divider(avm): - divider_list = [] - for ls in avm.get_scenario_lane_segments(): - for bound_type, bound_city in zip([ls.left_mark_type, ls.right_mark_type], [ls.left_lane_boundary, ls.right_lane_boundary]): - if bound_type not in [LaneMarkType.NONE,]: - divider_list.append(bound_city.xyz) - return divider_list - -def get_boundary(avm): - boundary_list = [] - for da in avm.get_scenario_vector_drivable_areas(): - boundary_list.append(da.xyz) - return boundary_list - -def get_ped(avm): - ped_list = [] - for pc in avm.get_scenario_ped_crossings(): - ped_list.append(pc.polygon) - return ped_list - -def get_data_from_logid(log_id, loader: AV2SensorDataLoader, data_root): - samples = [] - discarded = 0 - - # We use lidar timestamps to query all sensors. - # The frequency is 10Hz - cam_timestamps = loader._sdb.per_log_lidar_timestamps_index[log_id] - for ts in cam_timestamps: - cam_ring_fpath = [loader.get_closest_img_fpath( - log_id, cam_name, ts - ) for cam_name in CAM_NAMES] - lidar_fpath = loader.get_closest_lidar_fpath(log_id, ts) - - # If bad sensor synchronization, discard the sample - if None in cam_ring_fpath or lidar_fpath is None: - discarded += 1 - continue - - cams = {} - for i, cam_name in enumerate(CAM_NAMES): - pinhole_cam = loader.get_log_pinhole_camera(log_id, cam_name) - cams[cam_name] = dict( - img_fpath=str(cam_ring_fpath[i]), - intrinsics=pinhole_cam.intrinsics.K, - extrinsics=pinhole_cam.extrinsics, - ) - - city_SE3_ego = loader.get_city_SE3_ego(log_id, int(ts)) - e2g_translation = city_SE3_ego.translation - e2g_rotation = city_SE3_ego.rotation - - samples.append(dict( - e2g_translation=e2g_translation, - e2g_rotation=e2g_rotation, - cams=cams, - lidar_fpath=str(lidar_fpath), - # map_fpath=map_fname, - timestamp=str(ts), - log_id=log_id, - token=str(log_id+'_'+str(ts)))) - - return samples, discarded - - -if __name__ == '__main__': - args = parse_args() - for name in ['train', 'val', 'test']: - create_av2_infos_mp( - root_path=args.data_root, - split=name, - info_prefix='av2', - dest_path=args.data_root,) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/tools/dist_train_numa.sh b/docker-hub/MapTRv2/MapTR/tools/dist_train_numa.sh deleted file mode 100644 index 822bfee29bf8dd05fa6411cfd0202d6f27768649..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/dist_train_numa.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -MASTER_ADDR=${1:-localhost} -MASTER_PORT=6000 -NNODES=${2:-1} -NODE_RANK=${3:-0} -GPUS_PER_NODE=8 -DISTRIBUTED_ARGS="--nproc_per_node $GPUS_PER_NODE --nnodes $NNODES --node_rank $NODE_RANK --master_addr $MASTER_ADDR --master_port $MASTER_PORT" - -CONFIG=$4 - -# add numa affinity config -PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ -torchrun $DISTRIBUTED_ARGS --no-python \ - bash -c ' - numa_map=( $(hy-smi --showtopo | grep "Numa Node" | awk "{print \$6}") ); - LOCAL_RANK=${LOCAL_RANK:-0} - NUMA_ID=${numa_map[$LOCAL_RANK]} - numactl --cpunodebind=${NUMA_ID} --membind=${NUMA_ID} python $(dirname "$0")/tools/train.py "$@" - ' _ $CONFIG --launcher pytorch ${@:5} --deterministic diff --git a/docker-hub/MapTRv2/MapTR/tools/fp16/train.py b/docker-hub/MapTRv2/MapTR/tools/fp16/train.py deleted file mode 100644 index eddc34952266773a6035c5acf76f8fe61945a632..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/fp16/train.py +++ /dev/null @@ -1,271 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from __future__ import division - -import argparse -import copy -import mmcv -import os -import time -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.runner import get_dist_info, init_dist, wrap_fp16_model -from os import path as osp - -from mmdet import __version__ as mmdet_version -from mmdet3d import __version__ as mmdet3d_version -#from mmdet3d.apis import train_model - -from mmdet3d.datasets import build_dataset -from mmdet3d.models import build_model -from mmdet3d.utils import collect_env, get_root_logger -from mmdet.apis import set_random_seed -from mmseg import __version__ as mmseg_version - -from mmcv.utils import TORCH_VERSION, digit_version - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a detector') - parser.add_argument('config', help='train config file path') - parser.add_argument('--work-dir', help='the dir to save logs and models') - parser.add_argument( - '--resume-from', help='the checkpoint file to resume from') - parser.add_argument( - '--no-validate', - action='store_true', - help='whether not to evaluate the checkpoint during training') - group_gpus = parser.add_mutually_exclusive_group() - group_gpus.add_argument( - '--gpus', - type=int, - help='number of gpus to use ' - '(only applicable to non-distributed training)') - group_gpus.add_argument( - '--gpu-ids', - type=int, - nargs='+', - help='ids of gpus to use ' - '(only applicable to non-distributed training)') - parser.add_argument('--seed', type=int, default=0, help='random seed') - parser.add_argument( - '--deterministic', - action='store_true', - help='whether to set deterministic options for CUDNN backend.') - parser.add_argument( - '--options', - nargs='+', - action=DictAction, - help='override some settings in the used config, the key-value pair ' - 'in xxx=yyy format will be merged into config file (deprecate), ' - 'change to --cfg-options instead.') - parser.add_argument( - '--cfg-options', - nargs='+', - action=DictAction, - help='override some settings in the used config, the key-value pair ' - 'in xxx=yyy format will be merged into config file. If the value to ' - 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' - 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' - 'Note that the quotation marks are necessary and that no white space ' - 'is allowed.') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - parser.add_argument( - '--autoscale-lr', - action='store_true', - help='automatically scale lr with the number of gpus') - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - - if args.options and args.cfg_options: - raise ValueError( - '--options and --cfg-options cannot be both specified, ' - '--options is deprecated in favor of --cfg-options') - if args.options: - warnings.warn('--options is deprecated in favor of --cfg-options') - args.cfg_options = args.options - - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - if args.cfg_options is not None: - cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - from projects.mmdet3d_plugin.bevformer.apis import custom_train_model - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - - # work_dir is determined in this priority: CLI > segment in file > filename - if args.work_dir is not None: - # update configs according to CLI args if args.work_dir is not None - cfg.work_dir = args.work_dir - elif cfg.get('work_dir', None) is None: - # use config filename as default work_dir if cfg.work_dir is None - cfg.work_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0]) - #if args.resume_from is not None: - - if args.resume_from is not None and osp.isfile(args.resume_from): - cfg.resume_from = args.resume_from - - if args.gpu_ids is not None: - cfg.gpu_ids = args.gpu_ids - else: - cfg.gpu_ids = range(1) if args.gpus is None else range(args.gpus) - if digit_version(TORCH_VERSION) != digit_version('1.8.1'): - cfg.optimizer['type'] = 'AdamW' - if args.autoscale_lr: - # apply the linear scaling rule (https://arxiv.org/abs/1706.02677) - cfg.optimizer['lr'] = cfg.optimizer['lr'] * len(cfg.gpu_ids) / 8 - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - assert False, 'DOT NOT SUPPORT!!!' - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - # re-set gpu_ids with distributed training mode - _, world_size = get_dist_info() - cfg.gpu_ids = range(world_size) - - # create work_dir - mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) - # dump config - cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config))) - # init the logger before other steps - timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime()) - log_file = osp.join(cfg.work_dir, f'{timestamp}.log') - # specify logger name, if we still use 'mmdet', the output info will be - # filtered and won't be saved in the log_file - # TODO: ugly workaround to judge whether we are training det or seg model - if cfg.model.type in ['EncoderDecoder3D']: - logger_name = 'mmseg' - else: - logger_name = 'mmdet' - logger = get_root_logger( - log_file=log_file, log_level=cfg.log_level, name=logger_name) - - # init the meta dict to record some important information such as - # environment info and seed, which will be logged - meta = dict() - # log env info - env_info_dict = collect_env() - env_info = '\n'.join([(f'{k}: {v}') for k, v in env_info_dict.items()]) - dash_line = '-' * 60 + '\n' - logger.info('Environment info:\n' + dash_line + env_info + '\n' + - dash_line) - meta['env_info'] = env_info - meta['config'] = cfg.pretty_text - - # log some basic info - logger.info(f'Distributed training: {distributed}') - logger.info(f'Config:\n{cfg.pretty_text}') - - # set random seeds - if args.seed is not None: - logger.info(f'Set random seed to {args.seed}, ' - f'deterministic: {args.deterministic}') - set_random_seed(args.seed, deterministic=args.deterministic) - cfg.seed = args.seed - meta['seed'] = args.seed - meta['exp_name'] = osp.basename(args.config) - - model = build_model( - cfg.model, - train_cfg=cfg.get('train_cfg'), - test_cfg=cfg.get('test_cfg')) - model.init_weights() - - eval_model_config = copy.deepcopy(cfg.model) - eval_model = build_model( - eval_model_config, - train_cfg=cfg.get('train_cfg'), - test_cfg=cfg.get('test_cfg')) - - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(eval_model) - - #eval_model.init_weights() - eval_model.load_state_dict(model.state_dict()) - - logger.info(f'Model:\n{model}') - from projects.mmdet3d_plugin.datasets import custom_build_dataset - datasets = [custom_build_dataset(cfg.data.train)] - if len(cfg.workflow) == 2: - val_dataset = copy.deepcopy(cfg.data.val) - # in case we use a dataset wrapper - if 'dataset' in cfg.data.train: - val_dataset.pipeline = cfg.data.train.dataset.pipeline - else: - val_dataset.pipeline = cfg.data.train.pipeline - # set test_mode=False here in deep copied config - # which do not affect AP/AR calculation later - # refer to https://mmdetection3d.readthedocs.io/en/latest/tutorials/customize_runtime.html#customize-workflow # noqa - val_dataset.test_mode = False - datasets.append(custom_build_dataset(val_dataset)) - if cfg.checkpoint_config is not None: - # save mmdet version, config file content and class names in - # checkpoints as meta data - cfg.checkpoint_config.meta = dict( - mmdet_version=mmdet_version, - mmseg_version=mmseg_version, - mmdet3d_version=mmdet3d_version, - config=cfg.pretty_text, - CLASSES=datasets[0].CLASSES, - PALETTE=datasets[0].PALETTE # for segmentors - if hasattr(datasets[0], 'PALETTE') else None) - # add an attribute for visualization convenience - model.CLASSES = datasets[0].CLASSES - custom_train_model( - model, - datasets, - cfg, - eval_model=eval_model, - distributed=distributed, - validate=(not args.no_validate), - timestamp=timestamp, - meta=meta) - - -if __name__ == '__main__': - main() diff --git a/docker-hub/MapTRv2/MapTR/tools/maptr/benchmark.py b/docker-hub/MapTRv2/MapTR/tools/maptr/benchmark.py deleted file mode 100644 index 8c9f01d2e032702a4572eae6f659c98b094c5878..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptr/benchmark.py +++ /dev/null @@ -1,125 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import argparse -import time -import torch -from mmcv import Config -from mmcv.parallel import MMDataParallel -from mmcv.runner import load_checkpoint, wrap_fp16_model -import sys -import os -sys.path.append('.') -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.datasets import custom_build_dataset -# from mmdet3d.datasets import build_dataloader, build_dataset -from mmdet3d.models import build_detector -#from tools.misc.fuse_conv_bn import fuse_module - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet benchmark a model') - parser.add_argument('config', help='test config file path') - parser.add_argument('--checkpoint', default=None, help='checkpoint file') - parser.add_argument('--samples', default=2000, help='samples to benchmark') - parser.add_argument( - '--log-interval', default=50, help='interval of logging') - parser.add_argument( - '--fuse-conv-bn', - action='store_true', - help='Whether to fuse conv and bn, this will slightly increase' - 'the inference speed') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - print(cfg.data.test) - dataset = custom_build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - samples_per_gpu=1, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=False, - shuffle=False) - - # build the model and load checkpoint - cfg.model.train_cfg = None - model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg')) - n_parameters = sum(p.numel() for p in model.parameters() if p.requires_grad) - print('***********number of params:', n_parameters) - - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - if args.checkpoint is not None: - load_checkpoint(model, args.checkpoint, map_location='cpu') - #if args.fuse_conv_bn: - # model = fuse_module(model) - - model = MMDataParallel(model, device_ids=[0]) - - model.eval() - - # the first several iterations may be very slow so skip them - num_warmup = 5 - pure_inf_time = 0 - - # benchmark with several samples and take the average - for i, data in enumerate(data_loader): - torch.cuda.synchronize() - start_time = time.perf_counter() - with torch.no_grad(): - model(return_loss=False, rescale=True, **data) - - torch.cuda.synchronize() - elapsed = time.perf_counter() - start_time - - if i >= num_warmup: - pure_inf_time += elapsed - if (i + 1) % args.log_interval == 0: - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Done image [{i + 1:<3}/ {args.samples}], ' - f'fps: {fps:.1f} img / s') - - if (i + 1) == args.samples: - pure_inf_time += elapsed - fps = (i + 1 - num_warmup) / pure_inf_time - print(f'Overall fps: {fps:.1f} img / s') - break - - -if __name__ == '__main__': - main() diff --git a/docker-hub/MapTRv2/MapTR/tools/maptr/generate_papervis.py b/docker-hub/MapTRv2/MapTR/tools/maptr/generate_papervis.py deleted file mode 100644 index 79c884b369fddd44ab28697c546954af19d1b637..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptr/generate_papervis.py +++ /dev/null @@ -1,104 +0,0 @@ -import os.path as osp -import argparse -import os -import glob -import cv2 -import mmcv -CAMS = ['FRONT_LEFT','FRONT','FRONT_RIGHT', - 'BACK_LEFT','BACK','BACK_RIGHT',] -VIEWS_NAME = 'surroud_view.jpg' -GT_MAP_NAME = 'GT_fixednum_pts_MAP.png' -PRED_MAP_NAME = 'PRED_MAP_plot.png' - -def parse_args(): - parser = argparse.ArgumentParser(description='vis hdmaptr map gt label') - parser.add_argument('visdir', help='visualize directory') - # parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--sample-name', default='SAMPLE_VIS.png', type=str) - args = parser.parse_args() - return args - -def main(): - args = parse_args() - parent_dir = osp.join(args.visdir,'..') - vis_subdir_list = [] - - file_list = os.listdir(args.visdir) - prog_bar = mmcv.ProgressBar(len(file_list)) - for file in file_list: - file_path = osp.join(args.visdir, file) - if os.path.isdir(file_path): - vis_subdir_list.append(file_path) - sample_path = osp.join(file_path,args.sample_name) - row_1_list = [] - for cam in CAMS[:3]: - cam_img_name = 'CAM_'+ cam + '.jpg' - cam_img = cv2.imread(osp.join(file_path, cam_img_name)) - # import pdb;pdb.set_trace() - lw = 8 - tf = max(lw - 1, 1) - w, h = cv2.getTextSize(cam, 0, fontScale=lw / 3, thickness=tf)[0] # text width, height - p1 = (0,0) - p2 = (w,h+3) - color=(0, 0, 0) - txt_color=(255, 255, 255) - cv2.rectangle(cam_img, p1, p2, color, -1, cv2.LINE_AA) # filled - cv2.putText(cam_img, - cam, (p1[0], p1[1] + h + 2), - 0, - lw / 3, - txt_color, - thickness=tf, - lineType=cv2.LINE_AA) - row_1_list.append(cam_img) - row_2_list = [] - for cam in CAMS[3:]: - cam_img_name = 'CAM_'+ cam + '.jpg' - cam_img = cv2.imread(osp.join(file_path, cam_img_name)) - if cam == 'BACK': - cam_img = cv2.flip(cam_img, 1) - # import pdb;pdb.set_trace() - lw = 8 - tf = max(lw - 1, 1) - w, h = cv2.getTextSize(cam, 0, fontScale=lw / 3, thickness=tf)[0] # text width, height - p1 = (0,0) - p2 = (w,h+3) - color=(0, 0, 0) - txt_color=(255, 255, 255) - cv2.rectangle(cam_img, p1, p2, color, -1, cv2.LINE_AA) # filled - cv2.putText(cam_img, - cam, (p1[0], p1[1] + h + 2), - 0, - lw / 3, - txt_color, - thickness=tf, - lineType=cv2.LINE_AA) - row_2_list.append(cam_img) - row_1_img=cv2.hconcat(row_1_list) - row_2_img=cv2.hconcat(row_2_list) - cams_img = cv2.vconcat([row_1_img,row_2_img]) - - - map_img = cv2.imread(osp.join(file_path,PRED_MAP_NAME)) - gt_map_img = cv2.imread(osp.join(file_path,GT_MAP_NAME)) - map_img = cv2.copyMakeBorder(map_img, 10, 10, 10, 10, cv2.BORDER_CONSTANT, None, value = 0) - gt_map_img = cv2.copyMakeBorder(gt_map_img, 10, 10, 10, 10, cv2.BORDER_CONSTANT, None, value = 0) - - cams_h,cam_w,_ = cams_img.shape - map_h,map_w,_ = map_img.shape - resize_ratio = cams_h / map_h - resized_w = map_w * resize_ratio - resized_map_img = cv2.resize(map_img,(int(resized_w),int(cams_h))) - resized_gt_map_img = cv2.resize(gt_map_img,(int(resized_w),int(cams_h))) - - - - sample_img = cv2.hconcat([cams_img, resized_map_img,resized_gt_map_img]) - cv2.imwrite(sample_path, sample_img) - prog_bar.update() - print('DONE!') - - -if __name__ == '__main__': - main() - diff --git a/docker-hub/MapTRv2/MapTR/tools/maptr/generate_video.py b/docker-hub/MapTRv2/MapTR/tools/maptr/generate_video.py deleted file mode 100644 index 145af87c137d2979d770734064bd0e6e06dd8db3..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptr/generate_video.py +++ /dev/null @@ -1,131 +0,0 @@ -import os.path as osp -import argparse -import os -import glob -import cv2 -import mmcv -CAMS = ['FRONT_LEFT','FRONT','FRONT_RIGHT', - 'BACK_LEFT','BACK','BACK_RIGHT',] -GT_MAP_NAME = 'GT_fixednum_pts_MAP.png' -PRED_MAP_NAME = 'PRED_MAP_plot.png' - -def parse_args(): - parser = argparse.ArgumentParser(description='vis hdmaptr map gt label') - parser.add_argument('visdir', help='visualize directory') - # parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--fps', default=10, type=int, help='fps to generate video') - parser.add_argument('--video-name', default='demo',type=str) - parser.add_argument('--sample-name', default='SAMPLE_VIS.jpg', type=str) - args = parser.parse_args() - return args - -def main(): - args = parse_args() - parent_dir = osp.join(args.visdir,'..') - vis_subdir_list = [] - # import pdb;pdb.set_trace() - size = (1680,450) - # fourcc = cv2.VideoWriter_fourcc(*'mp4v') - # fourcc = cv2.VideoWriter_fourcc(*'MP4V') - fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') - video_path = osp.join(parent_dir,'%s.mp4' % args.video_name) - video = cv2.VideoWriter(video_path, fourcc, args.fps, size, True) - file_list = os.listdir(args.visdir) - prog_bar = mmcv.ProgressBar(len(file_list)) - for file in file_list: - file_path = osp.join(args.visdir, file) - if os.path.isdir(file_path): - vis_subdir_list.append(file_path) - sample_path = osp.join(file_path,args.sample_name) - row_1_list = [] - for cam in CAMS[:3]: - cam_img_name = 'CAM_'+ cam + '.jpg' - cam_img = cv2.imread(osp.join(file_path, cam_img_name)) - lw = 8 - tf = max(lw - 1, 1) - w, h = cv2.getTextSize(cam, 0, fontScale=lw / 3, thickness=tf)[0] # text width, height - p1 = (0,0) - p2 = (w,h+3) - color=(0, 0, 0) - txt_color=(255, 255, 255) - cv2.rectangle(cam_img, p1, p2, color, -1, cv2.LINE_AA) # filled - cv2.putText(cam_img, - cam, (p1[0], p1[1] + h + 2), - 0, - lw / 3, - txt_color, - thickness=tf, - lineType=cv2.LINE_AA) - row_1_list.append(cam_img) - row_2_list = [] - for cam in CAMS[3:]: - cam_img_name = 'CAM_'+cam + '.jpg' - cam_img = cv2.imread(osp.join(file_path, cam_img_name)) - if cam == 'BACK': - cam_img = cv2.flip(cam_img, 1) - lw = 8 - tf = max(lw - 1, 1) - w, h = cv2.getTextSize(cam, 0, fontScale=lw / 3, thickness=tf)[0] # text width, height - p1 = (0,0) - p2 = (w,h+3) - color=(0, 0, 0) - txt_color=(255, 255, 255) - cv2.rectangle(cam_img, p1, p2, color, -1, cv2.LINE_AA) # filled - cv2.putText(cam_img, - cam, (p1[0], p1[1] + h + 2), - 0, - lw / 3, - txt_color, - thickness=tf, - lineType=cv2.LINE_AA) - row_2_list.append(cam_img) - row_1_img=cv2.hconcat(row_1_list) - row_2_img=cv2.hconcat(row_2_list) - cams_img = cv2.vconcat([row_1_img,row_2_img]) - - map_img = cv2.imread(osp.join(file_path,PRED_MAP_NAME)) - gt_map_img = cv2.imread(osp.join(file_path,GT_MAP_NAME)) - - map_img = cv2.copyMakeBorder(map_img, 10, 10, 10, 10, cv2.BORDER_CONSTANT, None, value = 0) - gt_map_img = cv2.copyMakeBorder(gt_map_img, 10, 10, 10, 10, cv2.BORDER_CONSTANT, None, value = 0) - - - cams_h,cam_w,_ = cams_img.shape - map_h,map_w,_ = map_img.shape - resize_ratio = cams_h / map_h - resized_w = map_w * resize_ratio - resized_map_img = cv2.resize(map_img,(int(resized_w),int(cams_h))) - resized_gt_map_img = cv2.resize(gt_map_img,(int(resized_w),int(cams_h))) - - # font - font = cv2.FONT_HERSHEY_SIMPLEX - # fontScale - fontScale = 2 - # Line thickness of 2 px - thickness = 5 - # org - org = (20, 50) - # Blue color in BGR - color = (0, 0, 255) - # Using cv2.putText() method - resized_map_img = cv2.putText(resized_map_img, 'PRED', org, font, - fontScale, color, thickness, cv2.LINE_AA) - resized_gt_map_img = cv2.putText(resized_gt_map_img, 'GT', org, font, - fontScale, color, thickness, cv2.LINE_AA) - - sample_img = cv2.hconcat([cams_img, resized_map_img, resized_gt_map_img]) - cv2.imwrite(sample_path, sample_img,[cv2.IMWRITE_JPEG_QUALITY, 70]) - # import pdb;pdb.set_trace() - resized_img = cv2.resize(sample_img,size) - - video.write(resized_img) - prog_bar.update() - # import pdb;pdb.set_trace() - video.release() - - cv2.destroyAllWindows() - - -if __name__ == '__main__': - main() - diff --git a/docker-hub/MapTRv2/MapTR/tools/maptr/vis_pred.py b/docker-hub/MapTRv2/MapTR/tools/maptr/vis_pred.py deleted file mode 100644 index 157ef5fe224a577dcbca2af2dd642537da0d08ec..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptr/vis_pred.py +++ /dev/null @@ -1,393 +0,0 @@ -import argparse -import mmcv -import os -import shutil -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.cnn import fuse_conv_bn -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, - wrap_fp16_model) -from mmdet3d.utils import collect_env, get_root_logger -from mmdet3d.apis import single_gpu_test -from mmdet3d.datasets import build_dataset -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from mmdet3d.models import build_model -from mmdet.apis import set_random_seed -from projects.mmdet3d_plugin.bevformer.apis.test import custom_multi_gpu_test -from mmdet.datasets import replace_ImageToTensor -import time -import os.path as osp -import numpy as np -from PIL import Image -import matplotlib.pyplot as plt -from matplotlib import transforms -from matplotlib.patches import Rectangle -import cv2 - -CAMS = ['CAM_FRONT_LEFT','CAM_FRONT','CAM_FRONT_RIGHT', - 'CAM_BACK_LEFT','CAM_BACK','CAM_BACK_RIGHT',] -# we choose these samples not because it is easy but because it is hard -CANDIDATE=['n008-2018-08-01-15-16-36-0400_1533151184047036', - 'n008-2018-08-01-15-16-36-0400_1533151200646853', - 'n008-2018-08-01-15-16-36-0400_1533151274047332', - 'n008-2018-08-01-15-16-36-0400_1533151369947807', - 'n008-2018-08-01-15-16-36-0400_1533151581047647', - 'n008-2018-08-01-15-16-36-0400_1533151585447531', - 'n008-2018-08-01-15-16-36-0400_1533151741547700', - 'n008-2018-08-01-15-16-36-0400_1533151854947676', - 'n008-2018-08-22-15-53-49-0400_1534968048946931', - 'n008-2018-08-22-15-53-49-0400_1534968255947662', - 'n008-2018-08-01-15-16-36-0400_1533151616447606', - 'n015-2018-07-18-11-41-49+0800_1531885617949602', - 'n008-2018-08-28-16-43-51-0400_1535489136547616', - 'n008-2018-08-28-16-43-51-0400_1535489145446939', - 'n008-2018-08-28-16-43-51-0400_1535489152948944', - 'n008-2018-08-28-16-43-51-0400_1535489299547057', - 'n008-2018-08-28-16-43-51-0400_1535489317946828', - 'n008-2018-09-18-15-12-01-0400_1537298038950431', - 'n008-2018-09-18-15-12-01-0400_1537298047650680', - 'n008-2018-09-18-15-12-01-0400_1537298056450495', - 'n008-2018-09-18-15-12-01-0400_1537298074700410', - 'n008-2018-09-18-15-12-01-0400_1537298088148941', - 'n008-2018-09-18-15-12-01-0400_1537298101700395', - 'n015-2018-11-21-19-21-35+0800_1542799330198603', - 'n015-2018-11-21-19-21-35+0800_1542799345696426', - 'n015-2018-11-21-19-21-35+0800_1542799353697765', - 'n015-2018-11-21-19-21-35+0800_1542799525447813', - 'n015-2018-11-21-19-21-35+0800_1542799676697935', - 'n015-2018-11-21-19-21-35+0800_1542799758948001', - ] - -def perspective(cam_coords, proj_mat): - pix_coords = proj_mat @ cam_coords - valid_idx = pix_coords[2, :] > 0 - pix_coords = pix_coords[:, valid_idx] - pix_coords = pix_coords[:2, :] / (pix_coords[2, :] + 1e-7) - pix_coords = pix_coords.transpose(1, 0) - return pix_coords - -def parse_args(): - parser = argparse.ArgumentParser(description='vis hdmaptr map gt label') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--score-thresh', default=0.4, type=float, help='samples to visualize') - parser.add_argument( - '--show-dir', help='directory where visualizations will be saved') - parser.add_argument('--show-cam', action='store_true', help='show camera pic') - parser.add_argument( - '--gt-format', - type=str, - nargs='+', - default=['fixed_num_pts',], - help='vis format, default should be "points",' - 'support ["se_pts","bbox","fixed_num_pts","polyline_pts"]') - args = parser.parse_args() - return args - -def main(): - args = parse_args() - cfg = Config.fromfile(args.config) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - - cfg.model.pretrained = None - # in case the test dataset is concatenated - samples_per_gpu = 1 - if isinstance(cfg.data.test, dict): - cfg.data.test.test_mode = True - samples_per_gpu = cfg.data.test.pop('samples_per_gpu', 1) - if samples_per_gpu > 1: - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.test.pipeline = replace_ImageToTensor( - cfg.data.test.pipeline) - elif isinstance(cfg.data.test, list): - for ds_cfg in cfg.data.test: - ds_cfg.test_mode = True - samples_per_gpu = max( - [ds_cfg.pop('samples_per_gpu', 1) for ds_cfg in cfg.data.test]) - if samples_per_gpu > 1: - for ds_cfg in cfg.data.test: - ds_cfg.pipeline = replace_ImageToTensor(ds_cfg.pipeline) - - if args.show_dir is None: - args.show_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0], - 'vis_pred') - # create vis_label dir - mmcv.mkdir_or_exist(osp.abspath(args.show_dir)) - cfg.dump(osp.join(args.show_dir, osp.basename(args.config))) - logger = get_root_logger() - logger.info(f'DONE create vis_pred dir: {args.show_dir}') - - - dataset = build_dataset(cfg.data.test) - dataset.is_vis_on_test = True #TODO, this is a hack - data_loader = build_dataloader( - dataset, - samples_per_gpu=samples_per_gpu, - # workers_per_gpu=cfg.data.workers_per_gpu, - workers_per_gpu=0, - dist=False, - shuffle=False, - nonshuffler_sampler=cfg.data.nonshuffler_sampler, - ) - logger.info('Done build test data set') - - # build the model and load checkpoint - # import pdb;pdb.set_trace() - cfg.model.train_cfg = None - # cfg.model.pts_bbox_head.bbox_coder.max_num=15 # TODO this is a hack - model = build_model(cfg.model, test_cfg=cfg.get('test_cfg')) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - logger.info('loading check point') - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - if 'CLASSES' in checkpoint.get('meta', {}): - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - # palette for visualization in segmentation tasks - if 'PALETTE' in checkpoint.get('meta', {}): - model.PALETTE = checkpoint['meta']['PALETTE'] - elif hasattr(dataset, 'PALETTE'): - # segmentation dataset has `PALETTE` attribute - model.PALETTE = dataset.PALETTE - logger.info('DONE load check point') - model = MMDataParallel(model, device_ids=[0]) - model.eval() - - img_norm_cfg = cfg.img_norm_cfg - - # get denormalized param - mean = np.array(img_norm_cfg['mean'],dtype=np.float32) - std = np.array(img_norm_cfg['std'],dtype=np.float32) - to_bgr = img_norm_cfg['to_rgb'] - - # get pc_range - pc_range = cfg.point_cloud_range - - # get car icon - car_img = Image.open('./figs/lidar_car.png') - - # get color map: divider->r, ped->b, boundary->g - colors_plt = ['orange', 'b', 'g'] - - - logger.info('BEGIN vis test dataset samples gt label & pred') - - - - bbox_results = [] - mask_results = [] - dataset = data_loader.dataset - have_mask = False - # prog_bar = mmcv.ProgressBar(len(CANDIDATE)) - prog_bar = mmcv.ProgressBar(len(dataset)) - # import pdb;pdb.set_trace() - for i, data in enumerate(data_loader): - if ~(data['gt_labels_3d'].data[0][0] != -1).any(): - # import pdb;pdb.set_trace() - logger.error(f'\n empty gt for index {i}, continue') - # prog_bar.update() - continue - - - img = data['img'][0].data[0] - img_metas = data['img_metas'][0].data[0] - gt_bboxes_3d = data['gt_bboxes_3d'].data[0] - gt_labels_3d = data['gt_labels_3d'].data[0] - - pts_filename = img_metas[0]['pts_filename'] - pts_filename = osp.basename(pts_filename) - pts_filename = pts_filename.replace('__LIDAR_TOP__', '_').split('.')[0] - # import pdb;pdb.set_trace() - # if pts_filename not in CANDIDATE: - # continue - - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - sample_dir = osp.join(args.show_dir, pts_filename) - mmcv.mkdir_or_exist(osp.abspath(sample_dir)) - - filename_list = img_metas[0]['filename'] - img_path_dict = {} - # save cam img for sample - for filepath in filename_list: - filename = osp.basename(filepath) - filename_splits = filename.split('__') - # sample_dir = filename_splits[0] - # sample_dir = osp.join(args.show_dir, sample_dir) - # mmcv.mkdir_or_exist(osp.abspath(sample_dir)) - img_name = filename_splits[1] + '.jpg' - img_path = osp.join(sample_dir,img_name) - # img_path_list.append(img_path) - shutil.copyfile(filepath,img_path) - img_path_dict[filename_splits[1]] = img_path - - # surrounding view - row_1_list = [] - for cam in CAMS[:3]: - cam_img_name = cam + '.jpg' - cam_img = cv2.imread(osp.join(sample_dir, cam_img_name)) - row_1_list.append(cam_img) - row_2_list = [] - for cam in CAMS[3:]: - cam_img_name = cam + '.jpg' - cam_img = cv2.imread(osp.join(sample_dir, cam_img_name)) - row_2_list.append(cam_img) - row_1_img=cv2.hconcat(row_1_list) - row_2_img=cv2.hconcat(row_2_list) - cams_img = cv2.vconcat([row_1_img,row_2_img]) - cams_img_path = osp.join(sample_dir,'surroud_view.jpg') - cv2.imwrite(cams_img_path, cams_img,[cv2.IMWRITE_JPEG_QUALITY, 70]) - - for vis_format in args.gt_format: - if vis_format == 'se_pts': - gt_line_points = gt_bboxes_3d[0].start_end_points - for gt_bbox_3d, gt_label_3d in zip(gt_line_points, gt_labels_3d[0]): - pts = gt_bbox_3d.reshape(-1,2).numpy() - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - elif vis_format == 'bbox': - gt_lines_bbox = gt_bboxes_3d[0].bbox - for gt_bbox_3d, gt_label_3d in zip(gt_lines_bbox, gt_labels_3d[0]): - gt_bbox_3d = gt_bbox_3d.numpy() - xy = (gt_bbox_3d[0],gt_bbox_3d[1]) - width = gt_bbox_3d[2] - gt_bbox_3d[0] - height = gt_bbox_3d[3] - gt_bbox_3d[1] - # import pdb;pdb.set_trace() - plt.gca().add_patch(Rectangle(xy,width,height,linewidth=0.4,edgecolor=colors_plt[gt_label_3d],facecolor='none')) - # plt.Rectangle(xy, width, height,color=colors_plt[gt_label_3d]) - # continue - elif vis_format == 'fixed_num_pts': - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - # gt_bboxes_3d[0].fixed_num=30 #TODO, this is a hack - gt_lines_fixed_num_pts = gt_bboxes_3d[0].fixed_num_sampled_points - for gt_bbox_3d, gt_label_3d in zip(gt_lines_fixed_num_pts, gt_labels_3d[0]): - # import pdb;pdb.set_trace() - pts = gt_bbox_3d.numpy() - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - # plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - - - plt.plot(x, y, color=colors_plt[gt_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(x, y, color=colors_plt[gt_label_3d],s=2,alpha=0.8,zorder=-1) - # plt.plot(x, y, color=colors_plt[gt_label_3d]) - # plt.scatter(x, y, color=colors_plt[gt_label_3d],s=1) - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - gt_fixedpts_map_path = osp.join(sample_dir, 'GT_fixednum_pts_MAP.png') - plt.savefig(gt_fixedpts_map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - elif vis_format == 'polyline_pts': - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - gt_lines_instance = gt_bboxes_3d[0].instance_list - # import pdb;pdb.set_trace() - for gt_line_instance, gt_label_3d in zip(gt_lines_instance, gt_labels_3d[0]): - pts = np.array(list(gt_line_instance.coords)) - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - - # plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - - # plt.plot(x, y, color=colors_plt[gt_label_3d]) - plt.plot(x, y, color=colors_plt[gt_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(x, y, color=colors_plt[gt_label_3d],s=1,alpha=0.8,zorder=-1) - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - gt_polyline_map_path = osp.join(sample_dir, 'GT_polyline_pts_MAP.png') - plt.savefig(gt_polyline_map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - else: - logger.error(f'WRONG visformat for GT: {vis_format}') - raise ValueError(f'WRONG visformat for GT: {vis_format}') - - - # import pdb;pdb.set_trace() - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - - # visualize pred - # import pdb;pdb.set_trace() - result_dic = result[0]['pts_bbox'] - boxes_3d = result_dic['boxes_3d'] # bbox: xmin, ymin, xmax, ymax - scores_3d = result_dic['scores_3d'] - labels_3d = result_dic['labels_3d'] - pts_3d = result_dic['pts_3d'] - keep = scores_3d > args.score_thresh - - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - for pred_score_3d, pred_bbox_3d, pred_label_3d, pred_pts_3d in zip(scores_3d[keep], boxes_3d[keep],labels_3d[keep], pts_3d[keep]): - - pred_pts_3d = pred_pts_3d.numpy() - pts_x = pred_pts_3d[:,0] - pts_y = pred_pts_3d[:,1] - plt.plot(pts_x, pts_y, color=colors_plt[pred_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(pts_x, pts_y, color=colors_plt[pred_label_3d],s=1,alpha=0.8,zorder=-1) - - - pred_bbox_3d = pred_bbox_3d.numpy() - xy = (pred_bbox_3d[0],pred_bbox_3d[1]) - width = pred_bbox_3d[2] - pred_bbox_3d[0] - height = pred_bbox_3d[3] - pred_bbox_3d[1] - pred_score_3d = float(pred_score_3d) - pred_score_3d = round(pred_score_3d, 2) - s = str(pred_score_3d) - - - - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - map_path = osp.join(sample_dir, 'PRED_MAP_plot.png') - plt.savefig(map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - - prog_bar.update() - - logger.info('\n DONE vis test dataset samples gt label & pred') -if __name__ == '__main__': - main() diff --git a/docker-hub/MapTRv2/MapTR/tools/maptrv2/av2_vis_pred.py b/docker-hub/MapTRv2/MapTR/tools/maptrv2/av2_vis_pred.py deleted file mode 100644 index 229c426dfd8302dca1b82db8edddf23f0cb8020f..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptrv2/av2_vis_pred.py +++ /dev/null @@ -1,511 +0,0 @@ -import argparse -import mmcv -import os -import shutil -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.cnn import fuse_conv_bn -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, - wrap_fp16_model) -from mmdet3d.utils import collect_env, get_root_logger -from mmdet3d.apis import single_gpu_test -from mmdet3d.datasets import build_dataset -import sys -sys.path.append('') -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from mmdet3d.models import build_model -from mmdet.apis import set_random_seed -from projects.mmdet3d_plugin.bevformer.apis.test import custom_multi_gpu_test -from mmdet.datasets import replace_ImageToTensor -import time -import os.path as osp -import numpy as np -from PIL import Image -import matplotlib.pyplot as plt -from matplotlib import transforms -from matplotlib.patches import Rectangle -from shapely.geometry import LineString -import cv2 -import copy - -caption_by_cam={ - 'ring_front_center':'CAM_FRONT_CENTER', - 'ring_front_right':'CAM_FRONT_RIGHT', - 'ring_front_left': 'CAM_FRONT_LEFT', - 'ring_rear_right': 'CAM_REAR_RIGHT', - 'ring_rear_left': 'CAM_REAT_LEFT', - 'ring_side_right': 'CAM_SIDE_RIGHT', - 'ring_side_left': 'CAM_SIDE_LEFT', -} -COLOR_MAPS_BGR = { - # bgr colors - 'divider': (54,137,255), - 'boundary': (0, 0, 255), - 'ped_crossing': (255, 0, 0), - 'centerline': (0,255,0), - 'drivable_area': (171, 255, 255) -} - -data_path_prefix = '/home/users/yunchi.zhang/project/MapTR' # project root - -def remove_nan_values(uv): - is_u_valid = np.logical_not(np.isnan(uv[:, 0])) - is_v_valid = np.logical_not(np.isnan(uv[:, 1])) - is_uv_valid = np.logical_and(is_u_valid, is_v_valid) - - uv_valid = uv[is_uv_valid] - return uv_valid - -def interp_fixed_dist(line, sample_dist): - ''' Interpolate a line at fixed interval. - - Args: - line (LineString): line - sample_dist (float): sample interval - - Returns: - points (array): interpolated points, shape (N, 2) - ''' - - distances = list(np.arange(sample_dist, line.length, sample_dist)) - # make sure to sample at least two points when sample_dist > line.length - distances = [0,] + distances + [line.length,] - - sampled_points = np.array([list(line.interpolate(distance).coords) - for distance in distances]).squeeze() - - return sampled_points - -def draw_visible_polyline_cv2(line, valid_pts_bool, image, color, thickness_px,map_class): - """Draw a polyline onto an image using given line segments. - Args: - line: Array of shape (K, 2) representing the coordinates of line. - valid_pts_bool: Array of shape (K,) representing which polyline coordinates are valid for rendering. - For example, if the coordinate is occluded, a user might specify that it is invalid. - Line segments touching an invalid vertex will not be rendered. - image: Array of shape (H, W, 3), representing a 3-channel BGR image - color: Tuple of shape (3,) with a BGR format color - thickness_px: thickness (in pixels) to use when rendering the polyline. - """ - line = np.round(line).astype(int) # type: ignore -# if map_class == 'centerline': -# instance = LineString(line).simplify(0.2, preserve_topology=True) -# line = np.array(list(instance.coords)) -# line = np.round(line).astype(int) - for i in range(len(line) - 1): - - if (not valid_pts_bool[i]) or (not valid_pts_bool[i + 1]): - continue - - x1 = line[i][0] - y1 = line[i][1] - x2 = line[i + 1][0] - y2 = line[i + 1][1] - - # Use anti-aliasing (AA) for curves - if map_class != 'centerline': - image = cv2.line(image, pt1=(x1, y1), pt2=(x2, y2), color=color, thickness=thickness_px, lineType=cv2.LINE_AA) - else: - image = cv2.arrowedLine(image,(x1, y1),(x2,y2),color,thickness_px,8,0,0.7) - - -def points_ego2img(pts_ego, lidar2img): - pts_ego_4d = np.concatenate([pts_ego, np.ones([len(pts_ego), 1])], axis=-1) - pts_img_4d = lidar2img @ pts_ego_4d.T - - - uv = pts_img_4d.T - uv = remove_nan_values(uv) - depth = uv[:, 2] - uv = uv[:, :2] / uv[:, 2].reshape(-1, 1) - - return uv, depth -def draw_polyline_ego_on_img(polyline_ego, img_bgr, lidar2img, map_class, thickness): - # if 2-dimension, assume z=0 - if polyline_ego.shape[1] == 2: - zeros = np.zeros((polyline_ego.shape[0], 1)) - polyline_ego = np.concatenate([polyline_ego, zeros], axis=1) - - polyline_ego = interp_fixed_dist(line=LineString(polyline_ego), sample_dist=0.2) - - uv, depth = points_ego2img(polyline_ego, lidar2img) - - h, w, c = img_bgr.shape - - is_valid_x = np.logical_and(0 <= uv[:, 0], uv[:, 0] < w - 1) - is_valid_y = np.logical_and(0 <= uv[:, 1], uv[:, 1] < h - 1) - is_valid_z = depth > 0 - is_valid_points = np.logical_and.reduce([is_valid_x, is_valid_y, is_valid_z]) - - if is_valid_points.sum() == 0: - return - - tmp_list = [] - for i, valid in enumerate(is_valid_points): - - if valid: - tmp_list.append(uv[i]) - else: - if len(tmp_list) >= 2: - tmp_vector = np.stack(tmp_list) - tmp_vector = np.round(tmp_vector).astype(np.int32) - draw_visible_polyline_cv2( - copy.deepcopy(tmp_vector), - valid_pts_bool=np.ones((len(uv), 1), dtype=bool), - image=img_bgr, - color=COLOR_MAPS_BGR[map_class], - thickness_px=thickness, - map_class=map_class - ) - tmp_list = [] - if len(tmp_list) >= 2: - tmp_vector = np.stack(tmp_list) - tmp_vector = np.round(tmp_vector).astype(np.int32) - draw_visible_polyline_cv2( - copy.deepcopy(tmp_vector), - valid_pts_bool=np.ones((len(uv), 1), dtype=bool), - image=img_bgr, - color=COLOR_MAPS_BGR[map_class], - thickness_px=thickness, - map_class=map_class, - ) - -def render_anno_on_pv(cam_img, anno, lidar2img): - for key, value in anno.items(): - for pts in value: - draw_polyline_ego_on_img(pts, cam_img, lidar2img, - key, thickness=10) - -def perspective(cam_coords, proj_mat): - pix_coords = proj_mat @ cam_coords - valid_idx = pix_coords[2, :] > 0 - pix_coords = pix_coords[:, valid_idx] - pix_coords = pix_coords[:2, :] / (pix_coords[2, :] + 1e-7) - pix_coords = pix_coords.transpose(1, 0) - return pix_coords - -def parse_args(): - parser = argparse.ArgumentParser(description='vis hdmaptr map gt label') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--score-thresh', default=0.4, type=float, help='samples to visualize') - parser.add_argument( - '--show-dir', help='directory where visualizations will be saved') - parser.add_argument('--show-cam', action='store_true', help='show camera pic') - parser.add_argument( - '--gt-format', - type=str, - nargs='+', - default=['fixed_num_pts',], - help='vis format, default should be "points",' - 'support ["se_pts","bbox","fixed_num_pts","polyline_pts"]') - args = parser.parse_args() - return args - -def main(): - args = parse_args() - cfg = Config.fromfile(args.config) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - - cfg.model.pretrained = None - # in case the test dataset is concatenated - samples_per_gpu = 1 - if isinstance(cfg.data.test, dict): - cfg.data.test.test_mode = True - samples_per_gpu = cfg.data.test.pop('samples_per_gpu', 1) - if samples_per_gpu > 1: - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.test.pipeline = replace_ImageToTensor( - cfg.data.test.pipeline) - elif isinstance(cfg.data.test, list): - for ds_cfg in cfg.data.test: - ds_cfg.test_mode = True - samples_per_gpu = max( - [ds_cfg.pop('samples_per_gpu', 1) for ds_cfg in cfg.data.test]) - if samples_per_gpu > 1: - for ds_cfg in cfg.data.test: - ds_cfg.pipeline = replace_ImageToTensor(ds_cfg.pipeline) - - if args.show_dir is None: - args.show_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0], - 'vis_pred') - # create vis_label dir - mmcv.mkdir_or_exist(osp.abspath(args.show_dir)) - cfg.dump(osp.join(args.show_dir, osp.basename(args.config))) - logger = get_root_logger() - logger.info(f'DONE create vis_pred dir: {args.show_dir}') - - - dataset = build_dataset(cfg.data.test) - dataset.is_vis_on_test = True #TODO, this is a hack - data_loader = build_dataloader( - dataset, - samples_per_gpu=samples_per_gpu, - # workers_per_gpu=cfg.data.workers_per_gpu, - workers_per_gpu=0, - dist=False, - shuffle=False, - nonshuffler_sampler=cfg.data.nonshuffler_sampler, - ) - logger.info('Done build test data set') - - # build the model and load checkpoint - # import pdb;pdb.set_trace() - cfg.model.train_cfg = None - # cfg.model.pts_bbox_head.bbox_coder.max_num=15 # TODO this is a hack - model = build_model(cfg.model, test_cfg=cfg.get('test_cfg')) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - logger.info('loading check point') - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - if 'CLASSES' in checkpoint.get('meta', {}): - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - # palette for visualization in segmentation tasks - if 'PALETTE' in checkpoint.get('meta', {}): - model.PALETTE = checkpoint['meta']['PALETTE'] - elif hasattr(dataset, 'PALETTE'): - # segmentation dataset has `PALETTE` attribute - model.PALETTE = dataset.PALETTE - logger.info('DONE load check point') - model = MMDataParallel(model, device_ids=[0]) - model.eval() - - img_norm_cfg = cfg.img_norm_cfg - - # get denormalized param - mean = np.array(img_norm_cfg['mean'],dtype=np.float32) - std = np.array(img_norm_cfg['std'],dtype=np.float32) - to_bgr = img_norm_cfg['to_rgb'] - - # get pc_range - pc_range = cfg.point_cloud_range - - # get car icon - car_img = Image.open('./figs/car.png') - - # get color map: divider->orange, ped->blue, boundary->red, centerline->green - colors_plt = ['orange', 'blue', 'red','green'] - - logger.info('BEGIN vis test dataset samples gt label & pred') - - bbox_results = [] - mask_results = [] - dataset = data_loader.dataset - have_mask = False - # prog_bar = mmcv.ProgressBar(len(CANDIDATE)) - prog_bar = mmcv.ProgressBar(len(dataset)) - # import pdb;pdb.set_trace() - final_dict = {} - for i, data in enumerate(data_loader): - if ~(data['gt_labels_3d'].data[0][0] != -1).any(): - # import pdb;pdb.set_trace() - logger.error(f'\n empty gt for index {i}, continue') - # prog_bar.update() - continue - - - img = data['img'][0].data[0] - img_metas = data['img_metas'][0].data[0] - gt_bboxes_3d = data['gt_bboxes_3d'].data[0] - gt_labels_3d = data['gt_labels_3d'].data[0] - - pts_filename = img_metas[0]['pts_filename'] - pts_filename = osp.basename(pts_filename) - pts_filename = pts_filename.split('.')[0] - # import pdb;pdb.set_trace() - # if pts_filename not in CANDIDATE: - # continue - sample_dict = {} - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - sample_dir = osp.join(args.show_dir, pts_filename) - mmcv.mkdir_or_exist(osp.abspath(sample_dir)) - - filename_list = img_metas[0]['filename'] - img_path_dict = {} - # save cam img for sample - # import ipdb;ipdb.set_trace() - for filepath, lidar2img, img_aug in zip(filename_list,img_metas[0]['lidar2img'],img_metas[0]['img_aug_matrix']): - inv_aug = np.linalg.inv(img_aug) - lidar2orimg = np.dot(inv_aug, lidar2img) - cam_name = os.path.dirname(filepath).split('/')[-1] - img_path_dict[cam_name] = dict( - filepath=filepath, - lidar2img = lidar2orimg) - sample_dict['imgs_path'] = img_path_dict - gt_dict = {'divider':[],'ped_crossing':[],'boundary':[],'centerline':[]} - # import ipdb;ipdb.set_trace() - gt_lines_instance = gt_bboxes_3d[0].instance_list - # import pdb;pdb.set_trace() - for gt_line_instance, gt_label_3d in zip(gt_lines_instance, gt_labels_3d[0]): - if gt_label_3d == 0: - gt_dict['divider'].append(np.array(list(gt_line_instance.coords))) - elif gt_label_3d == 1: - gt_dict['ped_crossing'].append(np.array(list(gt_line_instance.coords))) - elif gt_label_3d == 2: - gt_dict['boundary'].append(np.array(list(gt_line_instance.coords))) - elif gt_label_3d == 3: - gt_dict['centerline'].append(np.array(list(gt_line_instance.coords))) - else: - raise NotImplementedError - sample_dict['gt_map'] = gt_dict - - result_dict = result[0]['pts_bbox'] - sample_dict['pred_map'] = result_dict - - # visualize gt - plt.figure(figsize=(4, 2)) - plt.xlim(-30, 30) - plt.ylim(-15, 15) - plt.axis('off') - gt_centerlines = [] - for pts in gt_dict['divider']: - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.plot(x, y, color='orange',linewidth=1,alpha=0.8,zorder=-1) - - for pts in gt_dict['ped_crossing']: - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.plot(x, y, color='blue',linewidth=1,alpha=0.8,zorder=-1) - - for pts in gt_dict['boundary']: - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.plot(x, y, color='red',linewidth=1,alpha=0.8,zorder=-1) - - for pts in gt_dict['centerline']: - instance = LineString(pts).simplify(0.2, preserve_topology=True) - pts = np.array(list(instance.coords)) - gt_centerlines.append(pts) - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color='green',headwidth=5,headlength=6,width=0.006,alpha=0.8,zorder=-1) - plt.imshow(car_img, extent=[-1.5, 1.5, -1.2, 1.2]) - gt_map_path = osp.join(sample_dir, 'GT_MAP.png') - plt.savefig(gt_map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - # visualize pred - scores_3d = result_dict['scores_3d'] - labels_3d = result_dict['labels_3d'] - pts_3d = result_dict['pts_3d'] - keep = scores_3d > 0.3 - - plt.figure(figsize=(4, 2)) - plt.xlim(-30, 30) - plt.ylim(-15, 15) - plt.axis('off') - pred_centerlines=[] - pred_anno = {'divider':[],'ped_crossing':[],'boundary':[],'centerline':[]} - class_by_index=['divider','ped_crossing','boundary'] - for pred_score_3d, pred_label_3d, pred_pts_3d in zip(scores_3d[keep], labels_3d[keep], pts_3d[keep]): - if pred_label_3d == 3: - instance = LineString(pred_pts_3d.numpy()).simplify(0.2, preserve_topology=True) - pts = np.array(list(instance.coords)) - pred_anno['centerline'].append(pts) - pred_centerlines.append(pts) - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color='green',headwidth=5,headlength=6,width=0.006,alpha=0.8,zorder=-1) - else: - pred_pts_3d = pred_pts_3d.numpy() - pred_anno[class_by_index[pred_label_3d]].append(pred_pts_3d) - pts_x = pred_pts_3d[:,0] - pts_y = pred_pts_3d[:,1] - plt.plot(pts_x, pts_y, color=colors_plt[pred_label_3d],linewidth=1,alpha=0.8,zorder=-1) - # plt.scatter(pts_x, pts_y, color=colors_plt[pred_label_3d],s=1,alpha=0.8,zorder=-1) - - plt.imshow(car_img, extent=[-1.5, 1.5, -1.2, 1.2]) - map_path = osp.join(sample_dir, 'PRED_MAP.png') - plt.savefig(map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - rendered_cams_dict = {} - for key, cam_dict in img_path_dict.items(): - cam_img = cv2.imread(osp.join(data_path_prefix,cam_dict['filepath'])) - render_anno_on_pv(cam_img,pred_anno,cam_dict['lidar2img']) - if 'front' not in key: - # cam_img = cam_img[:,::-1,:] - cam_img = cv2.flip(cam_img, 1) - lw = 8 - tf = max(lw - 1, 1) - w, h = cv2.getTextSize(caption_by_cam[key], 0, fontScale=lw / 3, thickness=tf)[0] # text width, height - p1 = (0,0) - p2 = (w,h+3) - color=(0, 0, 0) - txt_color=(255, 255, 255) - cv2.rectangle(cam_img, p1, p2, color, -1, cv2.LINE_AA) # filled - cv2.putText(cam_img, - caption_by_cam[key], (p1[0], p1[1] + h + 2), - 0, - lw / 3, - txt_color, - thickness=tf, - lineType=cv2.LINE_AA) - rendered_cams_dict[key] = cam_img - - new_image_height = 2048 - new_image_width = 1550+2048*2 - color = (255,255,255) - first_row_canvas = np.full((new_image_height,new_image_width, 3), color, dtype=np.uint8) - first_row_canvas[(2048-1550):, :2048,:] = rendered_cams_dict['ring_front_left'] - first_row_canvas[:,2048:(2048+1550),:] = rendered_cams_dict['ring_front_center'] - first_row_canvas[(2048-1550):,3598:,:] = rendered_cams_dict['ring_front_right'] - - new_image_height = 1550 - new_image_width = 2048*4 - color = (255,255,255) - second_row_canvas = np.full((new_image_height,new_image_width, 3), color, dtype=np.uint8) - second_row_canvas[:,:2048,:] = rendered_cams_dict['ring_side_left'] - second_row_canvas[:,2048:4096,:] = rendered_cams_dict['ring_rear_left'] - second_row_canvas[:,4096:6144,:] = rendered_cams_dict['ring_rear_right'] - second_row_canvas[:,6144:,:] = rendered_cams_dict['ring_side_right'] - - resized_first_row_canvas = cv2.resize(first_row_canvas,(8192,2972)) - full_canvas = np.full((2972+1550,8192,3),color,dtype=np.uint8) - full_canvas[:2972,:,:] = resized_first_row_canvas - full_canvas[2972:,:,:] = second_row_canvas - cams_img_path = osp.join(sample_dir,'surroud_view.jpg') - cv2.imwrite(cams_img_path, full_canvas,[cv2.IMWRITE_JPEG_QUALITY, 70]) - - final_dict[pts_filename] = sample_dict - prog_bar.update() - - mmcv.dump(final_dict, osp.join(args.show_dir, 'final_dict.pkl')) - logger.info('\n DONE vis test dataset samples gt label & pred') -if __name__ == '__main__': - main() diff --git a/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_av2_map_converter.py b/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_av2_map_converter.py deleted file mode 100644 index 0ca852a4ee75df94d8c30da22577fbcb7ddab7b2..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_av2_map_converter.py +++ /dev/null @@ -1,797 +0,0 @@ -from functools import partial -from multiprocessing import Pool -import multiprocessing -from random import sample -import time -import mmcv -import logging -from pathlib import Path -from os import path as osp -import os -from av2.datasets.sensor.av2_sensor_dataloader import AV2SensorDataLoader -from av2.map.lane_segment import LaneMarkType, LaneSegment -from av2.map.map_api import ArgoverseStaticMap -from tqdm import tqdm -import argparse -import networkx as nx -from av2.map.map_primitives import Polyline -from nuscenes.map_expansion.map_api import NuScenesMapExplorer -from shapely import affinity, ops -from shapely.geometry import Polygon, LineString, box, MultiPolygon, MultiLineString -from shapely.strtree import STRtree -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from av2.geometry.se3 import SE3 -import numpy as np -import math -from shapely.geometry import CAP_STYLE, JOIN_STYLE -from scipy.spatial import distance -import warnings -warnings.filterwarnings("ignore") - - -CAM_NAMES = ['ring_front_center', 'ring_front_right', 'ring_front_left', - 'ring_rear_right','ring_rear_left', 'ring_side_right', 'ring_side_left', - # 'stereo_front_left', 'stereo_front_right', - ] -# some fail logs as stated in av2 -# https://github.com/argoverse/av2-api/blob/05b7b661b7373adb5115cf13378d344d2ee43906/src/av2/map/README.md#training-online-map-inference-models -FAIL_LOGS = [ - # official - '75e8adad-50a6-3245-8726-5e612db3d165', - '54bc6dbc-ebfb-3fba-b5b3-57f88b4b79ca', - 'af170aac-8465-3d7b-82c5-64147e94af7d', - '6e106cf8-f6dd-38f6-89c8-9be7a71e7275', - # observed - '01bb304d-7bd8-35f8-bbef-7086b688e35e', - '453e5558-6363-38e3-bf9b-42b5ba0a6f1d' -] - -def parse_args(): - parser = argparse.ArgumentParser(description='Data converter arg parser') - parser.add_argument( - '--data-root', - type=str, - help='specify the root path of dataset') - parser.add_argument( - '--pc-range', - type=float, - nargs='+', - default=[-30.0, -15.0, -5.0, 30.0, 15.0, 3.0], - help='specify the perception point cloud range') - parser.add_argument( - '--nproc', - type=int, - default=64, - required=False, - help='workers to process data') - args = parser.parse_args() - return args - -def create_av2_infos_mp(root_path, - info_prefix, - dest_path=None, - split='train', - num_multithread=64, - pc_range = [-30.0, -15.0, -5.0, 30.0, 15.0, 3.0]): - """Create info file of av2 dataset. - - Given the raw data, generate its related info file in pkl format. - - Args: - root_path (str): Path of the data root. - info_prefix (str): Prefix of the info file to be generated. - dest_path (str): Path to store generated file, default to root_path - split (str): Split of the data. - Default: 'train' - """ - root_path = osp.join(root_path, split) - if dest_path is None: - dest_path = root_path - - loader = AV2SensorDataLoader(Path(root_path), Path(root_path)) - log_ids = list(loader.get_log_ids()) - # import pdb;pdb.set_trace() - for l in FAIL_LOGS: - if l in log_ids: - log_ids.remove(l) - - print('collecting samples...') - start_time = time.time() - print('num cpu:', multiprocessing.cpu_count()) - print(f'using {num_multithread} threads') - - # to supress logging from av2.utils.synchronization_database - sdb_logger = logging.getLogger('av2.utils.synchronization_database') - prev_level = sdb_logger.level - sdb_logger.setLevel(logging.CRITICAL) - - # FIXME: need to check the order - pool = Pool(num_multithread) - fn = partial(get_data_from_logid, loader=loader, data_root=root_path, pc_range=pc_range) - rt = pool.map_async(fn, log_ids) - pool.close() - pool.join() - results = rt.get() - - samples = [] - discarded = 0 - sample_idx = 0 - for _samples, _discarded in results: - for i in range(len(_samples)): - _samples[i]['sample_idx'] = sample_idx - sample_idx += 1 - samples += _samples - discarded += _discarded - - sdb_logger.setLevel(prev_level) - print(f'{len(samples)} available samples, {discarded} samples discarded') - - print('collected in {}s'.format(time.time()-start_time)) - infos = dict(samples=samples) - - info_path = osp.join(dest_path, - '{}_map_infos_{}.pkl'.format(info_prefix, split)) - print(f'saving results to {info_path}') - mmcv.dump(infos, info_path) - # mmcv.dump(samples, info_path) - -def get_divider(avm): - divider_list = [] - for ls in avm.get_scenario_lane_segments(): - for bound_type, bound_city in zip([ls.left_mark_type, ls.right_mark_type], [ls.left_lane_boundary, ls.right_lane_boundary]): - if bound_type not in [LaneMarkType.NONE,]: - divider_list.append(bound_city.xyz) - return divider_list - -def get_boundary(avm): - boundary_list = [] - for da in avm.get_scenario_vector_drivable_areas(): - boundary_list.append(da.xyz) - return boundary_list - -def get_ped(avm): - ped_list = [] - for pc in avm.get_scenario_ped_crossings(): - ped_list.append(pc.polygon) - return ped_list - -def get_data_from_logid(log_id, - loader: AV2SensorDataLoader, - data_root, - pc_range = [-30.0, -15.0, -5.0, 30.0, 15.0, 3.0]): - samples = [] - discarded = 0 - - log_map_dirpath = Path(osp.join(data_root, log_id, "map")) - vector_data_fnames = sorted(log_map_dirpath.glob("log_map_archive_*.json")) - if not len(vector_data_fnames) == 1: - raise RuntimeError(f"JSON file containing vector map data is missing (searched in {log_map_dirpath})") - vector_data_fname = vector_data_fnames[0] - vector_data_json_path = vector_data_fname - avm = ArgoverseStaticMap.from_json(vector_data_json_path) - # We use lidar timestamps to query all sensors. - # The frequency is 10Hz - cam_timestamps = loader._sdb.per_log_lidar_timestamps_index[log_id] - - - for ts in cam_timestamps: - cam_ring_fpath = [loader.get_closest_img_fpath( - log_id, cam_name, ts - ) for cam_name in CAM_NAMES] - lidar_fpath = loader.get_closest_lidar_fpath(log_id, ts) - - # If bad sensor synchronization, discard the sample - if None in cam_ring_fpath or lidar_fpath is None: - discarded += 1 - continue - - cams = {} - for i, cam_name in enumerate(CAM_NAMES): - pinhole_cam = loader.get_log_pinhole_camera(log_id, cam_name) - cam_timestamp_ns = int(cam_ring_fpath[i].stem) - cam_city_SE3_ego = loader.get_city_SE3_ego(log_id, cam_timestamp_ns) - cams[cam_name] = dict( - img_fpath=str(cam_ring_fpath[i]), - intrinsics=pinhole_cam.intrinsics.K, - extrinsics=pinhole_cam.extrinsics, - e2g_translation = cam_city_SE3_ego.translation, - e2g_rotation = cam_city_SE3_ego.rotation, - ) - - city_SE3_ego = loader.get_city_SE3_ego(log_id, int(ts)) - e2g_translation = city_SE3_ego.translation - e2g_rotation = city_SE3_ego.rotation - info = dict( - e2g_translation=e2g_translation, - e2g_rotation=e2g_rotation, - cams=cams, - lidar_path=str(lidar_fpath), - # map_fpath=map_fname, - timestamp=str(ts), - log_id=log_id, - token=str(log_id+'_'+str(ts))) - - map_anno = extract_local_map(avm, e2g_translation, e2g_rotation, pc_range) - info["annotation"] = map_anno - - samples.append(info) - - return samples, discarded - -def extract_local_map(avm, e2g_translation, e2g_rotation, pc_range): - patch_h = pc_range[4]-pc_range[1] - patch_w = pc_range[3]-pc_range[0] - patch_size = (patch_h, patch_w) - map_pose = e2g_translation[:2] - rotation = Quaternion._from_matrix(e2g_rotation) - patch_box = (map_pose[0], map_pose[1], patch_size[0], patch_size[1]) - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - - city_SE2_ego = SE3(e2g_rotation, e2g_translation) - ego_SE3_city = city_SE2_ego.inverse() - - nearby_centerlines = generate_nearby_centerlines(avm, patch_box,patch_angle) - nearby_dividers = generate_nearby_dividers(avm, patch_box,patch_angle) - - map_anno=dict( - divider=[], - ped_crossing=[], - boundary=[], - centerline=[], - ) - map_anno['ped_crossing'] = extract_local_ped_crossing(avm, ego_SE3_city, patch_box, patch_angle,patch_size) - map_anno['boundary'] = extract_local_boundary(avm, ego_SE3_city, patch_box, patch_angle,patch_size) - map_anno['centerline'] = extract_local_centerline(nearby_centerlines, ego_SE3_city, patch_box, patch_angle,patch_size) - map_anno['divider'] = extract_local_divider(nearby_dividers, ego_SE3_city, patch_box, patch_angle,patch_size) - - - return map_anno - -def generate_nearby_centerlines(avm, patch_box, patch_angle): - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - scene_ls_list = avm.get_scenario_lane_segments() - scene_ls_dict = dict() - for ls in scene_ls_list: - scene_ls_dict[ls.id] = dict( - ls=ls, - polygon = Polygon(ls.polygon_boundary), - predecessors=ls.predecessors, - successors=ls.successors - ) - ls_dict = dict() - for key, value in scene_ls_dict.items(): - polygon = value['polygon'] - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - ls_dict[key]=value - - for key,value in ls_dict.items(): - value['centerline'] = Polyline.from_array(avm.get_lane_segment_centerline(key).round(3)) - pts_G = nx.DiGraph() - junction_pts_list = [] - tmp=ls_dict - for key, value in tmp.items(): - centerline_geom = LineString(value['centerline'].xyz) - centerline_pts = np.array(centerline_geom.coords).round(3) - start_pt = centerline_pts[0] - end_pt = centerline_pts[-1] - for idx, pts in enumerate(centerline_pts[:-1]): - pts_G.add_edge(tuple(centerline_pts[idx]),tuple(centerline_pts[idx+1])) - valid_incoming_num = 0 - for idx, pred in enumerate(value['predecessors']): - if pred in tmp.keys(): - valid_incoming_num += 1 - pred_geom = LineString(tmp[pred]['centerline'].xyz) - pred_pt = np.array(pred_geom.coords).round(3)[-1] - pts_G.add_edge(tuple(pred_pt), tuple(start_pt)) - if valid_incoming_num > 1: - junction_pts_list.append(tuple(start_pt)) - valid_outgoing_num = 0 - for idx, succ in enumerate(value['successors']): - if succ in tmp.keys(): - valid_outgoing_num += 1 - succ_geom = LineString(tmp[succ]['centerline'].xyz) - succ_pt = np.array(succ_geom.coords).round(3)[0] - pts_G.add_edge(tuple(end_pt), tuple(succ_pt)) - if valid_outgoing_num > 1: - junction_pts_list.append(tuple(end_pt)) - roots = (v for v, d in pts_G.in_degree() if d == 0) - leaves = [v for v, d in pts_G.out_degree() if d == 0] - all_paths = [] - for root in roots: - paths = nx.all_simple_paths(pts_G, root, leaves) - all_paths.extend(paths) - - - final_centerline_paths = [] - for path in all_paths: - merged_line = LineString(path) - merged_line = merged_line.simplify(0.2, preserve_topology=True) - final_centerline_paths.append(merged_line) - - local_centerline_paths = final_centerline_paths - return local_centerline_paths - -def generate_nearby_dividers(avm, patch_box, patch_angle): - def get_path(ls_dict): - pts_G = nx.DiGraph() - junction_pts_list = [] - tmp=ls_dict - for key, value in tmp.items(): - centerline_geom = LineString(value['centerline'].xyz) - centerline_pts = np.array(centerline_geom.coords).round(3) - start_pt = centerline_pts[0] - end_pt = centerline_pts[-1] - for idx, pts in enumerate(centerline_pts[:-1]): - pts_G.add_edge(tuple(centerline_pts[idx]),tuple(centerline_pts[idx+1])) - valid_incoming_num = 0 - for idx, pred in enumerate(value['predecessors']): - if pred in tmp.keys(): - valid_incoming_num += 1 - pred_geom = LineString(tmp[pred]['centerline'].xyz) - pred_pt = np.array(pred_geom.coords).round(3)[-1] - pts_G.add_edge(tuple(pred_pt), tuple(start_pt)) - if valid_incoming_num > 1: - junction_pts_list.append(tuple(start_pt)) - valid_outgoing_num = 0 - for idx, succ in enumerate(value['successors']): - if succ in tmp.keys(): - valid_outgoing_num += 1 - succ_geom = LineString(tmp[succ]['centerline'].xyz) - succ_pt = np.array(succ_geom.coords).round(3)[0] - pts_G.add_edge(tuple(end_pt), tuple(succ_pt)) - if valid_outgoing_num > 1: - junction_pts_list.append(tuple(end_pt)) - roots = (v for v, d in pts_G.in_degree() if d == 0) - leaves = [v for v, d in pts_G.out_degree() if d == 0] - all_paths = [] - for root in roots: - paths = nx.all_simple_paths(pts_G, root, leaves) - all_paths.extend(paths) - - - final_centerline_paths = [] - for path in all_paths: - merged_line = LineString(path) - merged_line = merged_line.simplify(0.2, preserve_topology=True) - final_centerline_paths.append(merged_line) - - local_centerline_paths = final_centerline_paths - return local_centerline_paths - - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - scene_ls_list = avm.get_scenario_lane_segments() - scene_ls_dict = dict() - for ls in scene_ls_list: - scene_ls_dict[ls.id] = dict( - ls=ls, - polygon = Polygon(ls.polygon_boundary), - predecessors=ls.predecessors, - successors=ls.successors - ) -# nearby_ls_ids = [] - nearby_ls_dict = dict() - for key, value in scene_ls_dict.items(): - polygon = value['polygon'] - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - nearby_ls_dict[key] = value['ls'] - - ls_dict = nearby_ls_dict - divider_ls_dict = dict() - for key, value in ls_dict.items(): - if not value.is_intersection: - divider_ls_dict[key] = value - - left_lane_dict = {} - right_lane_dict = {} - for key,value in divider_ls_dict.items(): - if value.left_neighbor_id is not None: - left_lane_dict[key] = dict( - polyline=value.left_lane_boundary, - predecessors = value.predecessors, - successors = value.successors, - left_neighbor_id = value.left_neighbor_id, - ) - if value.right_neighbor_id is not None: - right_lane_dict[key] = dict( - polyline = value.right_lane_boundary, - predecessors = value.predecessors, - successors = value.successors, - right_neighbor_id = value.right_neighbor_id, - ) - for key, value in left_lane_dict.items(): - if value['left_neighbor_id'] in right_lane_dict.keys(): - del right_lane_dict[value['left_neighbor_id']] - - for key, value in right_lane_dict.items(): - if value['right_neighbor_id'] in left_lane_dict.keys(): - del left_lane_dict[value['right_neighbor_id']] - - for key, value in left_lane_dict.items(): - value['centerline'] = value['polyline'] - - for key, value in right_lane_dict.items(): - value['centerline'] = value['polyline'] - - left_paths = get_path(left_lane_dict) - right_paths = get_path(right_lane_dict) - local_dividers = left_paths + right_paths - - return local_dividers - -def proc_polygon(polygon, ego_SE3_city): - # import pdb;pdb.set_trace() - interiors = [] - exterior_cityframe = np.array(list(polygon.exterior.coords)) - exterior_egoframe = ego_SE3_city.transform_point_cloud(exterior_cityframe) - for inter in polygon.interiors: - inter_cityframe = np.array(list(inter.coords)) - inter_egoframe = ego_SE3_city.transform_point_cloud(inter_cityframe) - interiors.append(inter_egoframe[:,:3]) - - new_polygon = Polygon(exterior_egoframe[:,:3], interiors) - return new_polygon -def proc_line(line,ego_SE3_city): - # import pdb;pdb.set_trace() - new_line_pts_cityframe = np.array(list(line.coords)) - new_line_pts_egoframe = ego_SE3_city.transform_point_cloud(new_line_pts_cityframe) - line = LineString(new_line_pts_egoframe[:,:3]) #TODO - return line - -def extract_local_centerline(nearby_centerlines, ego_SE3_city, patch_box, patch_angle,patch_size): - - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - line_list = [] - for line in nearby_centerlines: - if line.is_empty: # Skip lines without nodes. - continue - new_line = line.intersection(patch) - if not new_line.is_empty: - if new_line.geom_type == 'MultiLineString': - for single_line in new_line.geoms: - if single_line.is_empty: - continue - single_line = proc_line(single_line,ego_SE3_city) - line_list.append(single_line) - else: - new_line = proc_line(new_line, ego_SE3_city) - line_list.append(new_line) - - centerlines = line_list - - poly_centerlines = [line.buffer(1, - cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) for line in centerlines] - index_by_id = dict((id(pt), i) for i, pt in enumerate(poly_centerlines)) - tree = STRtree(poly_centerlines) - final_pgeom = [] - remain_idx = [i for i in range(len(centerlines))] - for i, pline in enumerate(poly_centerlines): - if i not in remain_idx: - continue - remain_idx.pop(remain_idx.index(i)) - - final_pgeom.append(centerlines[i]) - for o in tree.query(pline): - o_idx = index_by_id[id(o)] - if o_idx not in remain_idx: - continue - inter = o.intersection(pline).area - union = o.union(pline).area - iou = inter / union - if iou >= 0.90: - remain_idx.pop(remain_idx.index(o_idx)) - return [np.array(line.coords) for line in final_pgeom] - -def merge_dividers(divider_list): - # divider_list: List[np.array(N,3)] - if len(divider_list) < 2: - return divider_list - divider_list_shapely = [LineString(divider) for divider in divider_list] - poly_dividers = [divider.buffer(1, - cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) for divider in divider_list_shapely] - tree = STRtree(poly_dividers) - index_by_id = dict((id(pt), i) for i, pt in enumerate(poly_dividers)) - final_pgeom = [] - remain_idx = [i for i in range(len(poly_dividers))] - for i, pline in enumerate(poly_dividers): - if i not in remain_idx: - continue - remain_idx.pop(remain_idx.index(i)) - final_pgeom.append(divider_list[i]) - for o in tree.query(pline): - o_idx = index_by_id[id(o)] - if o_idx not in remain_idx: - continue - # remove highly overlap divider - inter = o.intersection(pline).area - o_iof = inter / o.area - p_iof = inter / pline.area - # if query divider is highly overlaped with latter dividers, just remove it - if p_iof >=0.95: - final_pgeom.pop() - break - # if queried divider is highly overlapped with query divider, - # drop it and just turn to next one. - if o_iof >= 0.95: - remain_idx.pop(remain_idx.index(o_idx)) - continue - - pline_se_pts = final_pgeom[-1][[0,-1],:2] # only on xy - o_se_pts = divider_list[o_idx][[0,-1],:2] # only on xy - four_se_pts = np.concatenate([pline_se_pts,o_se_pts],axis=0) - dist_mat = distance.cdist(four_se_pts, four_se_pts, 'euclidean') - for j in range(4): - dist_mat[j,j] = 100 - index = np.where(dist_mat==0)[0].tolist() - if index == [0, 2]: - # e oline s s pline e - # +-------+ +-------+ - final_pgeom[-1] = np.concatenate([np.flip(divider_list[o_idx], axis=0)[:-1], final_pgeom[-1]]) - remain_idx.pop(remain_idx.index(o_idx)) - elif index == [1, 2]: - # s pline e s oline e - # +-------+ +-------+ - final_pgeom[-1] = np.concatenate([final_pgeom[-1][:-1], divider_list[o_idx]]) - remain_idx.pop(remain_idx.index(o_idx)) - elif index == [0, 3]: - # s oline e s pline e - # +-------+ +-------+ - final_pgeom[-1] = np.concatenate([divider_list[o_idx][:-1], final_pgeom[-1]]) - remain_idx.pop(remain_idx.index(o_idx)) - elif index == [1, 3]: - # s pline e e oline s - # +-------+ +-------+ - final_pgeom[-1] = np.concatenate([final_pgeom[-1][:-1],np.flip(divider_list[o_idx], axis=0)]) - remain_idx.pop(remain_idx.index(o_idx)) - elif len(index) > 2: - remain_idx.pop(remain_idx.index(o_idx)) - - return final_pgeom - - -def extract_local_divider(nearby_dividers, ego_SE3_city, patch_box, patch_angle,patch_size): - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - line_list = [] - for line in nearby_dividers: - if line.is_empty: # Skip lines without nodes. - continue - new_line = line.intersection(patch) - if not new_line.is_empty: - if new_line.geom_type == 'MultiLineString': - for single_line in new_line.geoms: - if single_line.is_empty: - continue - single_line = proc_line(single_line,ego_SE3_city) - line_list.append(single_line) - else: - new_line = proc_line(new_line, ego_SE3_city) - line_list.append(new_line) - - centerlines = line_list - - poly_centerlines = [line.buffer(1, - cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.mitre) for line in centerlines] - index_by_id = dict((id(pt), i) for i, pt in enumerate(poly_centerlines)) - tree = STRtree(poly_centerlines) - final_pgeom = [] - remain_idx = [i for i in range(len(centerlines))] - for i, pline in enumerate(poly_centerlines): - if i not in remain_idx: - continue - remain_idx.pop(remain_idx.index(i)) - - final_pgeom.append(centerlines[i]) - for o in tree.query(pline): - o_idx = index_by_id[id(o)] - if o_idx not in remain_idx: - continue - inter = o.intersection(pline).area - union = o.union(pline).area - iou = inter / union - if iou >= 0.90: - remain_idx.pop(remain_idx.index(o_idx)) - return [np.array(line.coords) for line in final_pgeom] -def extract_local_boundary(avm, ego_SE3_city, patch_box, patch_angle,patch_size): - boundary_list = [] - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - for da in avm.get_scenario_vector_drivable_areas(): - boundary_list.append(da.xyz) - - polygon_list = [] - for da in boundary_list: - exterior_coords = da - interiors = [] - # polygon = Polygon(exterior_coords, interiors) - polygon = Polygon(exterior_coords, interiors) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - if new_polygon.geom_type is 'Polygon': - if not new_polygon.is_valid: - continue - new_polygon = proc_polygon(new_polygon,ego_SE3_city) - if not new_polygon.is_valid: - continue - elif new_polygon.geom_type is 'MultiPolygon': - polygons = [] - for single_polygon in new_polygon.geoms: - if not single_polygon.is_valid or single_polygon.is_empty: - continue - new_single_polygon = proc_polygon(single_polygon,ego_SE3_city) - if not new_single_polygon.is_valid: - continue - polygons.append(new_single_polygon) - if len(polygons) == 0: - continue - new_polygon = MultiPolygon(polygons) - if not new_polygon.is_valid: - continue - else: - raise ValueError('{} is not valid'.format(new_polygon.geom_type)) - - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - union_segments = ops.unary_union(polygon_list) - max_x = patch_size[1] / 2 - max_y = patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - boundary_lines = [] - for line in results: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - boundary_lines.append(np.array(single_line.coords)) - elif line.geom_type == 'LineString': - boundary_lines.append(np.array(line.coords)) - else: - raise NotImplementedError - return boundary_lines - - - -def extract_local_ped_crossing(avm, ego_SE3_city, patch_box, patch_angle,patch_size): - ped_list = [] - for pc in avm.get_scenario_ped_crossings(): - ped_list.append(pc.polygon) - - patch = NuScenesMapExplorer.get_patch_coord(patch_box, patch_angle) - - polygon_list = [] - for pc in ped_list: - exterior_coords = pc - interiors = [] - polygon = Polygon(exterior_coords, interiors) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - if new_polygon.geom_type is 'Polygon': - if not new_polygon.is_valid: - continue - new_polygon = proc_polygon(new_polygon,ego_SE3_city) - if not new_polygon.is_valid: - continue - elif new_polygon.geom_type is 'MultiPolygon': - polygons = [] - for single_polygon in new_polygon.geoms: - if not single_polygon.is_valid or single_polygon.is_empty: - continue - new_single_polygon = proc_polygon(single_polygon,ego_SE3_city) - if not new_single_polygon.is_valid: - continue - polygons.append(new_single_polygon) - if len(polygons) == 0: - continue - new_polygon = MultiPolygon(polygons) - if not new_polygon.is_valid: - continue - else: - raise ValueError('{} is not valid'.format(new_polygon.geom_type)) - - if new_polygon.geom_type is 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - - def get_rec_direction(geom): - rect = geom.minimum_rotated_rectangle # polygon as rotated rect - rect_v_p = np.array(rect.exterior.coords)[:3] # vector point - rect_v = rect_v_p[1:]-rect_v_p[:-1] # vector - v_len = np.linalg.norm(rect_v, axis=-1) # vector length - longest_v_i = v_len.argmax() - - return rect_v[longest_v_i], v_len[longest_v_i] - - ped_geoms = polygon_list - tree = STRtree(ped_geoms) - index_by_id = dict((id(pt), i) for i, pt in enumerate(ped_geoms)) - final_pgeom = [] - remain_idx = [i for i in range(len(ped_geoms))] - for i, pgeom in enumerate(ped_geoms): - if i not in remain_idx: - continue - remain_idx.pop(remain_idx.index(i)) - pgeom_v, pgeom_v_norm = get_rec_direction(pgeom) - final_pgeom.append(pgeom) - for o in tree.query(pgeom): - o_idx = index_by_id[id(o)] - if o_idx not in remain_idx: - continue - o_v, o_v_norm = get_rec_direction(o) - cos = pgeom_v.dot(o_v)/(pgeom_v_norm*o_v_norm) - if 1 - np.abs(cos) < 0.01: # theta < 8 degrees. - final_pgeom[-1] =\ - final_pgeom[-1].union(o) # union parallel ped? - # update - remain_idx.pop(remain_idx.index(o_idx)) - for i in range(len(final_pgeom)): - if final_pgeom[i].geom_type != 'MultiPolygon': - final_pgeom[i] = MultiPolygon([final_pgeom[i]]) - - max_x = patch_size[1] / 2 - max_y = patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - # results = [] - results = [] - for geom in final_pgeom: - for ped_poly in geom.geoms: - # rect = ped_poly.minimum_rotated_rectangle - ext = ped_poly.exterior - if not ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - - if lines.type != 'LineString': - lines = ops.linemerge(lines) - - # same instance but not connected. - if lines.type != 'LineString': - ls = [] - for l in lines.geoms: - ls.append(np.array(l.coords)) - - lines = np.concatenate(ls, axis=0) - lines = LineString(lines) - - results.append(np.array(lines.coords)) - return results -if __name__ == '__main__': - args = parse_args() - for name in ['train', 'val', 'test']: - create_av2_infos_mp( - root_path=args.data_root, - split=name, - info_prefix='av2', - dest_path=args.data_root, - pc_range=args.pc_range,) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_nusc_map_converter.py b/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_nusc_map_converter.py deleted file mode 100644 index e65272dfc69759778f60a9445e6a7f6788ef0a49..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptrv2/custom_nusc_map_converter.py +++ /dev/null @@ -1,944 +0,0 @@ -import argparse -from os import path as osp -import sys -import mmcv -import numpy as np -import os -from collections import OrderedDict -from nuscenes.nuscenes import NuScenes -from nuscenes.utils.geometry_utils import view_points -from os import path as osp -# from pyquaternion import Quaternion -from shapely.geometry import MultiPoint, box -from typing import Dict, List, Optional, Tuple, Union - -from mmdet3d.core.bbox.box_np_ops import points_cam2img -from mmdet3d.datasets import NuScenesDataset -from nuscenes.map_expansion.map_api import NuScenesMap, NuScenesMapExplorer -from nuscenes.eval.common.utils import quaternion_yaw, Quaternion -from nuscenes.map_expansion.bitmap import BitMap -from matplotlib.patches import Polygon as mPolygon - -from shapely import affinity, ops -# from shapely.geometry import LineString, box, MultiPolygon, MultiLineString -from shapely.geometry import Polygon, MultiPolygon, LineString, Point, box, MultiLineString -from matplotlib.axes import Axes -from matplotlib.figure import Figure -import networkx as nx -sys.path.append('.') - - - - -class CNuScenesMapExplorer(NuScenesMapExplorer): - def __ini__(self, *args, **kwargs): - super(self, CNuScenesMapExplorer).__init__(*args, **kwargs) - - def _get_centerline(self, - patch_box: Tuple[float, float, float, float], - patch_angle: float, - layer_name: str, - return_token: bool = False) -> dict: - """ - Retrieve the centerline of a particular layer within the specified patch. - :param patch_box: Patch box defined as [x_center, y_center, height, width]. - :param patch_angle: Patch orientation in degrees. - :param layer_name: name of map layer to be extracted. - :return: dict(token:record_dict, token:record_dict,...) - """ - if layer_name not in ['lane','lane_connector']: - raise ValueError('{} is not a centerline layer'.format(layer_name)) - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.get_patch_coord(patch_box, patch_angle) - - records = getattr(self.map_api, layer_name) - - centerline_dict = dict() - for record in records: - if record['polygon_token'] is None: - # import ipdb - # ipdb.set_trace() - continue - polygon = self.map_api.extract_polygon(record['polygon_token']) - - # if polygon.intersects(patch) or polygon.within(patch): - # if not polygon.is_valid: - # print('within: {}, intersect: {}'.format(polygon.within(patch), polygon.intersects(patch))) - # print('polygon token {} is_valid: {}'.format(record['polygon_token'], polygon.is_valid)) - - # polygon = polygon.buffer(0) - - if polygon.is_valid: - # if within or intersect : - - new_polygon = polygon.intersection(patch) - # new_polygon = polygon - - if not new_polygon.is_empty: - centerline = self.map_api.discretize_lanes( - record, 0.5) - centerline = list(self.map_api.discretize_lanes([record['token']], 0.5).values())[0] - centerline = LineString(np.array(centerline)[:,:2].round(3)) - if centerline.is_empty: - continue - centerline = centerline.intersection(patch) - if not centerline.is_empty: - centerline = \ - to_patch_coord(centerline, patch_angle, patch_x, patch_y) - - # centerline.coords = np.array(centerline.coords).round(3) - # if centerline.geom_type != 'LineString': - # import ipdb;ipdb.set_trace() - record_dict = dict( - centerline=centerline, - token=record['token'], - incoming_tokens=self.map_api.get_incoming_lane_ids(record['token']), - outgoing_tokens=self.map_api.get_outgoing_lane_ids(record['token']), - ) - centerline_dict.update({record['token']: record_dict}) - return centerline_dict - -def to_patch_coord(new_polygon, patch_angle, patch_x, patch_y): - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - return new_polygon - - - -def get_available_scenes(nusc): - """Get available scenes from the input nuscenes class. - - Given the raw data, get the information of available scenes for - further info generation. - - Args: - nusc (class): Dataset class in the nuScenes dataset. - - Returns: - available_scenes (list[dict]): List of basic information for the - available scenes. - """ - available_scenes = [] - print('total scene num: {}'.format(len(nusc.scene))) - for scene in nusc.scene: - scene_token = scene['token'] - scene_rec = nusc.get('scene', scene_token) - sample_rec = nusc.get('sample', scene_rec['first_sample_token']) - sd_rec = nusc.get('sample_data', sample_rec['data']['LIDAR_TOP']) - has_more_frames = True - scene_not_exist = False - while has_more_frames: - lidar_path, boxes, _ = nusc.get_sample_data(sd_rec['token']) - lidar_path = str(lidar_path) - if os.getcwd() in lidar_path: - # path from lyftdataset is absolute path - lidar_path = lidar_path.split(f'{os.getcwd()}/')[-1] - # relative path - if not mmcv.is_filepath(lidar_path): - scene_not_exist = True - break - else: - break - if scene_not_exist: - continue - available_scenes.append(scene) - print('exist scene num: {}'.format(len(available_scenes))) - return available_scenes - -def _get_can_bus_info(nusc, nusc_can_bus, sample): - scene_name = nusc.get('scene', sample['scene_token'])['name'] - sample_timestamp = sample['timestamp'] - try: - pose_list = nusc_can_bus.get_messages(scene_name, 'pose') - except: - return np.zeros(18) # server scenes do not have can bus information. - can_bus = [] - # during each scene, the first timestamp of can_bus may be large than the first sample's timestamp - last_pose = pose_list[0] - for i, pose in enumerate(pose_list): - if pose['utime'] > sample_timestamp: - break - last_pose = pose - _ = last_pose.pop('utime') # useless - pos = last_pose.pop('pos') - rotation = last_pose.pop('orientation') - can_bus.extend(pos) - can_bus.extend(rotation) - for key in last_pose.keys(): - can_bus.extend(pose[key]) # 16 elements - can_bus.extend([0., 0.]) - return np.array(can_bus) - - -def obtain_sensor2top(nusc, - sensor_token, - l2e_t, - l2e_r_mat, - e2g_t, - e2g_r_mat, - sensor_type='lidar'): - """Obtain the info with RT matric from general sensor to Top LiDAR. - - Args: - nusc (class): Dataset class in the nuScenes dataset. - sensor_token (str): Sample data token corresponding to the - specific sensor type. - l2e_t (np.ndarray): Translation from lidar to ego in shape (1, 3). - l2e_r_mat (np.ndarray): Rotation matrix from lidar to ego - in shape (3, 3). - e2g_t (np.ndarray): Translation from ego to global in shape (1, 3). - e2g_r_mat (np.ndarray): Rotation matrix from ego to global - in shape (3, 3). - sensor_type (str): Sensor to calibrate. Default: 'lidar'. - - Returns: - sweep (dict): Sweep information after transformation. - """ - sd_rec = nusc.get('sample_data', sensor_token) - cs_record = nusc.get('calibrated_sensor', - sd_rec['calibrated_sensor_token']) - pose_record = nusc.get('ego_pose', sd_rec['ego_pose_token']) - data_path = str(nusc.get_sample_data_path(sd_rec['token'])) - if os.getcwd() in data_path: # path from lyftdataset is absolute path - data_path = data_path.split(f'{os.getcwd()}/')[-1] # relative path - sweep = { - 'data_path': data_path, - 'type': sensor_type, - 'sample_data_token': sd_rec['token'], - 'sensor2ego_translation': cs_record['translation'], - 'sensor2ego_rotation': cs_record['rotation'], - 'ego2global_translation': pose_record['translation'], - 'ego2global_rotation': pose_record['rotation'], - 'timestamp': sd_rec['timestamp'] - } - - l2e_r_s = sweep['sensor2ego_rotation'] - l2e_t_s = sweep['sensor2ego_translation'] - e2g_r_s = sweep['ego2global_rotation'] - e2g_t_s = sweep['ego2global_translation'] - - # obtain the RT from sensor to Top LiDAR - # sweep->ego->global->ego'->lidar - l2e_r_s_mat = Quaternion(l2e_r_s).rotation_matrix - e2g_r_s_mat = Quaternion(e2g_r_s).rotation_matrix - R = (l2e_r_s_mat.T @ e2g_r_s_mat.T) @ ( - np.linalg.inv(e2g_r_mat).T @ np.linalg.inv(l2e_r_mat).T) - T = (l2e_t_s @ e2g_r_s_mat.T + e2g_t_s) @ ( - np.linalg.inv(e2g_r_mat).T @ np.linalg.inv(l2e_r_mat).T) - T -= e2g_t @ (np.linalg.inv(e2g_r_mat).T @ np.linalg.inv(l2e_r_mat).T - ) + l2e_t @ np.linalg.inv(l2e_r_mat).T - sweep['sensor2lidar_rotation'] = R.T # points @ R.T + T - sweep['sensor2lidar_translation'] = T - return sweep - - -def _fill_trainval_infos(nusc, - nusc_can_bus, - nusc_maps, - map_explorer, - train_scenes, - val_scenes, - test=False, - max_sweeps=10, - point_cloud_range=[-15.0, -30.0,-10.0, 15.0, 30.0, 10.0]): - """Generate the train/val infos from the raw data. - - Args: - nusc (:obj:`NuScenes`): Dataset class in the nuScenes dataset. - train_scenes (list[str]): Basic information of training scenes. - val_scenes (list[str]): Basic information of validation scenes. - test (bool): Whether use the test mode. In the test mode, no - annotations can be accessed. Default: False. - max_sweeps (int): Max number of sweeps. Default: 10. - - Returns: - tuple[list[dict]]: Information of training set and validation set - that will be saved to the info file. - """ - train_nusc_infos = [] - val_nusc_infos = [] - frame_idx = 0 - for sample in mmcv.track_iter_progress(nusc.sample): - map_location = nusc.get('log', nusc.get('scene', sample['scene_token'])['log_token'])['location'] - - lidar_token = sample['data']['LIDAR_TOP'] - sd_rec = nusc.get('sample_data', sample['data']['LIDAR_TOP']) - cs_record = nusc.get('calibrated_sensor', - sd_rec['calibrated_sensor_token']) - pose_record = nusc.get('ego_pose', sd_rec['ego_pose_token']) - lidar_path, boxes, _ = nusc.get_sample_data(lidar_token) - - mmcv.check_file_exist(lidar_path) - can_bus = _get_can_bus_info(nusc, nusc_can_bus, sample) - ## - info = { - 'lidar_path': lidar_path, - 'token': sample['token'], - 'prev': sample['prev'], - 'next': sample['next'], - 'can_bus': can_bus, - 'frame_idx': frame_idx, # temporal related info - 'sweeps': [], - 'cams': dict(), - 'map_location': map_location, - 'scene_token': sample['scene_token'], # temporal related info - 'lidar2ego_translation': cs_record['translation'], - 'lidar2ego_rotation': cs_record['rotation'], - 'ego2global_translation': pose_record['translation'], - 'ego2global_rotation': pose_record['rotation'], - 'timestamp': sample['timestamp'], - } - - if sample['next'] == '': - frame_idx = 0 - else: - frame_idx += 1 - - l2e_r = info['lidar2ego_rotation'] - l2e_t = info['lidar2ego_translation'] - e2g_r = info['ego2global_rotation'] - e2g_t = info['ego2global_translation'] - l2e_r_mat = Quaternion(l2e_r).rotation_matrix - e2g_r_mat = Quaternion(e2g_r).rotation_matrix - - # obtain 6 image's information per frame - camera_types = [ - 'CAM_FRONT', - 'CAM_FRONT_RIGHT', - 'CAM_FRONT_LEFT', - 'CAM_BACK', - 'CAM_BACK_LEFT', - 'CAM_BACK_RIGHT', - ] - for cam in camera_types: - cam_token = sample['data'][cam] - cam_path, _, cam_intrinsic = nusc.get_sample_data(cam_token) - cam_info = obtain_sensor2top(nusc, cam_token, l2e_t, l2e_r_mat, - e2g_t, e2g_r_mat, cam) - cam_info.update(cam_intrinsic=cam_intrinsic) - info['cams'].update({cam: cam_info}) - - # obtain sweeps for a single key-frame - sd_rec = nusc.get('sample_data', sample['data']['LIDAR_TOP']) - sweeps = [] - while len(sweeps) < max_sweeps: - if not sd_rec['prev'] == '': - sweep = obtain_sensor2top(nusc, sd_rec['prev'], l2e_t, - l2e_r_mat, e2g_t, e2g_r_mat, 'lidar') - sweeps.append(sweep) - sd_rec = nusc.get('sample_data', sd_rec['prev']) - else: - break - info['sweeps'] = sweeps - # obtain annotation - # import ipdb;ipdb.set_trace() - info = obtain_vectormap(nusc_maps, map_explorer, info, point_cloud_range) - - if sample['scene_token'] in train_scenes: - train_nusc_infos.append(info) - else: - val_nusc_infos.append(info) - - return train_nusc_infos, val_nusc_infos - -def obtain_vectormap(nusc_maps, map_explorer, info, point_cloud_range): - # import ipdb;ipdb.set_trace() - lidar2ego = np.eye(4) - lidar2ego[:3,:3] = Quaternion(info['lidar2ego_rotation']).rotation_matrix - lidar2ego[:3, 3] = info['lidar2ego_translation'] - ego2global = np.eye(4) - ego2global[:3,:3] = Quaternion(info['ego2global_rotation']).rotation_matrix - ego2global[:3, 3] = info['ego2global_translation'] - - lidar2global = ego2global @ lidar2ego - - lidar2global_translation = list(lidar2global[:3,3]) - lidar2global_rotation = list(Quaternion(matrix=lidar2global).q) - - location = info['map_location'] - ego2global_translation = info['ego2global_translation'] - ego2global_rotation = info['ego2global_rotation'] - - patch_h = point_cloud_range[4]-point_cloud_range[1] - patch_w = point_cloud_range[3]-point_cloud_range[0] - patch_size = (patch_h, patch_w) - vector_map = VectorizedLocalMap(nusc_maps[location], map_explorer[location],patch_size) - map_anns = vector_map.gen_vectorized_samples(lidar2global_translation, lidar2global_rotation) - # import ipdb;ipdb.set_trace() - info["annotation"] = map_anns - return info - - -class VectorizedLocalMap(object): - CLASS2LABEL = { - 'road_divider': 0, - 'lane_divider': 0, - 'ped_crossing': 1, - 'contours': 2, - 'others': -1 - } - def __init__(self, - nusc_map, - map_explorer, - patch_size, - map_classes=['divider','ped_crossing','boundary','centerline'], - line_classes=['road_divider', 'lane_divider'], - ped_crossing_classes=['ped_crossing'], - contour_classes=['road_segment', 'lane'], - centerline_classes=['lane_connector','lane'], - use_simplify=True, - ): - super().__init__() - self.nusc_map = nusc_map - self.map_explorer = map_explorer - self.vec_classes = map_classes - self.line_classes = line_classes - self.ped_crossing_classes = ped_crossing_classes - self.polygon_classes = contour_classes - self.centerline_classes = centerline_classes - self.patch_size = patch_size - - - def gen_vectorized_samples(self, lidar2global_translation, lidar2global_rotation): - ''' - use lidar2global to get gt map layers - ''' - - map_pose = lidar2global_translation[:2] - rotation = Quaternion(lidar2global_rotation) - # import ipdb;ipdb.set_trace() - patch_box = (map_pose[0], map_pose[1], self.patch_size[0], self.patch_size[1]) - patch_angle = quaternion_yaw(rotation) / np.pi * 180 - map_dict = {'divider':[],'ped_crossing':[],'boundary':[],'centerline':[]} - vectors = [] - for vec_class in self.vec_classes: - if vec_class == 'divider': - line_geom = self.get_map_geom(patch_box, patch_angle, self.line_classes) - line_instances_dict = self.line_geoms_to_instances(line_geom) - for line_type, instances in line_instances_dict.items(): - for instance in instances: - map_dict[vec_class].append(np.array(instance.coords)) - # vectors.append((instance, self.CLASS2LABEL.get(line_type, -1))) - elif vec_class == 'ped_crossing': - ped_geom = self.get_map_geom(patch_box, patch_angle, self.ped_crossing_classes) - ped_instance_list = self.ped_poly_geoms_to_instances(ped_geom) - for instance in ped_instance_list: - # vectors.append((instance, self.CLASS2LABEL.get('ped_crossing', -1))) - map_dict[vec_class].append(np.array(instance.coords)) - elif vec_class == 'boundary': - polygon_geom = self.get_map_geom(patch_box, patch_angle, self.polygon_classes) - poly_bound_list = self.poly_geoms_to_instances(polygon_geom) - for instance in poly_bound_list: - # import ipdb;ipdb.set_trace() - map_dict[vec_class].append(np.array(instance.coords)) - # vectors.append((contour, self.CLASS2LABEL.get('contours', -1))) - elif vec_class =='centerline': - centerline_geom = self.get_centerline_geom(patch_box, patch_angle, self.centerline_classes) - centerline_list = self.centerline_geoms_to_instances(centerline_geom) - for instance in centerline_list: - map_dict[vec_class].append(np.array(instance.coords)) - else: - raise ValueError(f'WRONG vec_class: {vec_class}') - # import ipdb;ipdb.set_trace() - return map_dict - def get_centerline_geom(self, patch_box, patch_angle, layer_names): - map_geom = {} - for layer_name in layer_names: - if layer_name in self.centerline_classes: - return_token = False - layer_centerline_dict = self.map_explorer._get_centerline( - patch_box, patch_angle, layer_name, return_token=return_token) - if len(layer_centerline_dict.keys()) == 0: - continue - # import ipdb;ipdb.set_trace() - map_geom.update(layer_centerline_dict) - return map_geom - def get_map_geom(self, patch_box, patch_angle, layer_names): - map_geom = {} - for layer_name in layer_names: - if layer_name in self.line_classes: - geoms = self.get_divider_line(patch_box, patch_angle, layer_name) - # map_geom.append((layer_name, geoms)) - map_geom[layer_name] = geoms - elif layer_name in self.polygon_classes: - geoms = self.get_contour_line(patch_box, patch_angle, layer_name) - # map_geom.append((layer_name, geoms)) - map_geom[layer_name] = geoms - elif layer_name in self.ped_crossing_classes: - geoms = self.get_ped_crossing_line(patch_box, patch_angle) - # map_geom.append((layer_name, geoms)) - map_geom[layer_name] = geoms - return map_geom - - def get_divider_line(self,patch_box,patch_angle,layer_name): - if layer_name not in self.map_explorer.map_api.non_geometric_line_layers: - raise ValueError("{} is not a line layer".format(layer_name)) - - if layer_name == 'traffic_light': - return None - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer.get_patch_coord(patch_box, patch_angle) - - line_list = [] - records = getattr(self.map_explorer.map_api, layer_name) - for record in records: - line = self.map_explorer.map_api.extract_line(record['line_token']) - if line.is_empty: # Skip lines without nodes. - continue - - new_line = line.intersection(patch) - if not new_line.is_empty: - new_line = affinity.rotate(new_line, -patch_angle, origin=(patch_x, patch_y), use_radians=False) - new_line = affinity.affine_transform(new_line, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - line_list.append(new_line) - - return line_list - - def get_contour_line(self,patch_box,patch_angle,layer_name): - if layer_name not in self.map_explorer.map_api.non_geometric_polygon_layers: - raise ValueError('{} is not a polygonal layer'.format(layer_name)) - - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer.get_patch_coord(patch_box, patch_angle) - - records = getattr(self.map_explorer.map_api, layer_name) - - polygon_list = [] - if layer_name == 'drivable_area': - for record in records: - polygons = [self.map_explorer.map_api.extract_polygon(polygon_token) for polygon_token in record['polygon_tokens']] - - for polygon in polygons: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - else: - for record in records: - polygon = self.map_explorer.map_api.extract_polygon(record['polygon_token']) - - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - - def get_ped_crossing_line(self, patch_box, patch_angle): - patch_x = patch_box[0] - patch_y = patch_box[1] - - patch = self.map_explorer.get_patch_coord(patch_box, patch_angle) - polygon_list = [] - records = getattr(self.map_explorer.map_api, 'ped_crossing') - # records = getattr(self.nusc_maps[location], 'ped_crossing') - for record in records: - polygon = self.map_explorer.map_api.extract_polygon(record['polygon_token']) - if polygon.is_valid: - new_polygon = polygon.intersection(patch) - if not new_polygon.is_empty: - new_polygon = affinity.rotate(new_polygon, -patch_angle, - origin=(patch_x, patch_y), use_radians=False) - new_polygon = affinity.affine_transform(new_polygon, - [1.0, 0.0, 0.0, 1.0, -patch_x, -patch_y]) - if new_polygon.geom_type == 'Polygon': - new_polygon = MultiPolygon([new_polygon]) - polygon_list.append(new_polygon) - - return polygon_list - - def line_geoms_to_instances(self, line_geom): - line_instances_dict = dict() - for line_type, a_type_of_lines in line_geom.items(): - one_type_instances = self._one_type_line_geom_to_instances(a_type_of_lines) - line_instances_dict[line_type] = one_type_instances - - return line_instances_dict - - def _one_type_line_geom_to_instances(self, line_geom): - line_instances = [] - - for line in line_geom: - if not line.is_empty: - if line.geom_type == 'MultiLineString': - for single_line in line.geoms: - line_instances.append(single_line) - elif line.geom_type == 'LineString': - line_instances.append(line) - else: - raise NotImplementedError - return line_instances - - def ped_poly_geoms_to_instances(self, ped_geom): - # ped = ped_geom[0][1] - # import ipdb;ipdb.set_trace() - ped = ped_geom['ped_crossing'] - union_segments = ops.unary_union(ped) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x - 0.2, -max_y - 0.2, max_x + 0.2, max_y + 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - - def poly_geoms_to_instances(self, polygon_geom): - roads = polygon_geom['road_segment'] - lanes = polygon_geom['lane'] - # import ipdb;ipdb.set_trace() - union_roads = ops.unary_union(roads) - union_lanes = ops.unary_union(lanes) - union_segments = ops.unary_union([union_roads, union_lanes]) - max_x = self.patch_size[1] / 2 - max_y = self.patch_size[0] / 2 - local_patch = box(-max_x + 0.2, -max_y + 0.2, max_x - 0.2, max_y - 0.2) - exteriors = [] - interiors = [] - if union_segments.geom_type != 'MultiPolygon': - union_segments = MultiPolygon([union_segments]) - for poly in union_segments.geoms: - exteriors.append(poly.exterior) - for inter in poly.interiors: - interiors.append(inter) - - results = [] - for ext in exteriors: - if ext.is_ccw: - ext.coords = list(ext.coords)[::-1] - lines = ext.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - for inter in interiors: - if not inter.is_ccw: - inter.coords = list(inter.coords)[::-1] - lines = inter.intersection(local_patch) - if isinstance(lines, MultiLineString): - lines = ops.linemerge(lines) - results.append(lines) - - return self._one_type_line_geom_to_instances(results) - - def centerline_geoms_to_instances(self,geoms_dict): - centerline_geoms_list,pts_G = self.union_centerline(geoms_dict) - # vectors_dict = self.centerline_geoms2vec(centerline_geoms_list) - # import ipdb;ipdb.set_trace() - return self._one_type_line_geom_to_instances(centerline_geoms_list) - - - def centerline_geoms2vec(self, centerline_geoms_list): - vector_dict = {} - # import ipdb;ipdb.set_trace() - # centerline_geoms_list = [line.simplify(0.2, preserve_topology=True) \ - # for line in centerline_geoms_list] - vectors = self._geom_to_vectors( - centerline_geoms_list) - vector_dict.update({'centerline': ('centerline', vectors)}) - return vector_dict - - def union_centerline(self, centerline_geoms): - # import ipdb;ipdb.set_trace() - pts_G = nx.DiGraph() - junction_pts_list = [] - for key, value in centerline_geoms.items(): - centerline_geom = value['centerline'] - if centerline_geom.geom_type == 'MultiLineString': - start_pt = np.array(centerline_geom.geoms[0].coords).round(3)[0] - end_pt = np.array(centerline_geom.geoms[-1].coords).round(3)[-1] - for single_geom in centerline_geom.geoms: - single_geom_pts = np.array(single_geom.coords).round(3) - for idx, pt in enumerate(single_geom_pts[:-1]): - pts_G.add_edge(tuple(single_geom_pts[idx]),tuple(single_geom_pts[idx+1])) - elif centerline_geom.geom_type == 'LineString': - centerline_pts = np.array(centerline_geom.coords).round(3) - start_pt = centerline_pts[0] - end_pt = centerline_pts[-1] - for idx, pts in enumerate(centerline_pts[:-1]): - pts_G.add_edge(tuple(centerline_pts[idx]),tuple(centerline_pts[idx+1])) - else: - raise NotImplementedError - valid_incoming_num = 0 - for idx, pred in enumerate(value['incoming_tokens']): - if pred in centerline_geoms.keys(): - valid_incoming_num += 1 - pred_geom = centerline_geoms[pred]['centerline'] - if pred_geom.geom_type == 'MultiLineString': - pred_pt = np.array(pred_geom.geoms[-1].coords).round(3)[-1] - # if pred_pt != centerline_pts[0]: - pts_G.add_edge(tuple(pred_pt), tuple(start_pt)) - else: - pred_pt = np.array(pred_geom.coords).round(3)[-1] - pts_G.add_edge(tuple(pred_pt), tuple(start_pt)) - if valid_incoming_num > 1: - junction_pts_list.append(tuple(start_pt)) - - valid_outgoing_num = 0 - for idx, succ in enumerate(value['outgoing_tokens']): - if succ in centerline_geoms.keys(): - valid_outgoing_num += 1 - succ_geom = centerline_geoms[succ]['centerline'] - if succ_geom.geom_type == 'MultiLineString': - succ_pt = np.array(succ_geom.geoms[0].coords).round(3)[0] - # if pred_pt != centerline_pts[0]: - pts_G.add_edge(tuple(end_pt), tuple(succ_pt)) - else: - succ_pt = np.array(succ_geom.coords).round(3)[0] - pts_G.add_edge(tuple(end_pt), tuple(succ_pt)) - if valid_outgoing_num > 1: - junction_pts_list.append(tuple(end_pt)) - - roots = (v for v, d in pts_G.in_degree() if d == 0) - leaves = [v for v, d in pts_G.out_degree() if d == 0] - all_paths = [] - for root in roots: - paths = nx.all_simple_paths(pts_G, root, leaves) - all_paths.extend(paths) - - final_centerline_paths = [] - for path in all_paths: - merged_line = LineString(path) - merged_line = merged_line.simplify(0.2, preserve_topology=True) - final_centerline_paths.append(merged_line) - return final_centerline_paths, pts_G - - - - -def create_nuscenes_infos(root_path, - out_path, - can_bus_root_path, - info_prefix, - version='v1.0-trainval', - max_sweeps=10): - """Create info file of nuscene dataset. - - Given the raw data, generate its related info file in pkl format. - - Args: - root_path (str): Path of the data root. - info_prefix (str): Prefix of the info file to be generated. - version (str): Version of the data. - Default: 'v1.0-trainval' - max_sweeps (int): Max number of sweeps. - Default: 10 - """ - from nuscenes.nuscenes import NuScenes - from nuscenes.can_bus.can_bus_api import NuScenesCanBus - print(version, root_path) - nusc = NuScenes(version=version, dataroot=root_path, verbose=True) - nusc_can_bus = NuScenesCanBus(dataroot=can_bus_root_path) - MAPS = ['boston-seaport', 'singapore-hollandvillage', - 'singapore-onenorth', 'singapore-queenstown'] - nusc_maps = {} - map_explorer = {} - for loc in MAPS: - nusc_maps[loc] = NuScenesMap(dataroot=root_path, map_name=loc) - map_explorer[loc] = CNuScenesMapExplorer(nusc_maps[loc]) - - - from nuscenes.utils import splits - available_vers = ['v1.0-trainval', 'v1.0-test', 'v1.0-mini'] - assert version in available_vers - if version == 'v1.0-trainval': - train_scenes = splits.train - val_scenes = splits.val - elif version == 'v1.0-test': - train_scenes = splits.test - val_scenes = [] - elif version == 'v1.0-mini': - train_scenes = splits.mini_train - val_scenes = splits.mini_val - else: - raise ValueError('unknown') - - # filter existing scenes. - available_scenes = get_available_scenes(nusc) - available_scene_names = [s['name'] for s in available_scenes] - train_scenes = list( - filter(lambda x: x in available_scene_names, train_scenes)) - val_scenes = list(filter(lambda x: x in available_scene_names, val_scenes)) - train_scenes = set([ - available_scenes[available_scene_names.index(s)]['token'] - for s in train_scenes - ]) - val_scenes = set([ - available_scenes[available_scene_names.index(s)]['token'] - for s in val_scenes - ]) - - test = 'test' in version - if test: - print('test scene: {}'.format(len(train_scenes))) - else: - print('train scene: {}, val scene: {}'.format( - len(train_scenes), len(val_scenes))) - - train_nusc_infos, val_nusc_infos = _fill_trainval_infos( - nusc, nusc_can_bus, nusc_maps, map_explorer, train_scenes, val_scenes, test, max_sweeps=max_sweeps) - - metadata = dict(version=version) - if test: - print('test sample: {}'.format(len(train_nusc_infos))) - data = dict(infos=train_nusc_infos, metadata=metadata) - info_path = osp.join(out_path, - '{}_map_infos_temporal_test.pkl'.format(info_prefix)) - mmcv.dump(data, info_path) - else: - print('train sample: {}, val sample: {}'.format( - len(train_nusc_infos), len(val_nusc_infos))) - data = dict(infos=train_nusc_infos, metadata=metadata) - info_path = osp.join(out_path, - '{}_map_infos_temporal_train.pkl'.format(info_prefix)) - mmcv.dump(data, info_path) - data['infos'] = val_nusc_infos - info_val_path = osp.join(out_path, - '{}_map_infos_temporal_val.pkl'.format(info_prefix)) - mmcv.dump(data, info_val_path) - - - -def nuscenes_data_prep(root_path, - can_bus_root_path, - info_prefix, - version, - dataset_name, - out_dir, - max_sweeps=10): - """Prepare data related to nuScenes dataset. - - Related data consists of '.pkl' files recording basic infos, - 2D annotations and groundtruth database. - - Args: - root_path (str): Path of dataset root. - info_prefix (str): The prefix of info filenames. - version (str): Dataset version. - dataset_name (str): The dataset class name. - out_dir (str): Output directory of the groundtruth database info. - max_sweeps (int): Number of input consecutive frames. Default: 10 - """ - create_nuscenes_infos( - root_path, out_dir, can_bus_root_path, info_prefix, version=version, max_sweeps=max_sweeps) - - # if version == 'v1.0-test': - # info_test_path = osp.join( - # out_dir, f'{info_prefix}_infos_temporal_test.pkl') - # nuscenes_converter.export_2d_annotation( - # root_path, info_test_path, version=version) - # else: - # info_train_path = osp.join( - # out_dir, f'{info_prefix}_infos_temporal_train.pkl') - # info_val_path = osp.join( - # out_dir, f'{info_prefix}_infos_temporal_val.pkl') - # nuscenes_converter.export_2d_annotation( - # root_path, info_train_path, version=version) - # nuscenes_converter.export_2d_annotation( - # root_path, info_val_path, version=version) - # create_groundtruth_database(dataset_name, root_path, info_prefix, - # f'{out_dir}/{info_prefix}_infos_train.pkl') - - - -parser = argparse.ArgumentParser(description='Data converter arg parser') -parser.add_argument( - '--root-path', - type=str, - default='./data/kitti', - help='specify the root path of dataset') -parser.add_argument( - '--canbus', - type=str, - default='./data', - help='specify the root path of nuScenes canbus') -parser.add_argument( - '--version', - type=str, - default='v1.0', - required=False, - help='specify the dataset version, no need for kitti') -parser.add_argument( - '--max-sweeps', - type=int, - default=10, - required=False, - help='specify sweeps of lidar per example') -parser.add_argument( - '--out-dir', - type=str, - default='./data/kitti', - required='False', - help='name of info pkl') -parser.add_argument('--extra-tag', type=str, default='nuscenes') -parser.add_argument( - '--workers', type=int, default=4, help='number of threads to be used') -args = parser.parse_args() - - -if __name__ == '__main__': - train_version = f'{args.version}-trainval' - nuscenes_data_prep( - root_path=args.root_path, - can_bus_root_path=args.canbus, - info_prefix=args.extra_tag, - version=train_version, - dataset_name='NuScenesDataset', - out_dir=args.out_dir, - max_sweeps=args.max_sweeps) - test_version = f'{args.version}-test' - nuscenes_data_prep( - root_path=args.root_path, - can_bus_root_path=args.canbus, - info_prefix=args.extra_tag, - version=test_version, - dataset_name='NuScenesDataset', - out_dir=args.out_dir, - max_sweeps=args.max_sweeps) \ No newline at end of file diff --git a/docker-hub/MapTRv2/MapTR/tools/maptrv2/nusc_vis_pred.py b/docker-hub/MapTRv2/MapTR/tools/maptrv2/nusc_vis_pred.py deleted file mode 100644 index 537e9c97896ea505f7fc3c3c26cb75d2b1959143..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/MapTR/tools/maptrv2/nusc_vis_pred.py +++ /dev/null @@ -1,391 +0,0 @@ -import argparse -import mmcv -import os -import shutil -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.cnn import fuse_conv_bn -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, - wrap_fp16_model) -from mmdet3d.utils import collect_env, get_root_logger -from mmdet3d.apis import single_gpu_test -from mmdet3d.datasets import build_dataset -import sys -sys.path.append('') -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from mmdet3d.models import build_model -from mmdet.apis import set_random_seed -from projects.mmdet3d_plugin.bevformer.apis.test import custom_multi_gpu_test -from mmdet.datasets import replace_ImageToTensor -import time -import os.path as osp -import numpy as np -from PIL import Image -import matplotlib.pyplot as plt -from matplotlib import transforms -from matplotlib.patches import Rectangle -import cv2 - - -CAMS = ['CAM_FRONT_LEFT','CAM_FRONT','CAM_FRONT_RIGHT', - 'CAM_BACK_LEFT','CAM_BACK','CAM_BACK_RIGHT',] -# we choose these samples not because it is easy but because it is hard -CANDIDATE=['n008-2018-08-01-15-16-36-0400_1533151184047036', - 'n008-2018-08-01-15-16-36-0400_1533151200646853', - 'n008-2018-08-01-15-16-36-0400_1533151274047332', - 'n008-2018-08-01-15-16-36-0400_1533151369947807', - 'n008-2018-08-01-15-16-36-0400_1533151581047647', - 'n008-2018-08-01-15-16-36-0400_1533151585447531', - 'n008-2018-08-01-15-16-36-0400_1533151741547700', - 'n008-2018-08-01-15-16-36-0400_1533151854947676', - 'n008-2018-08-22-15-53-49-0400_1534968048946931', - 'n008-2018-08-22-15-53-49-0400_1534968255947662', - 'n008-2018-08-01-15-16-36-0400_1533151616447606', - 'n015-2018-07-18-11-41-49+0800_1531885617949602', - 'n008-2018-08-28-16-43-51-0400_1535489136547616', - 'n008-2018-08-28-16-43-51-0400_1535489145446939', - 'n008-2018-08-28-16-43-51-0400_1535489152948944', - 'n008-2018-08-28-16-43-51-0400_1535489299547057', - 'n008-2018-08-28-16-43-51-0400_1535489317946828', - 'n008-2018-09-18-15-12-01-0400_1537298038950431', - 'n008-2018-09-18-15-12-01-0400_1537298047650680', - 'n008-2018-09-18-15-12-01-0400_1537298056450495', - 'n008-2018-09-18-15-12-01-0400_1537298074700410', - 'n008-2018-09-18-15-12-01-0400_1537298088148941', - 'n008-2018-09-18-15-12-01-0400_1537298101700395', - 'n015-2018-11-21-19-21-35+0800_1542799330198603', - 'n015-2018-11-21-19-21-35+0800_1542799345696426', - 'n015-2018-11-21-19-21-35+0800_1542799353697765', - 'n015-2018-11-21-19-21-35+0800_1542799525447813', - 'n015-2018-11-21-19-21-35+0800_1542799676697935', - 'n015-2018-11-21-19-21-35+0800_1542799758948001', - ] - -def perspective(cam_coords, proj_mat): - pix_coords = proj_mat @ cam_coords - valid_idx = pix_coords[2, :] > 0 - pix_coords = pix_coords[:, valid_idx] - pix_coords = pix_coords[:2, :] / (pix_coords[2, :] + 1e-7) - pix_coords = pix_coords.transpose(1, 0) - return pix_coords - -def parse_args(): - parser = argparse.ArgumentParser(description='vis hdmaptr map gt label') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--score-thresh', default=0.4, type=float, help='samples to visualize') - parser.add_argument( - '--show-dir', help='directory where visualizations will be saved') - parser.add_argument('--show-cam', action='store_true', help='show camera pic') - parser.add_argument( - '--gt-format', - type=str, - nargs='+', - default=['fixed_num_pts',], - help='vis format, default should be "points",' - 'support ["se_pts","bbox","fixed_num_pts","polyline_pts"]') - args = parser.parse_args() - return args - -def main(): - args = parse_args() - cfg = Config.fromfile(args.config) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, 'plugin'): - if cfg.plugin: - import importlib - if hasattr(cfg, 'plugin_dir'): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split('/') - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + '.' + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - - cfg.model.pretrained = None - # in case the test dataset is concatenated - samples_per_gpu = 1 - if isinstance(cfg.data.test, dict): - cfg.data.test.test_mode = True - samples_per_gpu = cfg.data.test.pop('samples_per_gpu', 1) - if samples_per_gpu > 1: - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.test.pipeline = replace_ImageToTensor( - cfg.data.test.pipeline) - elif isinstance(cfg.data.test, list): - for ds_cfg in cfg.data.test: - ds_cfg.test_mode = True - samples_per_gpu = max( - [ds_cfg.pop('samples_per_gpu', 1) for ds_cfg in cfg.data.test]) - if samples_per_gpu > 1: - for ds_cfg in cfg.data.test: - ds_cfg.pipeline = replace_ImageToTensor(ds_cfg.pipeline) - - if args.show_dir is None: - args.show_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0], - 'vis_pred') - # create vis_label dir - mmcv.mkdir_or_exist(osp.abspath(args.show_dir)) - cfg.dump(osp.join(args.show_dir, osp.basename(args.config))) - logger = get_root_logger() - logger.info(f'DONE create vis_pred dir: {args.show_dir}') - - - dataset = build_dataset(cfg.data.test) - dataset.is_vis_on_test = True #TODO, this is a hack - data_loader = build_dataloader( - dataset, - samples_per_gpu=samples_per_gpu, - # workers_per_gpu=cfg.data.workers_per_gpu, - workers_per_gpu=0, - dist=False, - shuffle=False, - nonshuffler_sampler=cfg.data.nonshuffler_sampler, - ) - logger.info('Done build test data set') - - # build the model and load checkpoint - # import pdb;pdb.set_trace() - cfg.model.train_cfg = None - # cfg.model.pts_bbox_head.bbox_coder.max_num=15 # TODO this is a hack - model = build_model(cfg.model, test_cfg=cfg.get('test_cfg')) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - logger.info('loading check point') - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - if 'CLASSES' in checkpoint.get('meta', {}): - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - # palette for visualization in segmentation tasks - if 'PALETTE' in checkpoint.get('meta', {}): - model.PALETTE = checkpoint['meta']['PALETTE'] - elif hasattr(dataset, 'PALETTE'): - # segmentation dataset has `PALETTE` attribute - model.PALETTE = dataset.PALETTE - logger.info('DONE load check point') - model = MMDataParallel(model, device_ids=[0]) - model.eval() - - img_norm_cfg = cfg.img_norm_cfg - - # get denormalized param - mean = np.array(img_norm_cfg['mean'],dtype=np.float32) - std = np.array(img_norm_cfg['std'],dtype=np.float32) - to_bgr = img_norm_cfg['to_rgb'] - - # get pc_range - pc_range = cfg.point_cloud_range - - # get car icon - car_img = Image.open('./figs/lidar_car.png') - - # get color map: divider->r, ped->b, boundary->g - colors_plt = ['orange', 'b', 'r', 'g'] - - - logger.info('BEGIN vis test dataset samples gt label & pred') - - bbox_results = [] - mask_results = [] - dataset = data_loader.dataset - have_mask = False - # prog_bar = mmcv.ProgressBar(len(CANDIDATE)) - prog_bar = mmcv.ProgressBar(len(dataset)) - # import pdb;pdb.set_trace() - for i, data in enumerate(data_loader): - if ~(data['gt_labels_3d'].data[0][0] != -1).any(): - # import pdb;pdb.set_trace() - logger.error(f'\n empty gt for index {i}, continue') - # prog_bar.update() - continue - - - img = data['img'][0].data[0] - img_metas = data['img_metas'][0].data[0] - gt_bboxes_3d = data['gt_bboxes_3d'].data[0] - gt_labels_3d = data['gt_labels_3d'].data[0] - - pts_filename = img_metas[0]['pts_filename'] - pts_filename = osp.basename(pts_filename) - pts_filename = pts_filename.replace('__LIDAR_TOP__', '_').split('.')[0] - # import pdb;pdb.set_trace() - # if pts_filename not in CANDIDATE: - # continue - - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - sample_dir = osp.join(args.show_dir, pts_filename) - mmcv.mkdir_or_exist(osp.abspath(sample_dir)) - - filename_list = img_metas[0]['filename'] - img_path_dict = {} - # save cam img for sample - for filepath in filename_list: - filename = osp.basename(filepath) - filename_splits = filename.split('__') - # sample_dir = filename_splits[0] - # sample_dir = osp.join(args.show_dir, sample_dir) - # mmcv.mkdir_or_exist(osp.abspath(sample_dir)) - img_name = filename_splits[1] + '.jpg' - img_path = osp.join(sample_dir,img_name) - # img_path_list.append(img_path) - shutil.copyfile(filepath,img_path) - img_path_dict[filename_splits[1]] = img_path - - # surrounding view - row_1_list = [] - for cam in CAMS[:3]: - cam_img_name = cam + '.jpg' - cam_img = cv2.imread(osp.join(sample_dir, cam_img_name)) - row_1_list.append(cam_img) - row_2_list = [] - for cam in CAMS[3:]: - cam_img_name = cam + '.jpg' - cam_img = cv2.imread(osp.join(sample_dir, cam_img_name)) - row_2_list.append(cam_img) - row_1_img=cv2.hconcat(row_1_list) - row_2_img=cv2.hconcat(row_2_list) - cams_img = cv2.vconcat([row_1_img,row_2_img]) - cams_img_path = osp.join(sample_dir,'surroud_view.jpg') - cv2.imwrite(cams_img_path, cams_img,[cv2.IMWRITE_JPEG_QUALITY, 70]) - - for vis_format in args.gt_format: - if vis_format == 'se_pts': - gt_line_points = gt_bboxes_3d[0].start_end_points - for gt_bbox_3d, gt_label_3d in zip(gt_line_points, gt_labels_3d[0]): - pts = gt_bbox_3d.reshape(-1,2).numpy() - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - elif vis_format == 'bbox': - gt_lines_bbox = gt_bboxes_3d[0].bbox - for gt_bbox_3d, gt_label_3d in zip(gt_lines_bbox, gt_labels_3d[0]): - gt_bbox_3d = gt_bbox_3d.numpy() - xy = (gt_bbox_3d[0],gt_bbox_3d[1]) - width = gt_bbox_3d[2] - gt_bbox_3d[0] - height = gt_bbox_3d[3] - gt_bbox_3d[1] - # import pdb;pdb.set_trace() - plt.gca().add_patch(Rectangle(xy,width,height,linewidth=0.4,edgecolor=colors_plt[gt_label_3d],facecolor='none')) - # plt.Rectangle(xy, width, height,color=colors_plt[gt_label_3d]) - # continue - elif vis_format == 'fixed_num_pts': - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - # gt_bboxes_3d[0].fixed_num=30 #TODO, this is a hack - gt_lines_fixed_num_pts = gt_bboxes_3d[0].fixed_num_sampled_points - for gt_bbox_3d, gt_label_3d in zip(gt_lines_fixed_num_pts, gt_labels_3d[0]): - # import pdb;pdb.set_trace() - pts = gt_bbox_3d.numpy() - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - # plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - - - plt.plot(x, y, color=colors_plt[gt_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(x, y, color=colors_plt[gt_label_3d],s=2,alpha=0.8,zorder=-1) - # plt.plot(x, y, color=colors_plt[gt_label_3d]) - # plt.scatter(x, y, color=colors_plt[gt_label_3d],s=1) - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - gt_fixedpts_map_path = osp.join(sample_dir, 'GT_fixednum_pts_MAP.png') - plt.savefig(gt_fixedpts_map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - elif vis_format == 'polyline_pts': - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - gt_lines_instance = gt_bboxes_3d[0].instance_list - # import pdb;pdb.set_trace() - for gt_line_instance, gt_label_3d in zip(gt_lines_instance, gt_labels_3d[0]): - pts = np.array(list(gt_line_instance.coords)) - x = np.array([pt[0] for pt in pts]) - y = np.array([pt[1] for pt in pts]) - - # plt.quiver(x[:-1], y[:-1], x[1:] - x[:-1], y[1:] - y[:-1], scale_units='xy', angles='xy', scale=1, color=colors_plt[gt_label_3d]) - - # plt.plot(x, y, color=colors_plt[gt_label_3d]) - plt.plot(x, y, color=colors_plt[gt_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(x, y, color=colors_plt[gt_label_3d],s=1,alpha=0.8,zorder=-1) - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - gt_polyline_map_path = osp.join(sample_dir, 'GT_polyline_pts_MAP.png') - plt.savefig(gt_polyline_map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - else: - logger.error(f'WRONG visformat for GT: {vis_format}') - raise ValueError(f'WRONG visformat for GT: {vis_format}') - - - # import pdb;pdb.set_trace() - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - - # visualize pred - # import pdb;pdb.set_trace() - result_dic = result[0]['pts_bbox'] - boxes_3d = result_dic['boxes_3d'] # bbox: xmin, ymin, xmax, ymax - scores_3d = result_dic['scores_3d'] - labels_3d = result_dic['labels_3d'] - pts_3d = result_dic['pts_3d'] - keep = scores_3d > args.score_thresh - - plt.figure(figsize=(2, 4)) - plt.xlim(pc_range[0], pc_range[3]) - plt.ylim(pc_range[1], pc_range[4]) - plt.axis('off') - for pred_score_3d, pred_bbox_3d, pred_label_3d, pred_pts_3d in zip(scores_3d[keep], boxes_3d[keep],labels_3d[keep], pts_3d[keep]): - - pred_pts_3d = pred_pts_3d.numpy() - pts_x = pred_pts_3d[:,0] - pts_y = pred_pts_3d[:,1] - plt.plot(pts_x, pts_y, color=colors_plt[pred_label_3d],linewidth=1,alpha=0.8,zorder=-1) - plt.scatter(pts_x, pts_y, color=colors_plt[pred_label_3d],s=1,alpha=0.8,zorder=-1) - - - pred_bbox_3d = pred_bbox_3d.numpy() - xy = (pred_bbox_3d[0],pred_bbox_3d[1]) - width = pred_bbox_3d[2] - pred_bbox_3d[0] - height = pred_bbox_3d[3] - pred_bbox_3d[1] - pred_score_3d = float(pred_score_3d) - pred_score_3d = round(pred_score_3d, 2) - s = str(pred_score_3d) - - plt.imshow(car_img, extent=[-1.2, 1.2, -1.5, 1.5]) - - map_path = osp.join(sample_dir, 'PRED_MAP_plot.png') - plt.savefig(map_path, bbox_inches='tight', format='png',dpi=1200) - plt.close() - - prog_bar.update() - - logger.info('\n DONE vis test dataset samples gt label & pred') -if __name__ == '__main__': - main() diff --git a/docker-hub/MapTRv2/readme.md b/docker-hub/MapTRv2/readme.md deleted file mode 100644 index c6b11ab0bfd47a3df582c76a8e8ee319d5c88528..0000000000000000000000000000000000000000 --- a/docker-hub/MapTRv2/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# MapTRv2 - -## 环境构建 - -``` - docker run -dit --network=host --name=maptrv2 --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal:/opt/hyhal:ro -v /public/opendas/DL_DATA/zijia:/data:ro harbor.sourcefind.cn:5443/dcu/admin/base/custom:pytorch2.5.1-driver-maptrv2 -``` - -数据集已完成处理在乌镇集群/public/opendas/DL_DATA/zijia路径内 - -## 代码执行 - -``` -## 代码已经在容器/workspace下了 -cd /workspace/MapTR -bash start_maptrv2.sh -``` - - - diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/configs/_base_/datasets/nus-3d.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/configs/_base_/datasets/nus-3d.py deleted file mode 100644 index a48e1900b5cfb7a0e2ba6324674f7fedf90a5c4c..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/configs/_base_/datasets/nus-3d.py +++ /dev/null @@ -1,173 +0,0 @@ -# If point cloud range is changed, the models should also change their point -# cloud range accordingly -point_cloud_range = [-50, -50, -5, 50, 50, 3] -# Using calibration info convert the Lidar-coordinate point cloud range to the -# ego-coordinate point cloud range could bring a little promotion in nuScenes. -# point_cloud_range = [-50, -50.8, -5, 50, 49.2, 3] -# For nuScenes we usually do 10-class detection -class_names = [ - 'car', 'truck', 'trailer', 'bus', 'construction_vehicle', 'bicycle', - 'motorcycle', 'pedestrian', 'traffic_cone', 'barrier' -] -metainfo = dict(classes=class_names) -dataset_type = 'NuScenesDataset' -data_root = 'data/nuscenes/' -# Input modality for nuScenes dataset, this is consistent with the submission -# format which requires the information in input_modality. -input_modality = dict(use_lidar=True, use_camera=False) -data_prefix = dict(pts='samples/LIDAR_TOP', img='', sweeps='sweeps/LIDAR_TOP') - -# Example to use different file client -# Method 1: simply set the data root and let the file I/O module -# automatically infer from prefix (not support LMDB and Memcache yet) - -# data_root = 's3://openmmlab/datasets/detection3d/nuscenes/' - -# Method 2: Use backend_args, file_client_args in versions before 1.1.0 -# backend_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection3d/', -# 'data/': 's3://openmmlab/datasets/detection3d/' -# })) -backend_args = None - -train_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - backend_args=backend_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - backend_args=backend_args), - dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True), - dict( - type='GlobalRotScaleTrans', - rot_range=[-0.3925, 0.3925], - scale_ratio_range=[0.95, 1.05], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D', flip_ratio_bev_horizontal=0.5), - dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), - dict(type='ObjectNameFilter', classes=class_names), - dict(type='PointShuffle'), - dict( - type='Pack3DDetInputs', - keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) -] -test_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - backend_args=backend_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - test_mode=True, - backend_args=backend_args), - dict( - type='MultiScaleFlipAug3D', - img_scale=(1333, 800), - pts_scale_ratio=1, - flip=False, - transforms=[ - dict( - type='GlobalRotScaleTrans', - rot_range=[0, 0], - scale_ratio_range=[1., 1.], - translation_std=[0, 0, 0]), - dict(type='RandomFlip3D'), - dict( - type='PointsRangeFilter', point_cloud_range=point_cloud_range) - ]), - dict(type='Pack3DDetInputs', keys=['points']) -] -# construct a pipeline for data and gt loading in show function -# please keep its loading function consistent with test_pipeline (e.g. client) -eval_pipeline = [ - dict( - type='LoadPointsFromFile', - coord_type='LIDAR', - load_dim=5, - use_dim=5, - backend_args=backend_args), - dict( - type='LoadPointsFromMultiSweeps', - sweeps_num=10, - test_mode=True, - backend_args=backend_args), - dict(type='Pack3DDetInputs', keys=['points']) -] -train_dataloader = dict( - batch_size=6, - num_workers=6, - # 最优 - #batch_size=10, - #num_workers=10, - pin_memory=True, - persistent_workers=True, - sampler=dict(type='DefaultSampler', shuffle=True), - dataset=dict( - type=dataset_type, - data_root=data_root, - ann_file='nuscenes_infos_train.pkl', - pipeline=train_pipeline, - metainfo=metainfo, - modality=input_modality, - test_mode=False, - data_prefix=data_prefix, - # we use box_type_3d='LiDAR' in kitti and nuscenes dataset - # and box_type_3d='Depth' in sunrgbd and scannet dataset. - box_type_3d='LiDAR', - backend_args=backend_args)) -test_dataloader = dict( - batch_size=1, - num_workers=1, - persistent_workers=True, - drop_last=False, - sampler=dict(type='DefaultSampler', shuffle=False), - dataset=dict( - type=dataset_type, - data_root=data_root, - ann_file='nuscenes_infos_val.pkl', - pipeline=test_pipeline, - metainfo=metainfo, - modality=input_modality, - data_prefix=data_prefix, - test_mode=True, - box_type_3d='LiDAR', - backend_args=backend_args)) -val_dataloader = dict( - batch_size=1, - num_workers=1, - persistent_workers=True, - drop_last=False, - sampler=dict(type='DefaultSampler', shuffle=False), - dataset=dict( - type=dataset_type, - data_root=data_root, - ann_file='nuscenes_infos_val.pkl', - pipeline=test_pipeline, - metainfo=metainfo, - modality=input_modality, - test_mode=True, - data_prefix=data_prefix, - box_type_3d='LiDAR', - backend_args=backend_args)) - -val_evaluator = dict( - type='NuScenesMetric', - data_root=data_root, - ann_file=data_root + 'nuscenes_infos_val.pkl', - metric='bbox', - backend_args=backend_args) -test_evaluator = val_evaluator - -vis_backends = [dict(type='LocalVisBackend')] -visualizer = dict( - type='Det3DLocalVisualizer', vis_backends=vis_backends, name='visualizer') diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmcv-2.2.0+das.opt1.dtk25044.20260107.gb9d4e636-cp310-cp310-manylinux_2_28_x86_64.whl b/docker-hub/PointPillars/pointpillars/mmdetection3d/mmcv-2.2.0+das.opt1.dtk25044.20260107.gb9d4e636-cp310-cp310-manylinux_2_28_x86_64.whl deleted file mode 100644 index 71ccac726cace2310087bc81f535d152347208e4..0000000000000000000000000000000000000000 Binary files a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmcv-2.2.0+das.opt1.dtk25044.20260107.gb9d4e636-cp310-cp310-manylinux_2_28_x86_64.whl and /dev/null differ diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/data_preprocessors/voxelize.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/data_preprocessors/voxelize.py deleted file mode 100644 index 25cd5bf586a24e5b09767dde62c3f9eea8680ea9..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/data_preprocessors/voxelize.py +++ /dev/null @@ -1,326 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from typing import Any, List, Optional, Tuple, Union - -import torch -from mmcv.utils import ext_loader -from torch import nn -from torch.autograd import Function -from torch.nn import functional as F -from torch.nn.modules.utils import _pair - -ext_module = ext_loader.load_ext('_ext', [ - 'dynamic_voxelize_forward', 'hard_voxelize_forward', - 'dynamic_point_to_voxel_forward', 'dynamic_point_to_voxel_backward' -]) - - -class _Voxelization(Function): - - @staticmethod - def forward( - ctx: Any, - points: torch.Tensor, - voxel_size: Union[tuple, float], - coors_range: Union[tuple, float], - max_points: int = 35, - max_voxels: int = 20000, - deterministic: bool = True) -> Union[Tuple[torch.Tensor], Tuple]: - """Convert kitti points(N, >=3) to voxels. - - Args: - points (torch.Tensor): [N, ndim]. Points[:, :3] contain xyz points - and points[:, 3:] contain other information like reflectivity. - voxel_size (tuple or float): The size of voxel with the shape of - [3]. - coors_range (tuple or float): The coordinate range of voxel with - the shape of [6]. - max_points (int, optional): maximum points contained in a voxel. if - max_points=-1, it means using dynamic_voxelize. Default: 35. - max_voxels (int, optional): maximum voxels this function create. - for second, 20000 is a good choice. Users should shuffle points - before call this function because max_voxels may drop points. - Default: 20000. - deterministic: bool. whether to invoke the non-deterministic - version of hard-voxelization implementations. non-deterministic - version is considerablly fast but is not deterministic. only - affects hard voxelization. default True. for more information - of this argument and the implementation insights, please refer - to the following links: - https://github.com/open-mmlab/mmdetection3d/issues/894 - https://github.com/open-mmlab/mmdetection3d/pull/904 - it is an experimental feature and we will appreciate it if - you could share with us the failing cases. - - Returns: - tuple[torch.Tensor]: tuple[torch.Tensor]: A tuple contains three - elements. The first one is the output voxels with the shape of - [M, max_points, n_dim], which only contain points and returned - when max_points != -1. The second is the voxel coordinates with - shape of [M, 3]. The last is number of point per voxel with the - shape of [M], which only returned when max_points != -1. - """ - if max_points == -1 or max_voxels == -1: - coors = points.new_zeros(size=(points.size(0), 3), dtype=torch.int) - ext_module.dynamic_voxelize_forward( - points, - torch.tensor(voxel_size, dtype=torch.float), - torch.tensor(coors_range, dtype=torch.float), - coors, - NDim=3) - return coors - else: - voxels = points.new_zeros( - size=(max_voxels, max_points, points.size(1))) - coors = points.new_zeros(size=(max_voxels, 3), dtype=torch.int) - num_points_per_voxel = points.new_zeros( - size=(max_voxels, ), dtype=torch.int) - voxel_num = torch.zeros(size=(), dtype=torch.long) - ext_module.hard_voxelize_forward( - points, - torch.tensor(voxel_size, dtype=torch.float), - torch.tensor(coors_range, dtype=torch.float), - voxels, - coors, - num_points_per_voxel, - voxel_num, - max_points=max_points, - max_voxels=max_voxels, - NDim=3, - deterministic=deterministic) - # select the valid voxels - voxels_out = voxels[:voxel_num] - coors_out = coors[:voxel_num] - num_points_per_voxel_out = num_points_per_voxel[:voxel_num] - return voxels_out, coors_out, num_points_per_voxel_out - - -voxelization = _Voxelization.apply - - -class VoxelizationByGridShape(nn.Module): - """Voxelization that allows inferring voxel size automatically based on - grid shape. - - Please refer to `Point-Voxel CNN for Efficient 3D Deep Learning - `_ for more details. - - Args: - point_cloud_range (list): - [x_min, y_min, z_min, x_max, y_max, z_max] - max_num_points (int): max number of points per voxel - voxel_size (list): list [x, y, z] or [rho, phi, z] - size of single voxel. - grid_shape (list): [L, W, H], grid shape of voxelization. - max_voxels (tuple or int): max number of voxels in - (training, testing) time - deterministic: bool. whether to invoke the non-deterministic - version of hard-voxelization implementations. non-deterministic - version is considerablly fast but is not deterministic. only - affects hard voxelization. default True. for more information - of this argument and the implementation insights, please refer - to the following links: - https://github.com/open-mmlab/mmdetection3d/issues/894 - https://github.com/open-mmlab/mmdetection3d/pull/904 - it is an experimental feature and we will appreciate it if - you could share with us the failing cases. - """ - - def __init__(self, - point_cloud_range: List, - max_num_points: int, - voxel_size: List = [], - grid_shape: List[int] = [], - max_voxels: Union[tuple, int] = 20000, - deterministic: bool = True): - super().__init__() - if voxel_size and grid_shape: - raise ValueError('voxel_size is mutually exclusive grid_shape') - self.point_cloud_range = point_cloud_range - self.max_num_points = max_num_points - if isinstance(max_voxels, tuple): - self.max_voxels = max_voxels - else: - self.max_voxels = _pair(max_voxels) - self.deterministic = deterministic - - point_cloud_range = torch.tensor( - point_cloud_range, dtype=torch.float32) - if voxel_size: - self.voxel_size = voxel_size - voxel_size = torch.tensor(voxel_size, dtype=torch.float32) - grid_shape = (point_cloud_range[3:] - - point_cloud_range[:3]) / voxel_size - grid_shape = torch.round(grid_shape).long().tolist() - self.grid_shape = grid_shape - elif grid_shape: - grid_shape = torch.tensor(grid_shape, dtype=torch.float32) - voxel_size = (point_cloud_range[3:] - point_cloud_range[:3]) / ( - grid_shape - 1) - voxel_size = voxel_size.tolist() - self.voxel_size = voxel_size - else: - raise ValueError('must assign a value to voxel_size or grid_shape') - - def forward(self, input: torch.Tensor) -> torch.Tensor: - if self.training: - max_voxels = self.max_voxels[0] - else: - max_voxels = self.max_voxels[1] - - return voxelization(input, self.voxel_size, self.point_cloud_range, - self.max_num_points, max_voxels, - self.deterministic) - - def __repr__(self): - s = self.__class__.__name__ + '(' - s += 'voxel_size=' + str(self.voxel_size) - s += ', grid_shape=' + str(self.grid_shape) - s += ', point_cloud_range=' + str(self.point_cloud_range) - s += ', max_num_points=' + str(self.max_num_points) - s += ', max_voxels=' + str(self.max_voxels) - s += ', deterministic=' + str(self.deterministic) - s += ')' - return s - - -class _DynamicScatter(Function): - """Different from the mmcv implementation, here it is allowed to return - point2voxel_map.""" - - @staticmethod - def forward(ctx: Any, - feats: torch.Tensor, - coors: torch.Tensor, - reduce_type: str = 'max', - return_map: str = False) -> Tuple[torch.Tensor, torch.Tensor]: - """convert kitti points(N, >=3) to voxels. - - Args: - feats (torch.Tensor): [N, C]. Points features to be reduced - into voxels. - coors (torch.Tensor): [N, ndim]. Corresponding voxel coordinates - (specifically multi-dim voxel index) of each points. - reduce_type (str, optional): Reduce op. support 'max', 'sum' and - 'mean'. Default: 'max'. - return_map (str, optional): Whether to return point2voxel_map. - - Returns: - tuple[torch.Tensor]: A tuple contains two elements. The first one - is the voxel features with shape [M, C] which are respectively - reduced from input features that share the same voxel coordinates. - The second is voxel coordinates with shape [M, ndim]. - """ - results = ext_module.dynamic_point_to_voxel_forward( - feats, coors, reduce_type) - (voxel_feats, voxel_coors, point2voxel_map, - voxel_points_count) = results - ctx.reduce_type = reduce_type - ctx.save_for_backward(feats, voxel_feats, point2voxel_map, - voxel_points_count) - ctx.mark_non_differentiable(voxel_coors) - if return_map: - return voxel_feats, voxel_coors, point2voxel_map - else: - return voxel_feats, voxel_coors - - @staticmethod - def backward(ctx: Any, - grad_voxel_feats: torch.Tensor, - grad_voxel_coors: Optional[torch.Tensor] = None) -> tuple: - (feats, voxel_feats, point2voxel_map, - voxel_points_count) = ctx.saved_tensors - grad_feats = torch.zeros_like(feats) - # TODO: whether to use index put or use cuda_backward - # To use index put, need point to voxel index - ext_module.dynamic_point_to_voxel_backward( - grad_feats, grad_voxel_feats.contiguous(), feats, voxel_feats, - point2voxel_map, voxel_points_count, ctx.reduce_type) - return grad_feats, None, None - - -dynamic_scatter_3d = _DynamicScatter.apply - - -class DynamicScatter3D(nn.Module): - """Scatters points into voxels, used in the voxel encoder with dynamic - voxelization. - - Note: - The CPU and GPU implementation get the same output, but have numerical - difference after summation and division (e.g., 5e-7). - - Args: - voxel_size (list): list [x, y, z] size of three dimension. - point_cloud_range (list): The coordinate range of points, [x_min, - y_min, z_min, x_max, y_max, z_max]. - average_points (bool): whether to use avg pooling to scatter points - into voxel. - """ - - def __init__(self, voxel_size: List, point_cloud_range: List, - average_points: bool): - super().__init__() - - self.voxel_size = voxel_size - self.point_cloud_range = point_cloud_range - self.average_points = average_points - - def forward_single( - self, points: torch.Tensor, - coors: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: - """Scatters points into voxels. - - Args: - points (torch.Tensor): Points to be reduced into voxels. - coors (torch.Tensor): Corresponding voxel coordinates (specifically - multi-dim voxel index) of each points. - - Returns: - tuple[torch.Tensor]: A tuple contains two elements. The first one - is the voxel features with shape [M, C] which are respectively - reduced from input features that share the same voxel coordinates. - The second is voxel coordinates with shape [M, ndim]. - """ - reduce = 'mean' if self.average_points else 'max' - return dynamic_scatter_3d(points.contiguous(), coors.contiguous(), - reduce) - - def forward(self, points: torch.Tensor, - coors: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: - """Scatters points/features into voxels. - - Args: - points (torch.Tensor): Points to be reduced into voxels. - coors (torch.Tensor): Corresponding voxel coordinates (specifically - multi-dim voxel index) of each points. - - Returns: - tuple[torch.Tensor]: A tuple contains two elements. The first one - is the voxel features with shape [M, C] which are respectively - reduced from input features that share the same voxel coordinates. - The second is voxel coordinates with shape [M, ndim]. - """ - if coors.size(-1) == 3: - return self.forward_single(points, coors) - else: - batch_size = coors[-1, 0] + 1 - voxels, voxel_coors = [], [] - for i in range(batch_size): - inds = torch.where(coors[:, 0] == i) - voxel, voxel_coor = self.forward_single( - points[inds], coors[inds][:, 1:]) - coor_pad = F.pad(voxel_coor, (1, 0), mode='constant', value=i) - voxel_coors.append(coor_pad) - voxels.append(voxel) - features = torch.cat(voxels, dim=0) - feature_coors = torch.cat(voxel_coors, dim=0) - - return features, feature_coors - - def __repr__(self): - s = self.__class__.__name__ + '(' - s += 'voxel_size=' + str(self.voxel_size) - s += ', point_cloud_range=' + str(self.point_cloud_range) - s += ', average_points=' + str(self.average_points) - s += ')' - return s diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py deleted file mode 100644 index 11287587dfdc745ce679f7ef844278a57a601edd..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/models/middle_encoders/pillar_scatter.py +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from typing import List - -import torch -from torch import Tensor, nn - -from mmdet3d.registry import MODELS - - -@MODELS.register_module() -class PointPillarsScatter(nn.Module): - """Point Pillar's Scatter. - - Converts learned features from dense tensor to sparse pseudo image. - - Args: - in_channels (int): Channels of input features. - output_shape (list[int]): Required output shape of features. - """ - - def __init__(self, in_channels: int, output_shape: List[int]): - super().__init__() - self.output_shape = output_shape - self.ny = output_shape[0] - self.nx = output_shape[1] - self.in_channels = in_channels - - def forward(self, - voxel_features: Tensor, - coors: Tensor, - batch_size: int = None) -> Tensor: - """Foraward function to scatter features.""" - # TODO: rewrite the function in a batch manner - # no need to deal with different batch cases - if batch_size is not None: - return self.forward_batch(voxel_features, coors, batch_size) - else: - return self.forward_single(voxel_features, coors) - - def forward_single(self, voxel_features: Tensor, coors: Tensor) -> Tensor: - """Scatter features of single sample. - - Args: - voxel_features (torch.Tensor): Voxel features in shape (N, M, C). - coors (torch.Tensor): Coordinates of each voxel. - The first column indicates the sample ID. - """ - # Create the canvas for this sample - canvas = torch.zeros( - self.in_channels, - self.nx * self.ny, - dtype=voxel_features.dtype, - device=voxel_features.device) - - indices = coors[:, 2] * self.nx + coors[:, 3] - indices = indices.long() - voxels = voxel_features.t() - # Now scatter the blob back to the canvas. - canvas[:, indices] = voxels - # Undo the column stacking to final 4-dim tensor - canvas = canvas.view(1, self.in_channels, self.ny, self.nx) - return canvas - - def forward_batch(self, voxel_features: Tensor, coors: Tensor, - batch_size: int) -> Tensor: - """Scatter features of single sample. - - Args: - voxel_features (torch.Tensor): Voxel features in shape (N, M, C). - coors (torch.Tensor): Coordinates of each voxel in shape (N, 4). - The first column indicates the sample ID. - batch_size (int): Number of samples in the current batch. - """ - # batch_canvas will be the final output. - batch_canvas = [] - for batch_itt in range(batch_size): - # Create the canvas for this sample - canvas = torch.zeros( - self.in_channels, - self.nx * self.ny, - dtype=voxel_features.dtype, - device=voxel_features.device) - - # Only include non-empty pillars - batch_mask = coors[:, 0] == batch_itt - this_coors = coors[batch_mask, :] - indices = this_coors[:, 2] * self.nx + this_coors[:, 3] - indices = indices.type(torch.long) - voxels = voxel_features[batch_mask, :] - voxels = voxels.t() - - # Now scatter the blob back to the canvas. - canvas[:, indices] = voxels - - # Append to a list for later stacking. - batch_canvas.append(canvas) - - # Stack to 3-dim tensor (batch-size, in_channels, nrows*ncols) - batch_canvas = torch.stack(batch_canvas, 0) - - # Undo the column stacking to final 4-dim tensor - batch_canvas = batch_canvas.view(batch_size, self.in_channels, self.ny, - self.nx) - - return batch_canvas diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/structures/ops/iou3d_calculator.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/structures/ops/iou3d_calculator.py deleted file mode 100644 index 9d9954546b912febf2b761d9118f89d914cccf98..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/structures/ops/iou3d_calculator.py +++ /dev/null @@ -1,328 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import torch -from mmdet.structures.bbox import bbox_overlaps -from mmdet3d.registry import TASK_UTILS -from mmdet3d.structures.bbox_3d import get_box_type - - -@TASK_UTILS.register_module() -class BboxOverlapsNearest3D(object): - """Nearest 3D IoU Calculator. - - Note: - This IoU calculator first finds the nearest 2D boxes in bird eye view - (BEV), and then calculates the 2D IoU using :meth:`bbox_overlaps`. - - Args: - coordinate (str): 'camera', 'lidar', or 'depth' coordinate system. - """ - - def __init__(self, coordinate='lidar'): - assert coordinate in ['camera', 'lidar', 'depth'] - self.coordinate = coordinate - - def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False): - """Calculate nearest 3D IoU. - - Note: - If ``is_aligned`` is ``False``, then it calculates the ious between - each bbox of bboxes1 and bboxes2, otherwise it calculates the ious - between each aligned pair of bboxes1 and bboxes2. - - Args: - bboxes1 (torch.Tensor): shape (N, 7+N) - [x, y, z, x_size, y_size, z_size, ry, v]. - bboxes2 (torch.Tensor): shape (M, 7+N) - [x, y, z, x_size, y_size, z_size, ry, v]. - mode (str): "iou" (intersection over union) or iof - (intersection over foreground). - is_aligned (bool): Whether the calculation is aligned. - - Return: - torch.Tensor: If ``is_aligned`` is ``True``, return ious between - bboxes1 and bboxes2 with shape (M, N). If ``is_aligned`` is - ``False``, return shape is M. - """ - return bbox_overlaps_nearest_3d(bboxes1, bboxes2, mode, is_aligned, - self.coordinate) - - def __repr__(self): - """str: Return a string that describes the module.""" - repr_str = self.__class__.__name__ - repr_str += f'(coordinate={self.coordinate}' - return repr_str - - -@TASK_UTILS.register_module() -class BboxOverlaps3D(object): - """3D IoU Calculator. - - Args: - coordinate (str): The coordinate system, valid options are - 'camera', 'lidar', and 'depth'. - """ - - def __init__(self, coordinate): - assert coordinate in ['camera', 'lidar', 'depth'] - self.coordinate = coordinate - - def __call__(self, bboxes1, bboxes2, mode='iou'): - """Calculate 3D IoU using cuda implementation. - - Note: - This function calculate the IoU of 3D boxes based on their volumes. - IoU calculator ``:class:BboxOverlaps3D`` uses this function to - calculate the actual 3D IoUs of boxes. - - Args: - bboxes1 (torch.Tensor): with shape (N, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - bboxes2 (torch.Tensor): with shape (M, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - mode (str): "iou" (intersection over union) or - iof (intersection over foreground). - - Return: - torch.Tensor: Bbox overlaps results of bboxes1 and bboxes2 - with shape (M, N) (aligned mode is not supported currently). - """ - return bbox_overlaps_3d(bboxes1, bboxes2, mode, self.coordinate) - - def __repr__(self): - """str: return a string that describes the module""" - repr_str = self.__class__.__name__ - repr_str += f'(coordinate={self.coordinate}' - return repr_str - -#@torch.compile() -def bbox_overlaps_nearest_3d(bboxes1, - bboxes2, - mode='iou', - is_aligned=False, - coordinate='lidar'): - """Calculate nearest 3D IoU. - - Note: - This function first finds the nearest 2D boxes in bird eye view - (BEV), and then calculates the 2D IoU using :meth:`bbox_overlaps`. - This IoU calculator :class:`BboxOverlapsNearest3D` uses this - function to calculate IoUs of boxes. - - If ``is_aligned`` is ``False``, then it calculates the ious between - each bbox of bboxes1 and bboxes2, otherwise the ious between each - aligned pair of bboxes1 and bboxes2. - - Args: - bboxes1 (torch.Tensor): with shape (N, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - bboxes2 (torch.Tensor): with shape (M, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - mode (str): "iou" (intersection over union) or iof - (intersection over foreground). - is_aligned (bool): Whether the calculation is aligned - - Return: - torch.Tensor: If ``is_aligned`` is ``True``, return ious between - bboxes1 and bboxes2 with shape (M, N). If ``is_aligned`` is - ``False``, return shape is M. - """ - assert bboxes1.size(-1) == bboxes2.size(-1) >= 7 - - box_type, _ = get_box_type(coordinate) - - bboxes1 = box_type(bboxes1, box_dim=bboxes1.shape[-1]) - bboxes2 = box_type(bboxes2, box_dim=bboxes2.shape[-1]) - - # Change the bboxes to bev - # box conversion and iou calculation in torch version on CUDA - # is 10x faster than that in numpy version - bboxes1_bev = bboxes1.nearest_bev - bboxes2_bev = bboxes2.nearest_bev - - ret = bbox_overlaps( - bboxes1_bev, bboxes2_bev, mode=mode, is_aligned=is_aligned) - return ret - - -def bbox_overlaps_3d(bboxes1, bboxes2, mode='iou', coordinate='camera'): - """Calculate 3D IoU using cuda implementation. - - Note: - This function calculates the IoU of 3D boxes based on their volumes. - IoU calculator :class:`BboxOverlaps3D` uses this function to - calculate the actual IoUs of boxes. - - Args: - bboxes1 (torch.Tensor): with shape (N, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - bboxes2 (torch.Tensor): with shape (M, 7+C), - (x, y, z, x_size, y_size, z_size, ry, v*). - mode (str): "iou" (intersection over union) or - iof (intersection over foreground). - coordinate (str): 'camera' or 'lidar' coordinate system. - - Return: - torch.Tensor: Bbox overlaps results of bboxes1 and bboxes2 - with shape (M, N) (aligned mode is not supported currently). - """ - assert bboxes1.size(-1) == bboxes2.size(-1) >= 7 - - box_type, _ = get_box_type(coordinate) - - bboxes1 = box_type(bboxes1, box_dim=bboxes1.shape[-1]) - bboxes2 = box_type(bboxes2, box_dim=bboxes2.shape[-1]) - - return bboxes1.overlaps(bboxes1, bboxes2, mode=mode) - - -@TASK_UTILS.register_module() -class AxisAlignedBboxOverlaps3D(object): - """Axis-aligned 3D Overlaps (IoU) Calculator.""" - - def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False): - """Calculate IoU between 2D bboxes. - - Args: - bboxes1 (Tensor): shape (B, m, 6) in - format or empty. - bboxes2 (Tensor): shape (B, n, 6) in - format or empty. - B indicates the batch dim, in shape (B1, B2, ..., Bn). - If ``is_aligned`` is ``True``, then m and n must be equal. - mode (str): "iou" (intersection over union) or "giou" (generalized - intersection over union). - is_aligned (bool, optional): If True, then m and n must be equal. - Defaults to False. - Returns: - Tensor: shape (m, n) if ``is_aligned`` is False else shape (m,) - """ - assert bboxes1.size(-1) == bboxes2.size(-1) == 6 - return axis_aligned_bbox_overlaps_3d(bboxes1, bboxes2, mode, - is_aligned) - - def __repr__(self): - """str: a string describing the module""" - repr_str = self.__class__.__name__ + '()' - return repr_str - - -def axis_aligned_bbox_overlaps_3d(bboxes1, - bboxes2, - mode='iou', - is_aligned=False, - eps=1e-6): - """Calculate overlap between two set of axis aligned 3D bboxes. If - ``is_aligned`` is ``False``, then calculate the overlaps between each bbox - of bboxes1 and bboxes2, otherwise the overlaps between each aligned pair of - bboxes1 and bboxes2. - - Args: - bboxes1 (Tensor): shape (B, m, 6) in - format or empty. - bboxes2 (Tensor): shape (B, n, 6) in - format or empty. - B indicates the batch dim, in shape (B1, B2, ..., Bn). - If ``is_aligned`` is ``True``, then m and n must be equal. - mode (str): "iou" (intersection over union) or "giou" (generalized - intersection over union). - is_aligned (bool, optional): If True, then m and n must be equal. - Defaults to False. - eps (float, optional): A value added to the denominator for numerical - stability. Defaults to 1e-6. - - Returns: - Tensor: shape (m, n) if ``is_aligned`` is False else shape (m,) - - Example: - >>> bboxes1 = torch.FloatTensor([ - >>> [0, 0, 0, 10, 10, 10], - >>> [10, 10, 10, 20, 20, 20], - >>> [32, 32, 32, 38, 40, 42], - >>> ]) - >>> bboxes2 = torch.FloatTensor([ - >>> [0, 0, 0, 10, 20, 20], - >>> [0, 10, 10, 10, 19, 20], - >>> [10, 10, 10, 20, 20, 20], - >>> ]) - >>> overlaps = axis_aligned_bbox_overlaps_3d(bboxes1, bboxes2) - >>> assert overlaps.shape == (3, 3) - >>> overlaps = bbox_overlaps(bboxes1, bboxes2, is_aligned=True) - >>> assert overlaps.shape == (3, ) - Example: - >>> empty = torch.empty(0, 6) - >>> nonempty = torch.FloatTensor([[0, 0, 0, 10, 9, 10]]) - >>> assert tuple(bbox_overlaps(empty, nonempty).shape) == (0, 1) - >>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0) - >>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0) - """ - - assert mode in ['iou', 'giou'], f'Unsupported mode {mode}' - # Either the boxes are empty or the length of boxes's last dimension is 6 - assert (bboxes1.size(-1) == 6 or bboxes1.size(0) == 0) - assert (bboxes2.size(-1) == 6 or bboxes2.size(0) == 0) - - # Batch dim must be the same - # Batch dim: (B1, B2, ... Bn) - assert bboxes1.shape[:-2] == bboxes2.shape[:-2] - batch_shape = bboxes1.shape[:-2] - - rows = bboxes1.size(-2) - cols = bboxes2.size(-2) - if is_aligned: - assert rows == cols - - if rows * cols == 0: - if is_aligned: - return bboxes1.new(batch_shape + (rows, )) - else: - return bboxes1.new(batch_shape + (rows, cols)) - - area1 = (bboxes1[..., 3] - - bboxes1[..., 0]) * (bboxes1[..., 4] - bboxes1[..., 1]) * ( - bboxes1[..., 5] - bboxes1[..., 2]) - area2 = (bboxes2[..., 3] - - bboxes2[..., 0]) * (bboxes2[..., 4] - bboxes2[..., 1]) * ( - bboxes2[..., 5] - bboxes2[..., 2]) - - if is_aligned: - lt = torch.max(bboxes1[..., :3], bboxes2[..., :3]) # [B, rows, 3] - rb = torch.min(bboxes1[..., 3:], bboxes2[..., 3:]) # [B, rows, 3] - - wh = (rb - lt).clamp(min=0) # [B, rows, 2] - overlap = wh[..., 0] * wh[..., 1] * wh[..., 2] - - if mode in ['iou', 'giou']: - union = area1 + area2 - overlap - else: - union = area1 - if mode == 'giou': - enclosed_lt = torch.min(bboxes1[..., :3], bboxes2[..., :3]) - enclosed_rb = torch.max(bboxes1[..., 3:], bboxes2[..., 3:]) - else: - lt = torch.max(bboxes1[..., :, None, :3], - bboxes2[..., None, :, :3]) # [B, rows, cols, 3] - rb = torch.min(bboxes1[..., :, None, 3:], - bboxes2[..., None, :, 3:]) # [B, rows, cols, 3] - - wh = (rb - lt).clamp(min=0) # [B, rows, cols, 3] - overlap = wh[..., 0] * wh[..., 1] * wh[..., 2] - - if mode in ['iou', 'giou']: - union = area1[..., None] + area2[..., None, :] - overlap - if mode == 'giou': - enclosed_lt = torch.min(bboxes1[..., :, None, :3], - bboxes2[..., None, :, :3]) - enclosed_rb = torch.max(bboxes1[..., :, None, 3:], - bboxes2[..., None, :, 3:]) - - eps = union.new_tensor([eps]) - union = torch.max(union, eps) - ious = overlap / union - if mode in ['iou']: - return ious - # calculate gious - enclose_wh = (enclosed_rb - enclosed_lt).clamp(min=0) - enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1] * enclose_wh[..., 2] - enclose_area = torch.max(enclose_area, eps) - gious = ious - (enclose_area - union) / enclose_area - return gious diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/utils/__init__.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/utils/__init__.py deleted file mode 100644 index b5ed45629f51128279ea44248860e6418fce4dbd..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/mmdet3d/utils/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from .array_converter import ArrayConverter, array_converter -from .collect_env import collect_env -from .compat_cfg import compat_cfg -from .misc import replace_ceph_backend -from .setup_env import register_all_modules, setup_multi_processes -from .typing_utils import (ConfigType, InstanceList, MultiConfig, - OptConfigType, OptInstanceList, OptMultiConfig, - OptSampleList, OptSamplingResultList) - -__all__ = [ - 'collect_env', 'setup_multi_processes', 'compat_cfg', - 'register_all_modules', 'array_converter', 'ArrayConverter', 'ConfigType', - 'OptConfigType', 'MultiConfig', 'OptMultiConfig', 'InstanceList', - 'OptInstanceList', 'OptSamplingResultList', 'replace_ceph_backend', - 'OptSampleList' -] diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/voxelize.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/voxelize.py deleted file mode 100644 index fc48942d390f9ae1f9b2ceef87594a3912bb3ad5..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/projects/BEVFusion/bevfusion/ops/voxel/voxelize.py +++ /dev/null @@ -1,161 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved -import torch -from torch import nn -from torch.autograd import Function -from torch.nn.modules.utils import _pair - -# from .voxel_layer import dynamic_voxelize, hard_voxelize -from voxel.voxel_layer import dynamic_voxelize, hard_voxelize - -class _Voxelization(Function): - - @staticmethod - def forward(ctx, - points, - voxel_size, - coors_range, - max_points=35, - max_voxels=20000, - deterministic=True): - """convert kitti points(N, >=3) to voxels. - - Args: - points: [N, ndim] float tensor. points[:, :3] contain xyz points - and points[:, 3:] contain other information like reflectivity - voxel_size: [3] list/tuple or array, float. xyz, indicate voxel - size - coors_range: [6] list/tuple or array, float. indicate voxel - range. format: xyzxyz, minmax - max_points: int. indicate maximum points contained in a voxel. if - max_points=-1, it means using dynamic_voxelize - max_voxels: int. indicate maximum voxels this function create. - for second, 20000 is a good choice. Users should shuffle points - before call this function because max_voxels may drop points. - deterministic: bool. whether to invoke the non-deterministic - version of hard-voxelization implementations. non-deterministic - version is considerablly fast but is not deterministic. only - affects hard voxelization. default True. for more information - of this argument and the implementation insights, please refer - to the following links: - https://github.com/open-mmlab/mmdetection3d/issues/894 - https://github.com/open-mmlab/mmdetection3d/pull/904 - it is an experimental feature and we will appreciate it if - you could share with us the failing cases. - - Returns: - voxels: [M, max_points, ndim] float tensor. only contain points - and returned when max_points != -1. - coordinates: [M, 3] int32 tensor, always returned. - num_points_per_voxel: [M] int32 tensor. Only returned when - max_points != -1. - """ - if max_points == -1 or max_voxels == -1: - coors = points.new_zeros(size=(points.size(0), 3), dtype=torch.int) - dynamic_voxelize(points, coors, voxel_size, coors_range, 3) - return coors - else: - voxels = points.new_zeros( - size=(max_voxels, max_points, points.size(1))) - coors = points.new_zeros(size=(max_voxels, 3), dtype=torch.int) - num_points_per_voxel = points.new_zeros( - size=(max_voxels, ), dtype=torch.int) - voxel_num = hard_voxelize( - points, - voxels, - coors, - num_points_per_voxel, - voxel_size, - coors_range, - max_points, - max_voxels, - 3, - deterministic, - ) - # select the valid voxels - voxels_out = voxels[:voxel_num] - coors_out = coors[:voxel_num] - num_points_per_voxel_out = num_points_per_voxel[:voxel_num] - return voxels_out, coors_out, num_points_per_voxel_out - - -voxelization = _Voxelization.apply - - -class Voxelization(nn.Module): - - def __init__(self, - voxel_size, - point_cloud_range, - max_num_points, - max_voxels=20000, - deterministic=True): - super(Voxelization, self).__init__() - """ - Args: - voxel_size (list): list [x, y, z] size of three dimension - point_cloud_range (list): - [x_min, y_min, z_min, x_max, y_max, z_max] - max_num_points (int): max number of points per voxel - max_voxels (tuple or int): max number of voxels in - (training, testing) time - deterministic: bool. whether to invoke the non-deterministic - version of hard-voxelization implementations. non-deterministic - version is considerablly fast but is not deterministic. only - affects hard voxelization. default True. for more information - of this argument and the implementation insights, please refer - to the following links: - https://github.com/open-mmlab/mmdetection3d/issues/894 - https://github.com/open-mmlab/mmdetection3d/pull/904 - it is an experimental feature and we will appreciate it if - you could share with us the failing cases. - """ - self.voxel_size = voxel_size - self.point_cloud_range = point_cloud_range - self.max_num_points = max_num_points - if isinstance(max_voxels, tuple): - self.max_voxels = max_voxels - else: - self.max_voxels = _pair(max_voxels) - self.deterministic = deterministic - - point_cloud_range = torch.tensor( - point_cloud_range, dtype=torch.float32) - # [0, -40, -3, 70.4, 40, 1] - voxel_size = torch.tensor(voxel_size, dtype=torch.float32) - grid_size = (point_cloud_range[3:] - - point_cloud_range[:3]) / voxel_size - grid_size = torch.round(grid_size).long() - input_feat_shape = grid_size[:2] - self.grid_size = grid_size - # the origin shape is as [x-len, y-len, z-len] - # [w, h, d] -> [d, h, w] removed - self.pcd_shape = [*input_feat_shape, 1] # [::-1] - - def forward(self, input): - """ - Args: - input: NC points - """ - if self.training: - max_voxels = self.max_voxels[0] - else: - max_voxels = self.max_voxels[1] - - return voxelization( - input, - self.voxel_size, - self.point_cloud_range, - self.max_num_points, - max_voxels, - self.deterministic, - ) - - def __repr__(self): - tmpstr = self.__class__.__name__ + '(' - tmpstr += 'voxel_size=' + str(self.voxel_size) - tmpstr += ', point_cloud_range=' + str(self.point_cloud_range) - tmpstr += ', max_num_points=' + str(self.max_num_points) - tmpstr += ', max_voxels=' + str(self.max_voxels) - tmpstr += ', deterministic=' + str(self.deterministic) - tmpstr += ')' - return tmpstr diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/start_pointpillars.sh b/docker-hub/PointPillars/pointpillars/mmdetection3d/start_pointpillars.sh deleted file mode 100755 index c79020d761add3e6c9af9e9090b94be4ec0d83f7..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/start_pointpillars.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -export NCCL_TOPO_FILE=null -export NCCL_ALGO=Ring -export NCCL_RINGS="N0 0 7 6 5 4 3 2 1 N0|N1 1 2 3 4 5 6 7 0 N1|N2 2 1 0 7 6 5 4 3 N2|N3 3 4 5 6 7 0 1 2 N3|N4 4 3 2 1 0 7 6 5 N4|N5 5 6 7 0 1 2 3 4 N5|N6 6 5 4 3 2 1 0 7 N6|N7 7 0 1 2 3 4 5 6 N7" - -export PYTORCH_MIOPEN_SUGGEST_NHWC=1 -export MIOPEN_PRECISION_FP32_FP32_FP32_TF32_FP32=1 -export MIOPEN_FIND_MODE=1 -export ROCBLAS_MATH_MODE=1 - - -#export MIOPEN_ENABLE_LOGGING=1 # 打开MIOPEN LOGGING日志 default =0 -#export MIOPEN_ENABLE_LOGGING_CMD=1 # 输出日志CMD信息 default =0 -#export MIOPEN_LOG_LEVEL=6 # 设置日志打印level default=0 -#export ROCBLAS_LAYER=3 # 打开 rocblas输出日志 default=0 - - -TIME=$(date "+%Y-%m-%d_%H_%M") - -MASTER_ADDR=${1:-localhost} -NNODES=${2:-1} -NODE_RANK=${3:-0} -CONFIG=${4:-./configs/pointpillars/pointpillars_hv_fpn_sbn-all_8xb4-2x_nus-3d.py} - -bash tools/dist_train_numa.sh $MASTER_ADDR $NNODES $NODE_RANK $CONFIG \ - 2>&1 | tee cvm_bw1000_pointpillars_${NNODES}nodes_$TIME.log diff --git a/docker-hub/PointPillars/pointpillars/mmdetection3d/tools/train.py b/docker-hub/PointPillars/pointpillars/mmdetection3d/tools/train.py deleted file mode 100644 index d66bcfbe8ec3e55fc51c95be6d797886db297c1e..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/pointpillars/mmdetection3d/tools/train.py +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -import argparse -import logging -import os -import os.path as osp - -from mmengine.config import Config, DictAction -from mmengine.logging import print_log -from mmengine.registry import RUNNERS -from mmengine.runner import Runner - -from mmdet3d.utils import replace_ceph_backend -import torch - - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a 3D detector') - parser.add_argument('config', help='train config file path') - parser.add_argument('--work-dir', help='the dir to save logs and models') - parser.add_argument( - '--amp', - action='store_true', - default=False, - help='enable automatic-mixed-precision training') - parser.add_argument( - '--sync_bn', - choices=['none', 'torch', 'mmcv'], - default='none', - help='convert all BatchNorm layers in the model to SyncBatchNorm ' - '(SyncBN) or mmcv.ops.sync_bn.SyncBatchNorm (MMSyncBN) layers.') - parser.add_argument( - '--auto-scale-lr', - action='store_true', - help='enable automatically scaling LR.') - parser.add_argument( - '--resume', - nargs='?', - type=str, - const='auto', - help='If specify checkpoint path, resume from it, while if not ' - 'specify, try to auto resume from the latest checkpoint ' - 'in the work directory.') - parser.add_argument( - '--ceph', action='store_true', help='Use ceph as data storage backend') - parser.add_argument( - '--cfg-options', - nargs='+', - action=DictAction, - help='override some settings in the used config, the key-value pair ' - 'in xxx=yyy format will be merged into config file. If the value to ' - 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' - 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' - 'Note that the quotation marks are necessary and that no white space ' - 'is allowed.') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - # When using PyTorch version >= 2.0.0, the `torch.distributed.launch` - # will pass the `--local-rank` parameter to `tools/train.py` instead - # of `--local_rank`. - parser.add_argument('--local-rank', '--local-rank', type=int, default=0) - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - return args - - -def main(): - args = parse_args() - - # load config - cfg = Config.fromfile(args.config) - - # TODO: We will unify the ceph support approach with other OpenMMLab repos - if args.ceph: - cfg = replace_ceph_backend(cfg) - - cfg.launcher = args.launcher - if args.cfg_options is not None: - cfg.merge_from_dict(args.cfg_options) - - # work_dir is determined in this priority: CLI > segment in file > filename - if args.work_dir is not None: - # update configs according to CLI args if args.work_dir is not None - cfg.work_dir = args.work_dir - elif cfg.get('work_dir', None) is None: - # use config filename as default work_dir if cfg.work_dir is None - cfg.work_dir = osp.join('./work_dirs', - osp.splitext(osp.basename(args.config))[0]) - - # enable automatic-mixed-precision training - if args.amp is True: - optim_wrapper = cfg.optim_wrapper.type - if optim_wrapper == 'AmpOptimWrapper': - print_log( - 'AMP training is already enabled in your config.', - logger='current', - level=logging.WARNING) - else: - assert optim_wrapper == 'OptimWrapper', ( - '`--amp` is only supported when the optimizer wrapper type is ' - f'`OptimWrapper` but got {optim_wrapper}.') - cfg.optim_wrapper.type = 'AmpOptimWrapper' - cfg.optim_wrapper.loss_scale = 'dynamic' - - # convert BatchNorm layers - if args.sync_bn != 'none': - cfg.sync_bn = args.sync_bn - - # enable automatically scaling LR - if args.auto_scale_lr: - if 'auto_scale_lr' in cfg and \ - 'enable' in cfg.auto_scale_lr and \ - 'base_batch_size' in cfg.auto_scale_lr: - cfg.auto_scale_lr.enable = True - else: - raise RuntimeError('Can not find "auto_scale_lr" or ' - '"auto_scale_lr.enable" or ' - '"auto_scale_lr.base_batch_size" in your' - ' configuration file.') - - # resume is determined in this priority: resume from > auto_resume - if args.resume == 'auto': - cfg.resume = True - cfg.load_from = None - elif args.resume is not None: - cfg.resume = True - cfg.load_from = args.resume - - cfg.compile = dict(backend='inductor') - torch._dynamo.config.optimize_ddp=False - # torch._dynamo.config.capture_scalar_outputs = True - # torch._dynamo.config.capture_dynamic_output_shape_ops = True - - # build the runner from config - if 'runner_type' not in cfg: - # build the default runner - runner = Runner.from_cfg(cfg) - else: - # build customized runner from the registry - # if 'runner_type' is set in the cfg - runner = RUNNERS.build(cfg) - - # start training - torch.backends.cudnn.benchmark = True # 启用自动寻找最优卷积算法 - torch.backends.cudnn.deterministic = False # 允许非确定性算法提升速度 - - runner.train() - - -if __name__ == '__main__': - main() diff --git a/docker-hub/PointPillars/readme.md b/docker-hub/PointPillars/readme.md deleted file mode 100644 index caa461018fe57a012ed1a9d1825a8df8b6e8a588..0000000000000000000000000000000000000000 --- a/docker-hub/PointPillars/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# pointpillars - -## 环境构建 - -``` - docker run -dit --network=host --name=pointpillars --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal:/opt/hyhal:ro -v /public/opendas/DL_DATA/zijia:/data:ro harbor.sourcefind.cn:5443/dcu/admin/base/custom:pytorch2.5.1-driver-pointpillars -``` - -数据集已完成处理在乌镇集群/public/opendas/DL_DATA/zijia路径内 - -## 代码执行 - -``` -## 代码已经在容器/workspace下了 -cd /workspace/pointpillars -bash start_pointpillars.sh -``` - - - diff --git a/docker-hub/Sparse4D/Sparse4D/.gitignore b/docker-hub/Sparse4D/Sparse4D/.gitignore deleted file mode 100644 index f72a7a55d6290869de133dbe6b98daaeb98186ed..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.pyc -*.npy -*.pth \ No newline at end of file diff --git a/docker-hub/Sparse4D/Sparse4D/README.md b/docker-hub/Sparse4D/Sparse4D/README.md deleted file mode 100644 index f23a788472248247e934a6d5f11e0ce7fa1482dd..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/README.md +++ /dev/null @@ -1,92 +0,0 @@ -
- -# Sparse4D: Sparse-based End-to-end Multi-view Temporal Perception -
- -> [Github](https://github.com/HorizonRobotics/Sparse4D) \ -> [Sparse4D v1: Multi-view 3D Object Detection with Sparse Spatial-Temporal Fusion](https://arxiv.org/abs/2211.10581) \ -> [Sparse4D v2: Recurrent Temporal Fusion with Sparse Model](https://arxiv.org/abs/2305.14018) \ -> [Sparse4D v3: Advancing End-to-End 3D Detection and Tracking](https://arxiv.org/abs/2311.11722) \ -> [SparseDrive: End-to-End Autonomous Driving via Sparse Scene Representation](https://arxiv.org/abs/2405.19620) \ -> [Chinese Interpretation of the Papers](https://zhuanlan.zhihu.com/p/637096473) - -**【2024/06】Our follow-up project, SparseDrive (an end-to-end planning model based on the sparse framework), has been released!!! [arxiv](https://arxiv.org/abs/2405.19620) & [github](https://github.com/swc-17/SparseDrive).** - -## Overall Architecture -
- -
-
Overall Framework of Sparse4D, which conforms to an encoder-decoder structure. The inputs mainly consists of three components: multi-view images, newly initialized instances, propagated instances from previous frame. The output is the refined instances (3D anchor boxes and corresponding features), serve as the perception results for the current frame. Additionally, a subset of these refined instances is selected and propagated to the next frame.
-
- - -
- -
-
Illustration of our Efficient Deformable Aggregation Module. (a) The basic pipeline: we first generate multiple 3D key points inside 3D anchor, then sampling multi-scale/view image feature for each keypoint, and fuse these feature with predicted weight. (b) The parallel implementation: to further improve speed and reduce memory cost, we achieve a parallel implementation, where feature sampling and multi-view/scale weighted sum are combined as a CUDA operation. Our CUDA implementation supports handling different feature resolutions from different views.
-
- - -## nuScenes Benchmark -### Results on Validation Split -These experiments were conducted using 8 RTX 3090 GPUs with 24 GB memory. -|model | backbone |pretrain| img size | Epoch | Traning | FPS | NDS | mAP | AMOTA |AMOTP |IDS| config | ckpt | log | -| :----: | :---: | :---: | :---: | :---: | :---:| :---:|:---:|:---: | :---: | :----: | :----: | :---: | :----: | :----: | -|Sparse4D-T4 |Res101|[FCOS3D](https://github.com/linxuewu/Sparse4D/releases/download/v0.0/fcos3d.pth)|640x1600|24|2Day5H|2.9|0.5438|0.4409|-|-|-|[cfg](https://github.com/linxuewu/Sparse4D/blob/v2.0/projects/configs/sparse4d_r101_H4.py)|[ckpt](https://github.com/linxuewu/Sparse4D/releases/download/v0.0/sparse4dv1_r101_H4_release.pth)|[log](https://github.com/linxuewu/Sparse4D/releases/download/v0.0/sparse4d.log)| -|Sparse4Dv2|Res50|[ImageNet]()|256x704| 100 |15H | 20.3 |0.5384|0.4392|-|-|-|[cfg](https://github.com/linxuewu/Sparse4D/blob/v2.0/projects/configs/sparse4dv2_r50_HInf_256x704.py)|[ckpt](https://github.com/linxuewu/Sparse4D/releases/download/v0.0/sparse4dv2_r50_HInf_256x704.pth)|[log](https://github.com/linxuewu/Sparse4D/releases/download/v0.0/sparse4dv2_r50_HInf_256x704.log.json)| -|Sparse4Dv2|Res101|[nuImage](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r101_fpn_1x_nuim/cascade_mask_rcnn_r101_fpn_1x_nuim_20201024_134804-45215b1e.pth)|512x1408| 100 |2Day | 8.4 |0.5939|0.5051|-|-|-|-|-|-| -|Sparse4Dv3|Res50|[ImageNet]()|256x704| 100 |22H | 19.8 |0.5637|0.4646|0.477|1.167|456|[cfg](https://github.com/HorizonRobotics/Sparse4D/blob/main/projects/configs/sparse4dv3_temporal_r50_1x8_bs6_256x704.py)|[ckpt](https://github.com/HorizonRobotics/Sparse4D/releases/download/v3.0/sparse4dv3_r50.pth)|[log](https://github.com/HorizonRobotics/Sparse4D/releases/download/v3.0/sparse4dv3_r50.log) -|Sparse4Dv3|Res101|[nuImage](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r101_fpn_1x_nuim/cascade_mask_rcnn_r101_fpn_1x_nuim_20201024_134804-45215b1e.pth)|512x1408| 100 |2Day | 8.2 |0.623|0.537|0.567|1.027|557|-|-|-| - -### Results on Test Split -|model| backbone | img size | NDS | mAP |mATE| mASE | mAOE |mAVE| mAAE | AMOTA |AMOTP |IDS| -| :---: | :---: | :---: | :---: | :---:|:---:|:---: | :---: | :----: | :----: | :----: | :----: | :----: | -|Sparse4D-T4|[VoV-99](https://huggingface.co/Yuxin-CV/EVA-02/blob/main/eva02/det/eva02_L_coco_det_sys_o365.pth)|640x1600|0.595|0.511|0.533|0.263|0.369|0.317|0.124|-|-|-| -|Sparse4Dv2|[VoV-99](https://huggingface.co/Yuxin-CV/EVA-02/blob/main/eva02/det/eva02_L_coco_det_sys_o365.pth)|640x1600|0.638|0.556|0.462|0.238|0.328|0.264|0.115|-|-|-| -|Sparse4Dv3|[VoV-99](https://huggingface.co/Yuxin-CV/EVA-02/blob/main/eva02/det/eva02_L_coco_det_sys_o365.pth)|640x1600|0.656|0.570|0.412|0.236|0.312|0.210|0.117|0.574|0.970|669| -|Sparse4Dv3-offline|[EVA02-large](https://huggingface.co/Yuxin-CV/EVA-02/blob/main/eva02/det/eva02_L_coco_det_sys_o365.pth)|640x1600|0.719|0.668|0.346|0.234|0.279|0.142|0.145|0.677|0.761|514| - -PS: In the nuscenes leaderboard, Sparse4Dv3 selected external data=True because the eva02-large pretraining utilized imagenet, object365, and coco, as well as supervised by CLIP. Therefore, we consider using the model pre-trained with eva02 as incorporating external data. **However, we did not use external 3D detection data for training.** This clarification is provided to facilitate fair comparisons. - - -## Quick Start -[Quick Start](docs/quick_start.md) - -## Citation -``` -@misc{2311.11722, - Author = {Xuewu Lin and Zixiang Pei and Tianwei Lin and Lichao Huang and Zhizhong Su}, - Title = {Sparse4D v3: Advancing End-to-End 3D Detection and Tracking}, - Year = {2023}, - Eprint = {arXiv:2311.11722}, -} -@misc{2305.14018, - Author = {Xuewu Lin and Tianwei Lin and Zixiang Pei and Lichao Huang and Zhizhong Su}, - Title = {Sparse4D v2: Recurrent Temporal Fusion with Sparse Model}, - Year = {2023}, - Eprint = {arXiv:2305.14018}, -} -@misc{2211.10581, - Author = {Xuewu Lin and Tianwei Lin and Zixiang Pei and Lichao Huang and Zhizhong Su}, - Title = {Sparse4D: Multi-view 3D Object Detection with Sparse Spatial-Temporal Fusion}, - Year = {2022}, - Eprint = {arXiv:2211.10581}, -} -``` - -## Acknowledgement -- [BEVFormer](https://github.com/fundamentalvision/BEVFormer) -- [DETR3D](https://github.com/WangYueFt/detr3d) -- [mmdet3d](https://github.com/open-mmlab/mmdetection3d) -- [SOLOFusion](https://github.com/Divadi/SOLOFusion/tree/main/configs/solofusion) -- [StreamPETR](https://github.com/exiawsh/StreamPETR) diff --git a/docker-hub/Sparse4D/Sparse4D/data/nuscenes b/docker-hub/Sparse4D/Sparse4D/data/nuscenes deleted file mode 120000 index 9c09f1a2ed6d85d1bcd1b7dbdd59cf4426de90be..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/data/nuscenes +++ /dev/null @@ -1 +0,0 @@ -/data/nuScenes \ No newline at end of file diff --git a/docker-hub/Sparse4D/Sparse4D/miopen_Sparse4D.log b/docker-hub/Sparse4D/Sparse4D/miopen_Sparse4D.log deleted file mode 100644 index 4d895853348c2c8cd4b719c4f483390154e608c4..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/miopen_Sparse4D.log +++ /dev/null @@ -1,208 +0,0 @@ - 1624 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 1024 -H 16 -W 44 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 3304 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 1024 -H 16 -W 44 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 1624 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 128 -H 32 -W 88 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 3304 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 128 -H 32 -W 88 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 232 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 128 -H 64 -W 176 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 472 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 128 -H 64 -W 176 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 928 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 2048 -H 8 -W 22 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 1888 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 2048 -H 8 -W 22 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 2552 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 16 -W 44 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 5192 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 16 -W 44 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 232 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 32 -W 88 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 472 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 32 -W 88 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 928 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 64 -W 176 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 1888 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 256 -H 64 -W 176 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 232 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 16 -W 44 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 472 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 16 -W 44 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 1160 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 32 -W 88 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 2360 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 32 -W 88 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 1160 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 8 -W 22 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 2360 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 512 -H 8 -W 22 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 232 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 64 -H 128 -W 352 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 240 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 64 -H 128 -W 352 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 1392 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 64 -H 64 -W 176 -m 1 --forw 0 -b 1 -s 1 --spatial_dim 2 -L NHWC - 2832 MIOpen(HIP): Command [LogCmdBNorm] ./bin/MIOpenDriver bnormfp16 -n 90 -c 64 -H 64 -W 176 -m 1 --forw 1 -b 0 -r 1 -s 1 --spatial_dim 2 -L NHWC - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 2600 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1416 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1888 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 928 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 928 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 944 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 2832 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 2600 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 1392 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 944 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 240 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 3 -H 256 -W 704 -k 64 -y 7 -x 7 -p 3 -q 3 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 3 -H 256 -W 704 -k 64 -y 7 -x 7 -p 3 -q 3 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1416 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 712 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1416 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 944 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 464 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1888 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 928 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 928 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 472 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 232 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 1416 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 696 MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 1024 -H 16 -W 44 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 128 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 32 -W 88 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 128 -H 64 -W 176 -k 128 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 2048 -H 8 -W 22 -k 512 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 16 -W 44 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 32 -W 88 -k 256 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 1 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 512 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 256 -H 8 -W 22 -k 256 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 3 -H 256 -W 704 -k 64 -y 7 -x 7 -p 3 -q 3 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 3 -H 256 -W 704 -k 64 -y 7 -x 7 -p 3 -q 3 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 16 -W 44 -k 512 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 1024 -y 1 -x 1 -p 0 -q 0 -u 2 -v 2 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 128 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 32 -W 88 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 2048 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 512 -H 8 -W 22 -k 512 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 256 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 1 -x 1 -p 0 -q 0 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 - 16 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 1 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 2 -t 1 - 8 MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver convfp16 -n 90 -c 64 -H 64 -W 176 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 --in_layout NHWC --fil_layout NHWC --out_layout NHWC -m conv -g 1 -F 4 -t 1 diff --git a/docker-hub/Sparse4D/Sparse4D/projects/configs/sparse4dv3_temporal_r50_1x8_bs6_256x704.py b/docker-hub/Sparse4D/Sparse4D/projects/configs/sparse4dv3_temporal_r50_1x8_bs6_256x704.py deleted file mode 100644 index 6f41c30f72d0f03623ddea91fd197d30b7566288..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/configs/sparse4dv3_temporal_r50_1x8_bs6_256x704.py +++ /dev/null @@ -1,458 +0,0 @@ -""" -mAP: 0.4647 -mATE: 0.5403 -mASE: 0.2623 -mAOE: 0.4590 -mAVE: 0.2198 -mAAE: 0.2059 -NDS: 0.5636 -Eval time: 176.9s - -Per-class results: -Object Class AP ATE ASE AOE AVE AAE -car 0.668 0.357 0.142 0.054 0.184 0.195 -truck 0.394 0.528 0.187 0.052 0.163 0.210 -bus 0.451 0.681 0.196 0.070 0.383 0.243 -trailer 0.185 0.971 0.247 0.634 0.175 0.202 -construction_vehicle 0.122 0.879 0.496 1.200 0.136 0.406 -pedestrian 0.559 0.517 0.287 0.513 0.282 0.151 -motorcycle 0.497 0.462 0.238 0.536 0.293 0.236 -bicycle 0.426 0.441 0.257 0.951 0.142 0.004 -traffic_cone 0.697 0.275 0.299 nan nan nan -barrier 0.648 0.292 0.275 0.122 nan nan -""" - -""" -Per-class results: - AMOTA AMOTP RECALL MOTAR GT MOTA MOTP MT ML FAF TP FP FN IDS FRAG TID LGD -bicycle 0.444 1.169 0.533 0.733 1993 0.389 0.566 53 57 19.3 1059 283 931 3 8 1.60 1.75 -bus 0.559 1.175 0.626 0.824 2112 0.515 0.751 42 35 14.8 1321 233 790 1 20 1.13 1.95 -car 0.678 0.755 0.733 0.819 58317 0.599 0.470 2053 1073 134.2 42626 7706 15565 126 295 0.76 1.03 -motorcy 0.522 1.060 0.609 0.823 1977 0.497 0.564 50 38 15.7 1194 211 773 10 17 1.97 2.17 -pedestr 0.548 1.059 0.652 0.791 25423 0.506 0.678 677 467 77.6 16274 3404 8854 295 225 1.33 1.85 -trailer 0.136 1.603 0.383 0.403 2425 0.154 0.981 30 79 52.6 926 553 1496 3 13 1.49 2.64 -truck 0.454 1.132 0.577 0.691 9650 0.399 0.594 210 214 45.7 5569 1723 4078 3 50 1.35 1.85 - -Aggregated results: -AMOTA 0.477 -AMOTP 1.136 -RECALL 0.588 -MOTAR 0.726 -GT 14556 -MOTA 0.437 -MOTP 0.658 -MT 3115 -ML 1963 -FAF 51.4 -TP 68969 -FP 14113 -FN 32487 -IDS 441 -FRAG 628 -TID 1.37 -LGD 1.89 -""" - -# ================ base config =================== -plugin = True -plugin_dir = "projects/mmdet3d_plugin/" -dist_params = dict(backend="nccl") -log_level = "INFO" -work_dir = None - -total_batch_size = 120 -num_gpus = 8 -batch_size = total_batch_size // num_gpus -num_iters_per_epoch = int(28130 // (num_gpus * batch_size)) -num_epochs = 100 -checkpoint_epoch_interval = 20 - -checkpoint_config = dict( - interval=num_iters_per_epoch * checkpoint_epoch_interval -) -log_config = dict( - interval=1, - hooks=[ - dict(type="TextLoggerHook", by_epoch=False), - dict(type="TensorboardLoggerHook"), - ], -) -load_from = None -resume_from = None -workflow = [("train", 1)] -fp16 = dict(loss_scale=32.0) -input_shape = (704, 256) - -tracking_test = True -tracking_threshold = 0.2 - -# ================== model ======================== -class_names = [ - "car", - "truck", - "construction_vehicle", - "bus", - "trailer", - "barrier", - "motorcycle", - "bicycle", - "pedestrian", - "traffic_cone", -] - -num_classes = len(class_names) -embed_dims = 256 -num_groups = 8 -num_decoder = 6 -num_single_frame_decoder = 1 -use_deformable_func = True # mmdet3d_plugin/ops/setup.py needs to be executed -strides = [4, 8, 16, 32] -num_levels = len(strides) -num_depth_layers = 3 -drop_out = 0.1 -temporal = True -decouple_attn = True -with_quality_estimation = True - -model = dict( - type="Sparse4D", - use_grid_mask=True, - use_deformable_func=use_deformable_func, - img_backbone=dict( - type="ResNet", - depth=50, - num_stages=4, - frozen_stages=-1, - norm_eval=False, - style="pytorch", - with_cp=True, - out_indices=(0, 1, 2, 3), - norm_cfg=dict(type="BN", requires_grad=True), - pretrained="ckpt/resnet50-19c8e357.pth", - ), - img_neck=dict( - type="FPN", - num_outs=num_levels, - start_level=0, - out_channels=embed_dims, - add_extra_convs="on_output", - relu_before_extra_convs=True, - in_channels=[256, 512, 1024, 2048], - ), - depth_branch=dict( # for auxiliary supervision only - type="DenseDepthNet", - embed_dims=embed_dims, - num_depth_layers=num_depth_layers, - loss_weight=0.2, - ), - head=dict( - type="Sparse4DHead", - cls_threshold_to_reg=0.05, - decouple_attn=decouple_attn, - instance_bank=dict( - type="InstanceBank", - num_anchor=900, - embed_dims=embed_dims, - anchor="nuscenes_kmeans900.npy", - anchor_handler=dict(type="SparseBox3DKeyPointsGenerator"), - num_temp_instances=600 if temporal else -1, - confidence_decay=0.6, - feat_grad=False, - ), - anchor_encoder=dict( - type="SparseBox3DEncoder", - vel_dims=3, - embed_dims=[128, 32, 32, 64] if decouple_attn else 256, - mode="cat" if decouple_attn else "add", - output_fc=not decouple_attn, - in_loops=1, - out_loops=4 if decouple_attn else 2, - ), - num_single_frame_decoder=num_single_frame_decoder, - operation_order=( - [ - "gnn", - "norm", - "deformable", - "ffn", - "norm", - "refine", - ] - * num_single_frame_decoder - + [ - "temp_gnn", - "gnn", - "norm", - "deformable", - "ffn", - "norm", - "refine", - ] - * (num_decoder - num_single_frame_decoder) - )[2:], - temp_graph_model=dict( - type="MultiheadAttention", - embed_dims=embed_dims if not decouple_attn else embed_dims * 2, - num_heads=num_groups, - batch_first=True, - dropout=drop_out, - ) - if temporal - else None, - graph_model=dict( - type="MultiheadAttention", - embed_dims=embed_dims if not decouple_attn else embed_dims * 2, - num_heads=num_groups, - batch_first=True, - dropout=drop_out, - ), - norm_layer=dict(type="LN", normalized_shape=embed_dims), - ffn=dict( - type="AsymmetricFFN", - in_channels=embed_dims * 2, - pre_norm=dict(type="LN"), - embed_dims=embed_dims, - feedforward_channels=embed_dims * 4, - num_fcs=2, - ffn_drop=drop_out, - act_cfg=dict(type="ReLU", inplace=True), - ), - deformable_model=dict( - type="DeformableFeatureAggregation", - embed_dims=embed_dims, - num_groups=num_groups, - num_levels=num_levels, - num_cams=6, - attn_drop=0.15, - use_deformable_func=use_deformable_func, - use_camera_embed=True, - residual_mode="cat", - kps_generator=dict( - type="SparseBox3DKeyPointsGenerator", - num_learnable_pts=6, - fix_scale=[ - [0, 0, 0], - [0.45, 0, 0], - [-0.45, 0, 0], - [0, 0.45, 0], - [0, -0.45, 0], - [0, 0, 0.45], - [0, 0, -0.45], - ], - ), - ), - refine_layer=dict( - type="SparseBox3DRefinementModule", - embed_dims=embed_dims, - num_cls=num_classes, - refine_yaw=True, - with_quality_estimation=with_quality_estimation, - ), - sampler=dict( - type="SparseBox3DTarget", - num_dn_groups=5, - num_temp_dn_groups=3, - dn_noise_scale=[2.0] * 3 + [0.5] * 7, - max_dn_gt=32, - add_neg_dn=True, - cls_weight=2.0, - box_weight=0.25, - reg_weights=[2.0] * 3 + [0.5] * 3 + [0.0] * 4, - cls_wise_reg_weights={ - class_names.index("traffic_cone"): [ - 2.0, - 2.0, - 2.0, - 1.0, - 1.0, - 1.0, - 0.0, - 0.0, - 1.0, - 1.0, - ], - }, - ), - loss_cls=dict( - type="FocalLoss", - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=2.0, - ), - loss_reg=dict( - type="SparseBox3DLoss", - loss_box=dict(type="L1Loss", loss_weight=0.25), - loss_centerness=dict(type="CrossEntropyLoss", use_sigmoid=True), - loss_yawness=dict(type="GaussianFocalLoss"), - cls_allow_reverse=[class_names.index("barrier")], - ), - decoder=dict(type="SparseBox3DDecoder"), - reg_weights=[2.0] * 3 + [1.0] * 7, - ), -) - -# ================== data ======================== -dataset_type = "NuScenes3DDetTrackDataset" -data_root = "data/nuscenes/" -anno_root = "data/nuscenes_cam/" -anno_root = "data/nuscenes_anno_pkls/" -file_client_args = dict(backend="disk") - -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True -) -train_pipeline = [ - dict(type="LoadMultiViewImageFromFiles", to_float32=True), - dict( - type="LoadPointsFromFile", - coord_type="LIDAR", - load_dim=5, - use_dim=5, - file_client_args=file_client_args, - ), - dict(type="ResizeCropFlipImage"), - dict( - type="MultiScaleDepthMapGenerator", - downsample=strides[:num_depth_layers], - ), - dict(type="BBoxRotation"), - dict(type="PhotoMetricDistortionMultiViewImage"), - dict(type="NormalizeMultiviewImage", **img_norm_cfg), - dict( - type="CircleObjectRangeFilter", - class_dist_thred=[55] * len(class_names), - ), - dict(type="InstanceNameFilter", classes=class_names), - dict(type="NuScenesSparse4DAdaptor"), - dict( - type="Collect", - keys=[ - "img", - "timestamp", - "projection_mat", - "image_wh", - "gt_depth", - "focal", - "gt_bboxes_3d", - "gt_labels_3d", - ], - meta_keys=["T_global", "T_global_inv", "timestamp", "instance_id"], - ), -] -test_pipeline = [ - dict(type="LoadMultiViewImageFromFiles", to_float32=True), - dict(type="ResizeCropFlipImage"), - dict(type="NormalizeMultiviewImage", **img_norm_cfg), - dict(type="NuScenesSparse4DAdaptor"), - dict( - type="Collect", - keys=[ - "img", - "timestamp", - "projection_mat", - "image_wh", - ], - meta_keys=["T_global", "T_global_inv", "timestamp"], - ), -] - -input_modality = dict( - use_lidar=False, - use_camera=True, - use_radar=False, - use_map=False, - use_external=False, -) - -data_basic_config = dict( - type=dataset_type, - data_root=data_root, - classes=class_names, - modality=input_modality, - version="v1.0-trainval", -) - -data_aug_conf = { - "resize_lim": (0.40, 0.47), - "final_dim": input_shape[::-1], - "bot_pct_lim": (0.0, 0.0), - "rot_lim": (-5.4, 5.4), - "H": 900, - "W": 1600, - "rand_flip": True, - "rot3d_range": [-0.3925, 0.3925], -} - -data = dict( - samples_per_gpu=batch_size, - workers_per_gpu=batch_size, - train=dict( - **data_basic_config, - ann_file=anno_root + "nuscenes_infos_train.pkl", - pipeline=train_pipeline, - test_mode=False, - data_aug_conf=data_aug_conf, - with_seq_flag=True, - sequences_split_num=2, - keep_consistent_seq_aug=True, - ), - val=dict( - **data_basic_config, - ann_file=anno_root + "nuscenes_infos_val.pkl", - pipeline=test_pipeline, - data_aug_conf=data_aug_conf, - test_mode=True, - tracking=tracking_test, - tracking_threshold=tracking_threshold, - ), - test=dict( - **data_basic_config, - ann_file=anno_root + "nuscenes_infos_val.pkl", - pipeline=test_pipeline, - data_aug_conf=data_aug_conf, - test_mode=True, - tracking=tracking_test, - tracking_threshold=tracking_threshold, - ), -) - -# ================== training ======================== -optimizer = dict( - type="AdamW", - #type="Miopen_AdamW", - lr=6e-4, - weight_decay=0.001, - paramwise_cfg=dict( - custom_keys={ - "img_backbone": dict(lr_mult=0.5), - } - ), -) -optimizer_config = dict(grad_clip=dict(max_norm=25, norm_type=2)) -lr_config = dict( - policy="CosineAnnealing", - warmup="linear", - warmup_iters=500, - warmup_ratio=1.0 / 3, - min_lr_ratio=1e-3, -) -runner = dict( - type="IterBasedRunner", - max_iters=num_iters_per_epoch * num_epochs, -) - -# ================== eval ======================== -vis_pipeline = [ - dict(type="LoadMultiViewImageFromFiles", to_float32=True), - dict( - type="Collect", - keys=["img"], - meta_keys=["timestamp", "lidar2img"], - ), -] -evaluation = dict( - interval=num_iters_per_epoch * checkpoint_epoch_interval, - pipeline=vis_pipeline, - # out_dir="./vis", # for visualization -) diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/__init__.py b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/__init__.py deleted file mode 100644 index af30edd14c9cc1aad9090e73ffcfa8bbc34b40c7..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .datasets import * -from .models import * -from .apis import * -from .core.evaluation import * -#from .models.opt.miopen_adam import Miopen_AdamW diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/apis/mmdet_train.py b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/apis/mmdet_train.py deleted file mode 100644 index 257ac5726b7b93fdd2d755f4e4844b7ee23eeceb..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/apis/mmdet_train.py +++ /dev/null @@ -1,300 +0,0 @@ -# --------------------------------------------- -# Copyright (c) OpenMMLab. All rights reserved. -# --------------------------------------------- -# Modified by Zhiqi Li -# --------------------------------------------- -import random -import warnings - -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import ( - HOOKS, - DistSamplerSeedHook, - EpochBasedRunner, - Fp16OptimizerHook, - OptimizerHook, - build_optimizer, - build_runner, - get_dist_info, -) -from mmcv.utils import build_from_cfg - -from mmdet.core import EvalHook - -from mmdet.datasets import build_dataset, replace_ImageToTensor -from mmdet.utils import get_root_logger -import time -import os.path as osp -from projects.mmdet3d_plugin.datasets.builder import build_dataloader -from projects.mmdet3d_plugin.core.evaluation.eval_hooks import ( - CustomDistEvalHook, -) -from projects.mmdet3d_plugin.datasets import custom_build_dataset - -from mmcv.runner import Hook - -class ProfilerHook(Hook): - def __init__(self, profiler, total_steps): - self.profiler = profiler - self.total_steps = total_steps # 总步数 (wait + warmup + active) * repeat - self.stopped = False - - def after_train_iter(self, runner): - - if self.profiler.step_num == self.total_steps and not self.stopped: - # 停止Profiler - self.profiler.stop() - self.stopped = True - - # 只在rank 0上打印结果 - rank, _ = get_dist_info() - if rank == 0: - # 获取并打印关键指标 - # table = self.profiler.key_averages().table( - # sort_by="self_cuda_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - # table = self.profiler.key_averages().table( - # sort_by="self_cpu_time_total", - # row_limit=10 - # ) - # runner.logger.info(f"Profiler results after {self.total_steps} steps:\n{table}") - - results = self.profiler.key_averages().table(sort_by="cuda_time_total") - log_file = "./BW_log_step{}.txt".format(self.total_steps) - with open(log_file, mode='w') as file: - file.write(str(results)) - # self.profiler.start() - if not self.stopped: - self.profiler.step() - # 检测是否完成所有schedule步骤 - -def custom_train_detector( - model, - dataset, - cfg, - distributed=False, - validate=False, - timestamp=None, - meta=None, -): - logger = get_root_logger(cfg.log_level) - - # prepare data loaders - - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - # assert len(dataset)==1s - if "imgs_per_gpu" in cfg.data: - logger.warning( - '"imgs_per_gpu" is deprecated in MMDet V2.0. ' - 'Please use "samples_per_gpu" instead' - ) - if "samples_per_gpu" in cfg.data: - logger.warning( - f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' - f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' - f"={cfg.data.imgs_per_gpu} is used in this experiments" - ) - else: - logger.warning( - 'Automatically set "samples_per_gpu"="imgs_per_gpu"=' - f"{cfg.data.imgs_per_gpu} in this experiments" - ) - cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu - - if "runner" in cfg: - runner_type = cfg.runner["type"] - else: - runner_type = "EpochBasedRunner" - data_loaders = [ - build_dataloader( - ds, - cfg.data.samples_per_gpu, - cfg.data.workers_per_gpu, - # cfg.gpus will be ignored if distributed - len(cfg.gpu_ids), - dist=distributed, - seed=cfg.seed, - nonshuffler_sampler=dict( - type="DistributedSampler" - ), # dict(type='DistributedSampler'), - runner_type=runner_type, - ) - for ds in dataset - ] - - # put model on gpus - if distributed: - find_unused_parameters = cfg.get("find_unused_parameters", False) - # Sets the `find_unused_parameters` parameter in - # torch.nn.parallel.DistributedDataParallel - model = MMDistributedDataParallel( - model.cuda(), - device_ids=[torch.cuda.current_device()], - broadcast_buffers=False, - find_unused_parameters=find_unused_parameters, - ) - - else: - model = MMDataParallel( - model.cuda(cfg.gpu_ids[0]), device_ids=cfg.gpu_ids - ) - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - - if "runner" not in cfg: - cfg.runner = { - "type": "EpochBasedRunner", - "max_epochs": cfg.total_epochs, - } - warnings.warn( - "config is now expected to have a `runner` section, " - "please set `runner` in your config.", - UserWarning, - ) - else: - if "total_epochs" in cfg: - assert cfg.total_epochs == cfg.runner.max_epochs - - runner = build_runner( - cfg.runner, - default_args=dict( - model=model, - optimizer=optimizer, - work_dir=cfg.work_dir, - logger=logger, - meta=meta, - ), - ) - - # an ugly workaround to make .log and .log.json filenames the same - runner.timestamp = timestamp - - # fp16 setting - fp16_cfg = cfg.get("fp16", None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=distributed - ) - elif distributed and "type" not in cfg.optimizer_config: - optimizer_config = OptimizerHook(**cfg.optimizer_config) - else: - optimizer_config = cfg.optimizer_config - - # register hooks - runner.register_training_hooks( - cfg.lr_config, - optimizer_config, - cfg.checkpoint_config, - cfg.log_config, - cfg.get("momentum_config", None), - ) - - # register profiler hook - # trace_config = dict(type='tb_trace', dir_name='work_dir') - # profiler_config = dict(on_trace_ready=trace_config) - # runner.register_profiler_hook(profiler_config) - - if distributed: - if isinstance(runner, EpochBasedRunner): - runner.register_hook(DistSamplerSeedHook()) - - # register eval hooks - if validate: - # Support batch_size > 1 in validation - val_samples_per_gpu = cfg.data.val.pop("samples_per_gpu", 1) - if val_samples_per_gpu > 1: - assert False - # Replace 'ImageToTensor' to 'DefaultFormatBundle' - cfg.data.val.pipeline = replace_ImageToTensor( - cfg.data.val.pipeline - ) - val_dataset = custom_build_dataset(cfg.data.val, dict(test_mode=True)) - - val_dataloader = build_dataloader( - val_dataset, - samples_per_gpu=val_samples_per_gpu, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False, - nonshuffler_sampler=dict(type="DistributedSampler"), - ) - eval_cfg = cfg.get("evaluation", {}) - eval_cfg["by_epoch"] = cfg.runner["type"] != "IterBasedRunner" - eval_cfg["jsonfile_prefix"] = osp.join( - "val", - cfg.work_dir, - time.ctime().replace(" ", "_").replace(":", "_"), - ) - eval_hook = CustomDistEvalHook if distributed else EvalHook - runner.register_hook(eval_hook(val_dataloader, **eval_cfg)) - - # user-defined hooks - if cfg.get("custom_hooks", None): - custom_hooks = cfg.custom_hooks - assert isinstance( - custom_hooks, list - ), f"custom_hooks expect list type, but got {type(custom_hooks)}" - for hook_cfg in cfg.custom_hooks: - assert isinstance(hook_cfg, dict), ( - "Each item in custom_hooks expects dict type, but got " - f"{type(hook_cfg)}" - ) - hook_cfg = hook_cfg.copy() - priority = hook_cfg.pop("priority", "NORMAL") - hook = build_from_cfg(hook_cfg, HOOKS) - runner.register_hook(hook, priority=priority) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - - - if True: - # 创建profiler配置 - total_steps = (1 + 20 + 1) * 1 # 22 steps - profiler = torch.profiler.profile( - activities=[ - torch.profiler.ProfilerActivity.CPU, - torch.profiler.ProfilerActivity.CUDA - ], - schedule=torch.profiler.schedule( - wait=1, # 跳过前1个step - warmup=20, # 预热1个step(不计入结果) - active=1, # 分析3个step - repeat=1 # 只执行一轮 - ), - on_trace_ready=torch.profiler.tensorboard_trace_handler( - # f"{cfg.work_dir}/profiler_logs" # 输出目录 - "/root/BEVFormer/profiler_logs" - # "./profiler_logs" - ), - with_stack=True, # 收集调用栈信息 - profile_memory=False, # 分析内存使用 - record_shapes=False # 记录张量形状 - ) - # 创建并注册ProfilerHook - # profiler_hook = ProfilerHook(profiler) - profiler_hook = ProfilerHook(profiler,total_steps) - runner.register_hook(profiler_hook) - # 启动profiler - profiler.start() - print("==================================== profiler.start()===================================================================") - try: - # 运行训练 - runner.run(data_loaders, cfg.workflow) - finally: - # 确保profiler停止 - profiler.stop() - else: - # 正常训练 - runner.run(data_loaders, cfg.workflow) - - # runner.run(data_loaders, cfg.workflow) - #runner.run(data_loaders, cfg.workflow) diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/core/evaluation/__init__.py b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/core/evaluation/__init__.py deleted file mode 100644 index d92421c7e84fdc7a33e94aa10fddfccb332d6399..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/core/evaluation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .eval_hooks import CustomDistEvalHook \ No newline at end of file diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/detection3d/target.py b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/detection3d/target.py deleted file mode 100644 index e47fce347a27faeab6d4e9ace5b21ee0a853d902..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/detection3d/target.py +++ /dev/null @@ -1,483 +0,0 @@ -import torch -import numpy as np -import torch.nn.functional as F -from scipy.optimize import linear_sum_assignment - -from mmdet.core.bbox.builder import BBOX_SAMPLERS - -from projects.mmdet3d_plugin.core.box3d import * -from ..base_target import BaseTargetWithDenoising -from lightop import op - - -__all__ = ["SparseBox3DTarget"] - - -@BBOX_SAMPLERS.register_module() -class SparseBox3DTarget(BaseTargetWithDenoising): - def __init__( - self, - cls_weight=2.0, - alpha=0.25, - gamma=2, - eps=1e-12, - box_weight=0.25, - reg_weights=None, - cls_wise_reg_weights=None, - num_dn_groups=0, - dn_noise_scale=0.5, - max_dn_gt=32, - add_neg_dn=True, - num_temp_dn_groups=0, - ): - super(SparseBox3DTarget, self).__init__( - num_dn_groups, num_temp_dn_groups - ) - self.cls_weight = cls_weight - self.box_weight = box_weight - self.alpha = alpha - self.gamma = gamma - self.eps = eps - self.reg_weights = reg_weights - if self.reg_weights is None: - self.reg_weights = [1.0] * 8 + [0.0] * 2 - self.cls_wise_reg_weights = cls_wise_reg_weights - self.dn_noise_scale = dn_noise_scale - self.max_dn_gt = max_dn_gt - self.add_neg_dn = add_neg_dn - - - ''' - def encode_reg_target(self, box_target, device=None): - outputs = [] - for box in box_target: - output = torch.cat( - [ - box[..., [X, Y, Z]], - box[..., [W, L, H]].log(), - torch.sin(box[..., YAW]).unsqueeze(-1), - torch.cos(box[..., YAW]).unsqueeze(-1), - box[..., YAW + 1 :], - ], - dim=-1, - ) - if device is not None: - output = output.to(device=device) - outputs.append(output) - return outputs - ''' - def encode_reg_target(self,box_target_list, device=None): - outputs_lightop=[] - if len(box_target_list) == 0: - return [] - - dev = device if device is not None else box_target_list[0].device - box_target_list = [t.to(dev) if t.device != dev else t for t in box_target_list] - - for box in box_target_list: - N, D = box.shape - out = op.encode_reg_t(box, N) - outputs_lightop.append(out.contiguous()) - return outputs_lightop - - - def sample( - self, - cls_pred, - box_pred, - cls_target, - box_target, - ): - bs, num_pred, num_cls = cls_pred.shape - - cls_cost = self._cls_cost(cls_pred, cls_target) - - box_target = self.encode_reg_target(box_target, box_pred.device) - - instance_reg_weights = [] - for i in range(len(box_target)): - weights = torch.logical_not(box_target[i].isnan()).to( - dtype=box_target[i].dtype - ) - if self.cls_wise_reg_weights is not None: - for cls, weight in self.cls_wise_reg_weights.items(): - weights = torch.where( - (cls_target[i] == cls)[:, None], - weights.new_tensor(weight), - weights, - ) - instance_reg_weights.append(weights) - box_cost = self._box_cost(box_pred, box_target, instance_reg_weights) - - indices = [] - for i in range(bs): - if cls_cost[i] is not None and box_cost[i] is not None: - cost = (cls_cost[i] + box_cost[i]).detach().cpu().numpy() - cost = np.where(np.isneginf(cost) | np.isnan(cost), 1e8, cost) - assign = linear_sum_assignment(cost) - indices.append( - [cls_pred.new_tensor(x, dtype=torch.int64) for x in assign] - ) - else: - indices.append([None, None]) - - output_cls_target = ( - cls_target[0].new_ones([bs, num_pred], dtype=torch.long) * num_cls - ) - output_box_target = box_pred.new_zeros(box_pred.shape) - output_reg_weights = box_pred.new_zeros(box_pred.shape) - for i, (pred_idx, target_idx) in enumerate(indices): - if len(cls_target[i]) == 0: - continue - output_cls_target[i, pred_idx] = cls_target[i][target_idx] - output_box_target[i, pred_idx] = box_target[i][target_idx] - output_reg_weights[i, pred_idx] = instance_reg_weights[i][ - target_idx - ] - return output_cls_target, output_box_target, output_reg_weights - - def _cls_cost(self, cls_pred, cls_target): - bs = cls_pred.shape[0] - cls_pred = cls_pred.sigmoid() - cost = [] - for i in range(bs): - if len(cls_target[i]) > 0: - neg_cost = ( - -(1 - cls_pred[i] + self.eps).log() - * (1 - self.alpha) - * cls_pred[i].pow(self.gamma) - ) - pos_cost = ( - -(cls_pred[i] + self.eps).log() - * self.alpha - * (1 - cls_pred[i]).pow(self.gamma) - ) - cost.append( - (pos_cost[:, cls_target[i]] - neg_cost[:, cls_target[i]]) - * self.cls_weight - ) - else: - cost.append(None) - return cost - - ''' - def _box_cost(self, box_pred, box_target, instance_reg_weights): - bs = box_pred.shape[0] - cost = [] - for i in range(bs): - if len(box_target[i]) > 0: - cost.append( - torch.sum( - torch.abs(box_pred[i, :, None] - box_target[i][None]) - * instance_reg_weights[i][None] - * box_pred.new_tensor(self.reg_weights), - dim=-1, - ) - * self.box_weight - ) - else: - cost.append(None) - return cost - ''' - - def _box_cost(self, box_pred, box_target, instance_reg_weights): - bs = box_pred.shape[0] - reg_weights_tensor=torch.tensor(self.reg_weights, device=box_pred.device, dtype=torch.float32) - cost = [] - for i in range(bs): - if len(box_target[i]) > 0: - pred_tensor = box_pred[i] - target_tensor = box_target[i] - inst_weights_tensor = instance_reg_weights[i] - cost.append(op.box_cost( - pred_tensor, - target_tensor, - inst_weights_tensor, - reg_weights_tensor, - self.box_weight - )) - else: - cost.append(None) - return cost - - def get_dn_anchors(self, cls_target, box_target, gt_instance_id=None): - if self.num_dn_groups <= 0: - return None - if self.num_temp_dn_groups <= 0: - gt_instance_id = None - - if self.max_dn_gt > 0: - cls_target = [x[: self.max_dn_gt] for x in cls_target] - box_target = [x[: self.max_dn_gt] for x in box_target] - if gt_instance_id is not None: - gt_instance_id = [x[: self.max_dn_gt] for x in gt_instance_id] - - max_dn_gt = max([len(x) for x in cls_target]) - if max_dn_gt == 0: - return None - cls_target = torch.stack( - [ - F.pad(x, (0, max_dn_gt - x.shape[0]), value=-1) - for x in cls_target - ] - ) - box_target = self.encode_reg_target(box_target, cls_target.device) - box_target = torch.stack( - [F.pad(x, (0, 0, 0, max_dn_gt - x.shape[0])) for x in box_target] - ) - box_target = torch.where( - cls_target[..., None] == -1, box_target.new_tensor(0), box_target - ) - if gt_instance_id is not None: - gt_instance_id = torch.stack( - [ - F.pad(x, (0, max_dn_gt - x.shape[0]), value=-1) - for x in gt_instance_id - ] - ) - - bs, num_gt, state_dims = box_target.shape - if self.num_dn_groups > 1: - cls_target = cls_target.tile(self.num_dn_groups, 1) - box_target = box_target.tile(self.num_dn_groups, 1, 1) - if gt_instance_id is not None: - gt_instance_id = gt_instance_id.tile(self.num_dn_groups, 1) - - noise = torch.rand_like(box_target) * 2 - 1 - noise *= box_target.new_tensor(self.dn_noise_scale) - dn_anchor = box_target + noise - if self.add_neg_dn: - noise_neg = torch.rand_like(box_target) + 1 - flag = torch.where( - torch.rand_like(box_target) > 0.5, - noise_neg.new_tensor(1), - noise_neg.new_tensor(-1), - ) - noise_neg *= flag - noise_neg *= box_target.new_tensor(self.dn_noise_scale) - dn_anchor = torch.cat([dn_anchor, box_target + noise_neg], dim=1) - num_gt *= 2 - - box_cost = self._box_cost( - dn_anchor, box_target, torch.ones_like(box_target) - ) - dn_box_target = torch.zeros_like(dn_anchor) - dn_cls_target = -torch.ones_like(cls_target) * 3 - if gt_instance_id is not None: - dn_id_target = -torch.ones_like(gt_instance_id) - if self.add_neg_dn: - dn_cls_target = torch.cat([dn_cls_target, dn_cls_target], dim=1) - if gt_instance_id is not None: - dn_id_target = torch.cat([dn_id_target, dn_id_target], dim=1) - - for i in range(dn_anchor.shape[0]): - cost = box_cost[i].cpu().numpy() - anchor_idx, gt_idx = linear_sum_assignment(cost) - anchor_idx = dn_anchor.new_tensor(anchor_idx, dtype=torch.int64) - gt_idx = dn_anchor.new_tensor(gt_idx, dtype=torch.int64) - dn_box_target[i, anchor_idx] = box_target[i, gt_idx] - dn_cls_target[i, anchor_idx] = cls_target[i, gt_idx] - if gt_instance_id is not None: - dn_id_target[i, anchor_idx] = gt_instance_id[i, gt_idx] - dn_anchor = ( - dn_anchor.reshape(self.num_dn_groups, bs, num_gt, state_dims) - .permute(1, 0, 2, 3) - .flatten(1, 2) - ) - dn_box_target = ( - dn_box_target.reshape(self.num_dn_groups, bs, num_gt, state_dims) - .permute(1, 0, 2, 3) - .flatten(1, 2) - ) - dn_cls_target = ( - dn_cls_target.reshape(self.num_dn_groups, bs, num_gt) - .permute(1, 0, 2) - .flatten(1) - ) - if gt_instance_id is not None: - dn_id_target = ( - dn_id_target.reshape(self.num_dn_groups, bs, num_gt) - .permute(1, 0, 2) - .flatten(1) - ) - else: - dn_id_target = None - valid_mask = dn_cls_target >= 0 - if self.add_neg_dn: - cls_target = ( - torch.cat([cls_target, cls_target], dim=1) - .reshape(self.num_dn_groups, bs, num_gt) - .permute(1, 0, 2) - .flatten(1) - ) - valid_mask = torch.logical_or( - valid_mask, ((cls_target >= 0) & (dn_cls_target == -3)) - ) # valid denotes the items is not from pad. - attn_mask = dn_box_target.new_ones( - num_gt * self.num_dn_groups, num_gt * self.num_dn_groups - ) - for i in range(self.num_dn_groups): - start = num_gt * i - end = start + num_gt - attn_mask[start:end, start:end] = 0 - attn_mask = attn_mask == 1 - dn_cls_target = dn_cls_target.long() - return ( - dn_anchor, - dn_box_target, - dn_cls_target, - attn_mask, - valid_mask, - dn_id_target, - ) - - def update_dn( - self, - instance_feature, - anchor, - dn_reg_target, - dn_cls_target, - valid_mask, - dn_id_target, - num_noraml_anchor, - temporal_valid_mask, - ): - bs, num_anchor = instance_feature.shape[:2] - if temporal_valid_mask is None: - self.dn_metas = None - if self.dn_metas is None or num_noraml_anchor >= num_anchor: - return ( - instance_feature, - anchor, - dn_reg_target, - dn_cls_target, - valid_mask, - dn_id_target, - ) - - # split instance_feature and anchor into non-dn and dn - num_dn = num_anchor - num_noraml_anchor - dn_instance_feature = instance_feature[:, -num_dn:] - dn_anchor = anchor[:, -num_dn:] - instance_feature = instance_feature[:, :num_noraml_anchor] - anchor = anchor[:, :num_noraml_anchor] - - # reshape all dn metas from (bs,num_all_dn,xxx) - # to (bs, dn_group, num_dn_per_group, xxx) - num_dn_groups = self.num_dn_groups - num_dn = num_dn // num_dn_groups - dn_feat = dn_instance_feature.reshape(bs, num_dn_groups, num_dn, -1) - dn_anchor = dn_anchor.reshape(bs, num_dn_groups, num_dn, -1) - dn_reg_target = dn_reg_target.reshape(bs, num_dn_groups, num_dn, -1) - dn_cls_target = dn_cls_target.reshape(bs, num_dn_groups, num_dn) - valid_mask = valid_mask.reshape(bs, num_dn_groups, num_dn) - if dn_id_target is not None: - dn_id = dn_id_target.reshape(bs, num_dn_groups, num_dn) - - # update temp_dn_metas by instance_id - temp_dn_feat = self.dn_metas["dn_instance_feature"] - _, num_temp_dn_groups, num_temp_dn = temp_dn_feat.shape[:3] - temp_dn_id = self.dn_metas["dn_id_target"] - - # bs, num_temp_dn_groups, num_temp_dn, num_dn - match = temp_dn_id[..., None] == dn_id[:, :num_temp_dn_groups, None] - temp_reg_target = ( - match[..., None] * dn_reg_target[:, :num_temp_dn_groups, None] - ).sum(dim=3) - # temp_cls_target = torch.where( - # torch.all(torch.logical_not(match), dim=-1), - # self.dn_metas["dn_cls_target"].new_tensor(-1), - # self.dn_metas["dn_cls_target"], - # ) - temp_cls_target = torch.where( - torch.all(torch.logical_not(match), dim=-1), - #self.dn_metas["dn_cls_target"].new_tensor(-1), - -torch.ones_like(self.dn_metas["dn_cls_target"]), - self.dn_metas["dn_cls_target"], - ) - temp_valid_mask = self.dn_metas["valid_mask"] - temp_dn_anchor = self.dn_metas["dn_anchor"] - - # handle the misalignment the length of temp_dn to dn caused by the - # change of num_gt, then concat the temp_dn and dn - temp_dn_metas = [ - temp_dn_feat, - temp_dn_anchor, - temp_reg_target, - temp_cls_target, - temp_valid_mask, - temp_dn_id, - ] - dn_metas = [ - dn_feat, - dn_anchor, - dn_reg_target, - dn_cls_target, - valid_mask, - dn_id, - ] - output = [] - for i, (temp_meta, meta) in enumerate(zip(temp_dn_metas, dn_metas)): - if num_temp_dn < num_dn: - pad = (0, num_dn - num_temp_dn) - if temp_meta.dim() == 4: - pad = (0, 0) + pad - else: - assert temp_meta.dim() == 3 - temp_meta = F.pad(temp_meta, pad, value=0) - else: - temp_meta = temp_meta[:, :, :num_dn] - mask = temporal_valid_mask[:, None, None] - if meta.dim() == 4: - mask = mask.unsqueeze(dim=-1) - temp_meta = torch.where( - mask, temp_meta, meta[:, :num_temp_dn_groups] - ) - meta = torch.cat([temp_meta, meta[:, num_temp_dn_groups:]], dim=1) - meta = meta.flatten(1, 2) - output.append(meta) - output[0] = torch.cat([instance_feature, output[0]], dim=1) - output[1] = torch.cat([anchor, output[1]], dim=1) - return output - - @torch.compile(mode="max-autotune-no-cudagraphs") - def cache_dn( - self, - dn_instance_feature, - dn_anchor, - dn_cls_target, - valid_mask, - dn_id_target, - ): - if self.num_temp_dn_groups < 0: - return - num_dn_groups = self.num_dn_groups - bs, num_dn = dn_instance_feature.shape[:2] - num_temp_dn = num_dn // num_dn_groups - temp_group_mask = ( - torch.randperm(num_dn_groups) < self.num_temp_dn_groups - ) - temp_group_mask = temp_group_mask.to(device=dn_anchor.device) - dn_instance_feature = dn_instance_feature.detach().reshape( - bs, num_dn_groups, num_temp_dn, -1 - )[:, temp_group_mask] - dn_anchor = dn_anchor.detach().reshape( - bs, num_dn_groups, num_temp_dn, -1 - )[:, temp_group_mask] - dn_cls_target = dn_cls_target.reshape(bs, num_dn_groups, num_temp_dn)[ - :, temp_group_mask - ] - valid_mask = valid_mask.reshape(bs, num_dn_groups, num_temp_dn)[ - :, temp_group_mask - ] - if dn_id_target is not None: - dn_id_target = dn_id_target.reshape( - bs, num_dn_groups, num_temp_dn - )[:, temp_group_mask] - self.dn_metas = dict( - dn_instance_feature=dn_instance_feature, - dn_anchor=dn_anchor, - dn_cls_target=dn_cls_target, - valid_mask=valid_mask, - dn_id_target=dn_id_target, - ) diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/opt/miopen_adam.py b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/opt/miopen_adam.py deleted file mode 100644 index 78586163d97615940eeed1205d83cfb99d1576f9..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/models/opt/miopen_adam.py +++ /dev/null @@ -1,125 +0,0 @@ -import lightop -import torch -from torch.optim.optimizer import Optimizer -from mmcv.runner.optimizer.builder import OPTIMIZERS - -@OPTIMIZERS.register_module() -class Miopen_AdamW(Optimizer): - r"""Implements AdamW algorithm. Solve the bug of torch 1.8 - - The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. - The AdamW variant was proposed in `Decoupled Weight Decay Regularization`_. - - Args: - params (iterable): iterable of parameters to optimize or dicts defining - parameter groups - lr (float, optional): learning rate (default: 1e-3) - betas (Tuple[float, float], optional): coefficients used for computing - running averages of gradient and its square (default: (0.9, 0.999)) - eps (float, optional): term added to the denominator to improve - numerical stability (default: 1e-8) - weight_decay (float, optional): weight decay coefficient (default: 1e-2) - amsgrad (boolean, optional): whether to use the AMSGrad variant of this - algorithm from the paper `On the Convergence of Adam and Beyond`_ - (default: False) - - .. _Adam\: A Method for Stochastic Optimization: - https://arxiv.org/abs/1412.6980 - .. _Decoupled Weight Decay Regularization: - https://arxiv.org/abs/1711.05101 - .. _On the Convergence of Adam and Beyond: - https://openreview.net/forum?id=ryQu7f-RZ - """ - - def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, - weight_decay=1e-2, amsgrad=False): - if not 0.0 <= lr: - raise ValueError("Invalid learning rate: {}".format(lr)) - if not 0.0 <= eps: - raise ValueError("Invalid epsilon value: {}".format(eps)) - if not 0.0 <= betas[0] < 1.0: - raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) - if not 0.0 <= betas[1] < 1.0: - raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) - if not 0.0 <= weight_decay: - raise ValueError("Invalid weight_decay value: {}".format(weight_decay)) - defaults = dict(lr=lr, betas=betas, eps=eps, - weight_decay=weight_decay, amsgrad=amsgrad) - super(Miopen_AdamW, self).__init__(params, defaults) - - def __setstate__(self, state): - super(Miopen_AdamW, self).__setstate__(state) - for group in self.param_groups: - group.setdefault('amsgrad', False) - - @torch.no_grad() - def step(self, closure=None): - """Performs a single optimization step. - - Args: - closure (callable, optional): A closure that reevaluates the model - and returns the loss. - """ - loss = None - if closure is not None: - with torch.enable_grad(): - loss = closure() - - for group in self.param_groups: - params_with_grad = [] - grads = [] - exp_avgs = [] - exp_avg_sqs = [] - state_sums = [] - max_exp_avg_sqs = [] - state_steps = [] - amsgrad = group['amsgrad'] - - # put this line here for solving bug - beta1, beta2 = group['betas'] - - for p in group['params']: - if p.grad is None: - continue - params_with_grad.append(p.contiguous()) - if p.grad.is_sparse: - raise RuntimeError('AdamW does not support sparse gradients') - grads.append(p.grad.contiguous()) - - state = self.state[p] - - # State initialization - if len(state) == 0: - state['step'] = 0 - # Exponential moving average of gradient values - state['exp_avg'] = torch.zeros_like(p, memory_format=torch.preserve_format) - # Exponential moving average of squared gradient values - state['exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - if amsgrad: - # Maintains max of all exp. moving avg. of sq. grad. values - state['max_exp_avg_sq'] = torch.zeros_like(p, memory_format=torch.preserve_format) - - exp_avgs.append(state['exp_avg'].contiguous()) - exp_avg_sqs.append(state['exp_avg_sq'].contiguous()) - - if amsgrad: - max_exp_avg_sqs.append(state['max_exp_avg_sq'].contiguous()) - - # record the step after step update - state_steps.append(torch.tensor(state['step'])) - - lightop.miopen_adamw( - params=params_with_grad, - grads=grads, - exp_avgs=exp_avgs, - exp_avg_sqs=exp_avg_sqs, - max_exp_avg_sqs=max_exp_avg_sqs, - state_steps=state_steps, - amsgrad=amsgrad, - beta1=beta1, - beta2=beta2, - lr=group['lr'], - weight_decay=group['weight_decay'], - eps=group['eps']) - - return loss diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/lib.linux-x86_64-cpython-310/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/lib.linux-x86_64-cpython-310/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so deleted file mode 100755 index 814a41f2932f129bde1772a0850a25ea76edd5d3..0000000000000000000000000000000000000000 Binary files a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/lib.linux-x86_64-cpython-310/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so and /dev/null differ diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_deps b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_deps deleted file mode 100644 index 0a64b3a5ec1fda587aebe4104f60c917259dc741..0000000000000000000000000000000000000000 Binary files a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_deps and /dev/null differ diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_log b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_log deleted file mode 100644 index 0ab97736f46581c231ded891d146b9165a8cec4f..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/.ninja_log +++ /dev/null @@ -1,3 +0,0 @@ -# ninja log v5 -0 20522 1775205758816462106 /workspace/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation.o db55a3ac18a07cb5 -1 21200 1775205759483467685 /workspace/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation_cuda.o f090fdcb36569dda diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/build.ninja b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/build.ninja deleted file mode 100644 index a3e4778691c513cf9dea05147857108ea3a8ac6b..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/build.ninja +++ /dev/null @@ -1,33 +0,0 @@ -ninja_required_version = 1.3 -cxx = c++ -nvcc = /opt/dtk/cuda/cuda/bin/nvcc - -cflags = -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DWITH_CUDA -I/usr/local/lib/python3.10/dist-packages/torch/include -I/usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.10/dist-packages/torch/include/TH -I/usr/local/lib/python3.10/dist-packages/torch/include/THC -I/opt/dtk/cuda/cuda/include -I/usr/include/python3.10 -c -post_cflags = -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1014"' -DTORCH_EXTENSION_NAME=deformable_aggregation_ext -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++17 -cuda_cflags = -DWITH_CUDA -I/usr/local/lib/python3.10/dist-packages/torch/include -I/usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.10/dist-packages/torch/include/TH -I/usr/local/lib/python3.10/dist-packages/torch/include/THC -I/opt/dtk/cuda/cuda/include -I/usr/include/python3.10 -c -cuda_post_cflags = -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options -fPIC -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1014"' -DTORCH_EXTENSION_NAME=deformable_aggregation_ext -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_90,code=compute_90 -gencode=arch=compute_90,code=sm_90 -std=c++17 -cuda_dlink_post_cflags = -ldflags = - -rule compile - command = $cxx -MMD -MF $out.d $cflags -c $in -o $out $post_cflags - depfile = $out.d - deps = gcc - -rule cuda_compile - depfile = $out.d - deps = gcc - command = $nvcc --generate-dependencies-with-compile --dependency-output $out.d $cuda_cflags -c $in -o $out $cuda_post_cflags - - - - - -build /workspace/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation.o: compile /workspace/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation.cpp -build /workspace/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation_cuda.o: cuda_compile /workspace/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.cu - - - - - - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation.o b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation.o deleted file mode 100644 index bea4e43bbc109b2bcb79e5a2224d56b83e545162..0000000000000000000000000000000000000000 Binary files a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation.o and /dev/null differ diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation_cuda.o b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation_cuda.o deleted file mode 100644 index 3d49ea231682ecbb4f3e0f0f81d97fa6bdb4e5d9..0000000000000000000000000000000000000000 Binary files a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/build/temp.linux-x86_64-cpython-310/src/deformable_aggregation_cuda.o and /dev/null differ diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so deleted file mode 100755 index 814a41f2932f129bde1772a0850a25ea76edd5d3..0000000000000000000000000000000000000000 Binary files a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.cpython-310-x86_64-linux-gnu.so and /dev/null differ diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/PKG-INFO b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/PKG-INFO deleted file mode 100644 index 768433589ec0fed80569d14abf6f2807bb4d5d03..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/PKG-INFO +++ /dev/null @@ -1,3 +0,0 @@ -Metadata-Version: 2.1 -Name: deformable-aggregation-ext -Version: 0.0.0 diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/SOURCES.txt b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/SOURCES.txt deleted file mode 100644 index be8ed3072b7c1719d8d39e42df6cb0e78ba5b00e..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -__init__.py -deformable_aggregation.py -setup.py -deformable_aggregation_ext.egg-info/PKG-INFO -deformable_aggregation_ext.egg-info/SOURCES.txt -deformable_aggregation_ext.egg-info/dependency_links.txt -deformable_aggregation_ext.egg-info/top_level.txt -src/deformable_aggregation.cpp -src/deformable_aggregation_cuda.cu \ No newline at end of file diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/dependency_links.txt b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/dependency_links.txt deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/top_level.txt b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/top_level.txt deleted file mode 100644 index 8b137891791fe96927ad78e64b0aad7bded08bdc..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/deformable_aggregation_ext.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation.cpp b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation.cpp deleted file mode 100644 index f346f0509c4a1d1f3b50f29517fe1087a66236f8..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include -#include - -void deformable_aggregation( - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -); - - - -/* feat: bs, num_feat, c */ -/* _spatial_shape: cam, scale, 2 */ -/* _scale_start_index: cam, scale */ -/* _sampling_location: bs, anchor, pts, cam, 2 */ -/* _weights: bs, anchor, pts, cam, scale, group */ -/* output: bs, anchor, c */ -/* kernel: bs, anchor, pts, c */ - - -at::Tensor deformable_aggregation_forward( - const at::Tensor &_mc_ms_feat, - const at::Tensor &_spatial_shape, - const at::Tensor &_scale_start_index, - const at::Tensor &_sampling_location, - const at::Tensor &_weights -) { - at::DeviceGuard guard(_mc_ms_feat.device()); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_mc_ms_feat)); - int batch_size = _mc_ms_feat.size(0); - int num_feat = _mc_ms_feat.size(1); - int num_embeds = _mc_ms_feat.size(2); - int num_cams = _spatial_shape.size(0); - int num_scale = _spatial_shape.size(1); - int num_anchors = _sampling_location.size(1); - int num_pts = _sampling_location.size(2); - int num_groups = _weights.size(5); - - const float* mc_ms_feat = _mc_ms_feat.data_ptr(); - const int* spatial_shape = _spatial_shape.data_ptr(); - const int* scale_start_index = _scale_start_index.data_ptr(); - const float* sampling_location = _sampling_location.data_ptr(); - const float* weights = _weights.data_ptr(); - - auto output = at::zeros({batch_size, num_anchors, num_embeds}, _mc_ms_feat.options()); - int warm_up = 10; - int prof_cnt = 50; - cudaEvent_t start, stop; - float milliseconds = 0; - deformable_aggregation( - output.data_ptr(), - mc_ms_feat, spatial_shape, scale_start_index, sampling_location, weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - return output; -} - - - - -void deformable_aggregation_grad( - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -); - -void deformable_aggregation_backward( - const at::Tensor &_mc_ms_feat, - const at::Tensor &_spatial_shape, - const at::Tensor &_scale_start_index, - const at::Tensor &_sampling_location, - const at::Tensor &_weights, - const at::Tensor &_grad_output, - at::Tensor &_grad_mc_ms_feat, - at::Tensor &_grad_sampling_location, - at::Tensor &_grad_weights -) { - at::DeviceGuard guard(_mc_ms_feat.device()); - const at::cuda::OptionalCUDAGuard device_guard(device_of(_mc_ms_feat)); - int batch_size = _mc_ms_feat.size(0); - int num_feat = _mc_ms_feat.size(1); - int num_embeds = _mc_ms_feat.size(2); - int num_cams = _spatial_shape.size(0); - int num_scale = _spatial_shape.size(1); - int num_anchors = _sampling_location.size(1); - int num_pts = _sampling_location.size(2); - int num_groups = _weights.size(5); - - const float* mc_ms_feat = _mc_ms_feat.data_ptr(); - const int* spatial_shape = _spatial_shape.data_ptr(); - const int* scale_start_index = _scale_start_index.data_ptr(); - const float* sampling_location = _sampling_location.data_ptr(); - const float* weights = _weights.data_ptr(); - const float* grad_output = _grad_output.data_ptr(); - - float* grad_mc_ms_feat = _grad_mc_ms_feat.data_ptr(); - float* grad_sampling_location = _grad_sampling_location.data_ptr(); - float* grad_weights = _grad_weights.data_ptr(); - - auto _test_grad_mc_ms_feat_tensor = _grad_mc_ms_feat.clone(); - auto _test_grad_sampling_location_tensor = _grad_sampling_location.clone(); - auto _test_grad_weights_tensor = _grad_weights.clone(); - - float* _test_grad_mc_ms_feat = _test_grad_mc_ms_feat_tensor.data_ptr(); - float* _test_grad_sampling_location = _test_grad_sampling_location_tensor.data_ptr(); - float* _test_grad_weights = _test_grad_weights_tensor.data_ptr(); - - deformable_aggregation_grad( - mc_ms_feat, spatial_shape, scale_start_index, sampling_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - -} - - - - - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def( - "deformable_aggregation_forward", - &deformable_aggregation_forward, - "deformable_aggregation_forward" - ); - - m.def( - "deformable_aggregation_backward", - &deformable_aggregation_backward, - "deformable_aggregation_backward" - ); - -} - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.cu b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.cu deleted file mode 100644 index d50e1bef12a73e9052bb98b30e779de06be3cacd..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.cu +++ /dev/null @@ -1,610 +0,0 @@ -#include -#include -#include -#include - -#include - -#include -#include - - -__device__ float bilinear_sampling( - const float *&bottom_data, const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr -) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - float v1 = 0; - if (h_low >= 0 && w_low >= 0) { - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - v1 = bottom_data[ptr1]; - } - float v2 = 0; - if (h_low >= 0 && w_high <= width - 1) { - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - v2 = bottom_data[ptr2]; - } - float v3 = 0; - if (h_high <= height - 1 && w_low >= 0) { - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - v3 = bottom_data[ptr3]; - } - float v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) { - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - v4 = bottom_data[ptr4]; - } - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - return val; -} - -struct float2_t{ - float a; - float b; -}; - -__forceinline__ __device__ -float2_t warp_reduce_sum(float2_t val, int max = 32) { - for (int offset = max; offset > 0; offset >>= 1) { - val.a += __shfl_down(val.a, offset); - val.b += __shfl_down(val.b, offset); - } - return val; -} - -template -__forceinline__ __device__ -float2_t block_reduce_sum(float2_t val, float2_t* shared) { - const int lid = threadIdx.x % 64; - const int wid = threadIdx.x / 64; - constexpr int share_size = blocksize / 64; - - val = warp_reduce_sum(val); - - if constexpr (blocksize == 64) return val; - - if (lid == 0 && wid < share_size) { - shared[wid] = val; - } - - __syncthreads(); - - if (wid == 0 && lid < share_size) { - val = shared[lid]; - val = warp_reduce_sum(val, share_size / 2); - } - - return val; - -} - -__device__ void bilinear_sampling_grad_sp( - const float *&bottom_data, const float &weight, - const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr, - const float &grad_output, - float *&grad_mc_ms_feat, float *grad_sampling_location, float *grad_weights, - float2_t* s_data) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - const float top_grad_mc_ms_feat = grad_output * weight; - float grad_h_weight = 0, grad_w_weight = 0; - - - const int valid1 = (h_low >= 0 && w_low >= 0); - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - float v1 = valid1 ? bottom_data[ptr1] : 0.0f; - if (valid1) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); -#endif - } - - const int valid2 = (h_low >= 0 && w_high <= width - 1); - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - float v2 = valid2 ? bottom_data[ptr2] : 0.0f; - if (valid2) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); -#endif - } - - const int valid3 = (h_high <= height - 1 && w_low >= 0); - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - float v3 = valid3 ? bottom_data[ptr3] : 0.0f; - if (valid3) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); -#endif - } - - const int valid4 = (h_high <= height - 1 && w_high <= width - 1); - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - float v4 = valid4 ? bottom_data[ptr4] : 0.0f; - if (valid4) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); -#endif - } - - grad_h_weight += (-hw * v1) + (-lw * v2) + ( hw * v3) + ( lw * v4); - grad_w_weight += (-hh * v1) + ( hh * v2) + (-lh * v3) + ( lh * v4); - - float2_t spl; - spl.a = width * grad_w_weight * top_grad_mc_ms_feat; - spl.b = height * grad_h_weight * top_grad_mc_ms_feat; - - spl = block_reduce_sum<256>(spl, s_data); - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - // TODO: 尝试 grad_weights 部分的规约, 区间设置 - //! | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | - //! 区间不固定的情况怎么规约 - //! 还有线程号的对应关系 - //! ----------- 仅对特定参数优化---------------- - - //! 这一点的优化仅针对 group 内部原始小于 64 生效 - float wei = grad_output * val; - - for (int offset=16; offset>=1; offset >>= 1) { - wei += __shfl_down(wei, offset); - } - - #ifdef __gfx936__ - //! 最后一步的 warp 内规约 - //! 规约区间为 - // __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, grad_output * val); - - if (threadIdx.x % 32 == 0) { - // __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, wei); - *grad_weights +=wei; - } - - if (threadIdx.x ==0) { - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location, spl.a); - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location + 1, spl.b); - } - #else - atomicAdd(grad_weights, grad_output * val); - atomicAdd(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - atomicAdd(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #endif -} - -__device__ void bilinear_sampling_grad( - const float *&bottom_data, const float &weight, - const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr, - const float &grad_output, - float *&grad_mc_ms_feat, float *grad_sampling_location, float *grad_weights) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - const float top_grad_mc_ms_feat = grad_output * weight; - float grad_h_weight = 0, grad_w_weight = 0; - - float v1 = 0; - if (h_low >= 0 && w_low >= 0) { - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - v1 = bottom_data[ptr1]; - grad_h_weight -= hw * v1; - grad_w_weight -= hh * v1; - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); - #endif - } - - float v2 = 0; - if (h_low >= 0 && w_high <= width - 1) { - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - v2 = bottom_data[ptr2]; - grad_h_weight -= lw * v2; - grad_w_weight += hh * v2; - - // atomicAdd(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - #endif - - } - float v3 = 0; - if (h_high <= height - 1 && w_low >= 0) { - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - v3 = bottom_data[ptr3]; - grad_h_weight += hw * v3; - grad_w_weight -= lh * v3; - // atomicAdd(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - #endif - - } - float v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) { - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - v4 = bottom_data[ptr4]; - grad_h_weight += lw * v4; - grad_w_weight += lh * v4; - // atomicAdd(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - #endif - - } - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, grad_output * val); - - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #else - atomicAdd(grad_weights, grad_output * val); - atomicAdd(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - atomicAdd(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #endif -} - -__global__ void deformable_aggregation_kernel( - const int64_t num_kernels, - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - int64_t block_id = blockIdx.x; // block -> (batch, anchor) - int batch_idx = block_id / num_anchors; - int anchor_local = block_id % num_anchors; - int anchor_index = batch_idx * num_anchors + anchor_local; - - int channel = threadIdx.x; // thread -> channel - if(channel >= num_embeds) return; - - double accum = 0.0; - - for(int p=0; p0.f && loc_w<1.f && loc_h>0.f && loc_h<1.f)) continue; - - for(int s=0; s0 ? (channel / embeds_per_group) : 0; - int w_idx = (((((anchor_index*num_pts + p)*num_cams + cam)*num_scale + s)*num_groups)+group); - double w_val = double(weights[w_idx]); - - accum += (double)sampled * (double)w_val; - } - } - } - float result=float(accum); - -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(output + anchor_index * num_embeds + channel, result); -#else - atomicAdd(output + anchor_index * num_embeds + channel, result); -#endif -} - - -// 辅助函数:判断是否为 2 的幂(device 上 inline) -__device__ __forceinline__ bool is_pow2_int(int x) { - return (x > 0) && ((x & (x - 1)) == 0); -} -// 辅助函数:计算 base-2 的对数 (假设 x 是 2 的幂) -__device__ __forceinline__ int log2_int(int x) { - int s = 0; - while ((x & 1) == 0) { x >>= 1; ++s; } - return s; -} - - -__global__ void deformable_aggregation_grad_kernel_sp( - const int num_kernels, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups) { - extern __shared__ float2_t s_data[]; - - int block_id = blockIdx.x; // 每个block对应(batch, anchor) - int batch_idx = block_id / num_anchors; - int anchor_local = block_id % num_anchors; - int anchor_index = batch_idx * num_anchors + anchor_local; - - int channel = threadIdx.x; // 每个thread对应一个通道 - if (channel >= num_embeds) return; - - float grad_accum = 0.0f; - - // —— 循环计算点、相机、尺度的梯度 - for (int p = 0; p < num_pts; ++p) { - for (int cam = 0; cam < num_cams; ++cam) { - int loc_offset = (((anchor_index * num_pts + p) * num_cams + cam) << 1); - float loc_w = sample_location[loc_offset + 0]; - float loc_h = sample_location[loc_offset + 1]; - - if (loc_w <= 0 || loc_w >= 1 || loc_h <= 0 || loc_h >= 1) - continue; // 跳过越界点 - - for (int s = 0; s < num_scale; ++s) { - int cam_scale_index = cam * num_scale + s; - int sp_base = cam_scale_index * 2; - int H = spatial_shape[sp_base]; - int W = spatial_shape[sp_base + 1]; - - float h_im = loc_h * H - 0.5f; - float w_im = loc_w * W - 0.5f; - - int feat_map_idx = batch_idx * num_feat + scale_start_index[cam_scale_index]; - int base_ptr = feat_map_idx * num_embeds + channel; - - int embeds_per_group = num_embeds / num_groups; - int group = embeds_per_group > 0 ? (channel / embeds_per_group) : 0; - int w_idx = (((((anchor_index * num_pts + p) * num_cams + cam) * num_scale + s) * num_groups) + group); - - float weight_val = weights[w_idx]; - float grad_val = grad_output[anchor_index * num_embeds + channel]; - - // —— 调用梯度计算 - bilinear_sampling_grad_sp( - mc_ms_feat, weight_val, H, W, num_embeds, h_im, w_im, base_ptr, - grad_val, grad_mc_ms_feat, - grad_sampling_location + loc_offset, - grad_weights + w_idx, - s_data); - } - } - } -} - -__global__ void deformable_aggregation_grad_kernel( - const int64_t num_kernels, - const float* mc_ms_feat, // [bs, anchor, pts, cam, scale, channel] - const int* spatial_shape, // [cam, scale, 2] - const int* scale_start_index, // [cam, scale] - const float* sample_location, // [bs, anchor, pts, cam, 2(y, x)] - const float* weights, // [bs, anchor, cam, scale, group] - const float* grad_output, // [bs, anchor, c] - float* grad_mc_ms_feat, // same as feat - float* grad_sampling_location, // same as sampling location - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - int64_t idx = blockIdx.x * blockDim.x + threadIdx.x; - if (idx >= num_kernels) return; - - const int weights_ptr = idx / (num_embeds / num_groups); - const int channel_index = idx % num_embeds; - idx /= num_embeds; - const int scale_index = idx % num_scale; - idx /= num_scale; - - const int cam_index = idx % num_cams; - idx /= num_cams; - const int pts_index = idx % num_pts; - idx /= num_pts; - - int anchor_index = idx % num_anchors; - idx /= num_anchors; - const int batch_index = idx % batch_size; - idx /= batch_size; - - anchor_index = batch_index * num_anchors + anchor_index; - const int loc_offset = ((anchor_index * num_pts + pts_index) * num_cams + cam_index) << 1; - - const float loc_w = sample_location[loc_offset]; - if (loc_w <= 0 || loc_w >= 1) return; - const float loc_h = sample_location[loc_offset + 1]; - if (loc_h <= 0 || loc_h >= 1) return; - - const float grad = grad_output[anchor_index*num_embeds + channel_index]; - - int cam_scale_index = cam_index * num_scale + scale_index; - const int value_offset = (batch_index * num_feat + scale_start_index[cam_scale_index]) * num_embeds + channel_index; - - cam_scale_index = cam_scale_index << 1; - const int h = spatial_shape[cam_scale_index]; - const int w = spatial_shape[cam_scale_index + 1]; - - const float h_im = loc_h * h - 0.5; - const float w_im = loc_w * w - 0.5; - - - const float weight = weights[weights_ptr]; - float *grad_weights_ptr = grad_weights + weights_ptr; - float *grad_location_ptr = grad_sampling_location + loc_offset; - bilinear_sampling_grad( - mc_ms_feat, weight, h, w, num_embeds, h_im, w_im, - value_offset, - grad, - grad_mc_ms_feat, grad_location_ptr, grad_weights_ptr - ); -} - -void deformable_aggregation( - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - // new grid: one block per (batch, anchor) - const int grid = batch_size * num_anchors; - - // choose block threads: try to use a power-of-two near num_embeds but <= 1024 - int threads = 256; - if (num_embeds <= 128) threads = 128; - else if (num_embeds < 256) threads = 256; - else if (num_embeds <= 512) threads = 512; - else threads = 1024; - - deformable_aggregation_kernel<<< grid, threads >>>( - 0,output, mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - -} - -void deformable_aggregation_grad( - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - const int64_t num_kernels = (int64_t)batch_size * num_pts * num_embeds * num_anchors * num_cams * num_scale; - - if (num_embeds != 256 || ((num_embeds / num_groups) != 32)) { - deformable_aggregation_grad_kernel - <<<(int)ceil(((double)num_kernels/128)), 128>>>( - num_kernels, - mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - } else { - - int num_blocks = batch_size * num_anchors; - int threads_per_block = num_embeds; - deformable_aggregation_grad_kernel_sp<<>>( - 0, - mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - } -} - - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.hip b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.hip deleted file mode 100644 index be04141493e936ae06d4ad77479b179cba6ca5a0..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_cuda.hip +++ /dev/null @@ -1,612 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include -#include -#include - -#include - -#include -#include - - -__device__ float bilinear_sampling( - const float *&bottom_data, const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr -) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - float v1 = 0; - if (h_low >= 0 && w_low >= 0) { - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - v1 = bottom_data[ptr1]; - } - float v2 = 0; - if (h_low >= 0 && w_high <= width - 1) { - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - v2 = bottom_data[ptr2]; - } - float v3 = 0; - if (h_high <= height - 1 && w_low >= 0) { - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - v3 = bottom_data[ptr3]; - } - float v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) { - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - v4 = bottom_data[ptr4]; - } - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - return val; -} - -struct float2_t{ - float a; - float b; -}; - -__forceinline__ __device__ -float2_t warp_reduce_sum(float2_t val, int max = 32) { - for (int offset = max; offset > 0; offset >>= 1) { - val.a += __shfl_down(val.a, offset); - val.b += __shfl_down(val.b, offset); - } - return val; -} - -template -__forceinline__ __device__ -float2_t block_reduce_sum(float2_t val, float2_t* shared) { - const int lid = threadIdx.x % 64; - const int wid = threadIdx.x / 64; - constexpr int share_size = blocksize / 64; - - val = warp_reduce_sum(val); - - if constexpr (blocksize == 64) return val; - - if (lid == 0 && wid < share_size) { - shared[wid] = val; - } - - __syncthreads(); - - if (wid == 0 && lid < share_size) { - val = shared[lid]; - val = warp_reduce_sum(val, share_size / 2); - } - - return val; - -} - -__device__ void bilinear_sampling_grad_sp( - const float *&bottom_data, const float &weight, - const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr, - const float &grad_output, - float *&grad_mc_ms_feat, float *grad_sampling_location, float *grad_weights, - float2_t* s_data) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - const float top_grad_mc_ms_feat = grad_output * weight; - float grad_h_weight = 0, grad_w_weight = 0; - - - const int valid1 = (h_low >= 0 && w_low >= 0); - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - float v1 = valid1 ? bottom_data[ptr1] : 0.0f; - if (valid1) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); -#endif - } - - const int valid2 = (h_low >= 0 && w_high <= width - 1); - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - float v2 = valid2 ? bottom_data[ptr2] : 0.0f; - if (valid2) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); -#endif - } - - const int valid3 = (h_high <= height - 1 && w_low >= 0); - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - float v3 = valid3 ? bottom_data[ptr3] : 0.0f; - if (valid3) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); -#endif - } - - const int valid4 = (h_high <= height - 1 && w_high <= width - 1); - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - float v4 = valid4 ? bottom_data[ptr4] : 0.0f; - if (valid4) { -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); -#endif - } - - grad_h_weight += (-hw * v1) + (-lw * v2) + ( hw * v3) + ( lw * v4); - grad_w_weight += (-hh * v1) + ( hh * v2) + (-lh * v3) + ( lh * v4); - - float2_t spl; - spl.a = width * grad_w_weight * top_grad_mc_ms_feat; - spl.b = height * grad_h_weight * top_grad_mc_ms_feat; - - spl = block_reduce_sum<256>(spl, s_data); - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - // TODO: 尝试 grad_weights 部分的规约, 区间设置 - //! | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | - //! 区间不固定的情况怎么规约 - //! 还有线程号的对应关系 - //! ----------- 仅对特定参数优化---------------- - - //! 这一点的优化仅针对 group 内部原始小于 64 生效 - float wei = grad_output * val; - - for (int offset=16; offset>=1; offset >>= 1) { - wei += __shfl_down(wei, offset); - } - - #ifdef __gfx936__ - //! 最后一步的 warp 内规约 - //! 规约区间为 - // __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, grad_output * val); - - if (threadIdx.x % 32 == 0) { - // __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, wei); - *grad_weights +=wei; - } - - if (threadIdx.x ==0) { - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location, spl.a); - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location + 1, spl.b); - } - #else - atomicAdd(grad_weights, grad_output * val); - atomicAdd(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - atomicAdd(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #endif -} - -__device__ void bilinear_sampling_grad( - const float *&bottom_data, const float &weight, - const int &height, const int &width, - const int &num_embeds, const float &h_im, const float &w_im, - const int &base_ptr, - const float &grad_output, - float *&grad_mc_ms_feat, float *grad_sampling_location, float *grad_weights) { - const int h_low = floorf(h_im); - const int w_low = floorf(w_im); - const int h_high = h_low + 1; - const int w_high = w_low + 1; - - const float lh = h_im - h_low; - const float lw = w_im - w_low; - const float hh = 1 - lh, hw = 1 - lw; - - const int w_stride = num_embeds; - const int h_stride = width * w_stride; - const int h_low_ptr_offset = h_low * h_stride; - const int h_high_ptr_offset = h_low_ptr_offset + h_stride; - const int w_low_ptr_offset = w_low * w_stride; - const int w_high_ptr_offset = w_low_ptr_offset + w_stride; - - const float w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - const float top_grad_mc_ms_feat = grad_output * weight; - float grad_h_weight = 0, grad_w_weight = 0; - - float v1 = 0; - if (h_low >= 0 && w_low >= 0) { - const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; - v1 = bottom_data[ptr1]; - grad_h_weight -= hw * v1; - grad_w_weight -= hh * v1; - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr1, w1 * top_grad_mc_ms_feat); - #endif - } - - float v2 = 0; - if (h_low >= 0 && w_high <= width - 1) { - const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; - v2 = bottom_data[ptr2]; - grad_h_weight -= lw * v2; - grad_w_weight += hh * v2; - - // atomicAdd(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr2, w2 * top_grad_mc_ms_feat); - #endif - - } - float v3 = 0; - if (h_high <= height - 1 && w_low >= 0) { - const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; - v3 = bottom_data[ptr3]; - grad_h_weight += hw * v3; - grad_w_weight -= lh * v3; - // atomicAdd(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr3, w3 * top_grad_mc_ms_feat); - #endif - - } - float v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) { - const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; - v4 = bottom_data[ptr4]; - grad_h_weight += lw * v4; - grad_w_weight += lh * v4; - // atomicAdd(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - #else - atomicAdd(grad_mc_ms_feat + ptr4, w4 * top_grad_mc_ms_feat); - #endif - - } - - const float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - - #ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(grad_weights, grad_output * val); - - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - __builtin_amdgcn_global_atomic_fadd_f32(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #else - atomicAdd(grad_weights, grad_output * val); - atomicAdd(grad_sampling_location, width * grad_w_weight * top_grad_mc_ms_feat); - atomicAdd(grad_sampling_location + 1, height * grad_h_weight * top_grad_mc_ms_feat); - #endif -} - -__global__ void deformable_aggregation_kernel( - const int64_t num_kernels, - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - int64_t block_id = blockIdx.x; // block -> (batch, anchor) - int batch_idx = block_id / num_anchors; - int anchor_local = block_id % num_anchors; - int anchor_index = batch_idx * num_anchors + anchor_local; - - int channel = threadIdx.x; // thread -> channel - if(channel >= num_embeds) return; - - double accum = 0.0; - - for(int p=0; p0.f && loc_w<1.f && loc_h>0.f && loc_h<1.f)) continue; - - for(int s=0; s0 ? (channel / embeds_per_group) : 0; - int w_idx = (((((anchor_index*num_pts + p)*num_cams + cam)*num_scale + s)*num_groups)+group); - double w_val = double(weights[w_idx]); - - accum += (double)sampled * (double)w_val; - } - } - } - float result=float(accum); - -#ifdef __gfx936__ - __builtin_amdgcn_global_atomic_fadd_f32(output + anchor_index * num_embeds + channel, result); -#else - atomicAdd(output + anchor_index * num_embeds + channel, result); -#endif -} - - -// 辅助函数:判断是否为 2 的幂(device 上 inline) -__device__ __forceinline__ bool is_pow2_int(int x) { - return (x > 0) && ((x & (x - 1)) == 0); -} -// 辅助函数:计算 base-2 的对数 (假设 x 是 2 的幂) -__device__ __forceinline__ int log2_int(int x) { - int s = 0; - while ((x & 1) == 0) { x >>= 1; ++s; } - return s; -} - - -__global__ void deformable_aggregation_grad_kernel_sp( - const int num_kernels, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups) { - extern __shared__ float2_t s_data[]; - - int block_id = blockIdx.x; // 每个block对应(batch, anchor) - int batch_idx = block_id / num_anchors; - int anchor_local = block_id % num_anchors; - int anchor_index = batch_idx * num_anchors + anchor_local; - - int channel = threadIdx.x; // 每个thread对应一个通道 - if (channel >= num_embeds) return; - - float grad_accum = 0.0f; - - // —— 循环计算点、相机、尺度的梯度 - for (int p = 0; p < num_pts; ++p) { - for (int cam = 0; cam < num_cams; ++cam) { - int loc_offset = (((anchor_index * num_pts + p) * num_cams + cam) << 1); - float loc_w = sample_location[loc_offset + 0]; - float loc_h = sample_location[loc_offset + 1]; - - if (loc_w <= 0 || loc_w >= 1 || loc_h <= 0 || loc_h >= 1) - continue; // 跳过越界点 - - for (int s = 0; s < num_scale; ++s) { - int cam_scale_index = cam * num_scale + s; - int sp_base = cam_scale_index * 2; - int H = spatial_shape[sp_base]; - int W = spatial_shape[sp_base + 1]; - - float h_im = loc_h * H - 0.5f; - float w_im = loc_w * W - 0.5f; - - int feat_map_idx = batch_idx * num_feat + scale_start_index[cam_scale_index]; - int base_ptr = feat_map_idx * num_embeds + channel; - - int embeds_per_group = num_embeds / num_groups; - int group = embeds_per_group > 0 ? (channel / embeds_per_group) : 0; - int w_idx = (((((anchor_index * num_pts + p) * num_cams + cam) * num_scale + s) * num_groups) + group); - - float weight_val = weights[w_idx]; - float grad_val = grad_output[anchor_index * num_embeds + channel]; - - // —— 调用梯度计算 - bilinear_sampling_grad_sp( - mc_ms_feat, weight_val, H, W, num_embeds, h_im, w_im, base_ptr, - grad_val, grad_mc_ms_feat, - grad_sampling_location + loc_offset, - grad_weights + w_idx, - s_data); - } - } - } -} - -__global__ void deformable_aggregation_grad_kernel( - const int64_t num_kernels, - const float* mc_ms_feat, // [bs, anchor, pts, cam, scale, channel] - const int* spatial_shape, // [cam, scale, 2] - const int* scale_start_index, // [cam, scale] - const float* sample_location, // [bs, anchor, pts, cam, 2(y, x)] - const float* weights, // [bs, anchor, cam, scale, group] - const float* grad_output, // [bs, anchor, c] - float* grad_mc_ms_feat, // same as feat - float* grad_sampling_location, // same as sampling location - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - int64_t idx = blockIdx.x * blockDim.x + threadIdx.x; - if (idx >= num_kernels) return; - - const int weights_ptr = idx / (num_embeds / num_groups); - const int channel_index = idx % num_embeds; - idx /= num_embeds; - const int scale_index = idx % num_scale; - idx /= num_scale; - - const int cam_index = idx % num_cams; - idx /= num_cams; - const int pts_index = idx % num_pts; - idx /= num_pts; - - int anchor_index = idx % num_anchors; - idx /= num_anchors; - const int batch_index = idx % batch_size; - idx /= batch_size; - - anchor_index = batch_index * num_anchors + anchor_index; - const int loc_offset = ((anchor_index * num_pts + pts_index) * num_cams + cam_index) << 1; - - const float loc_w = sample_location[loc_offset]; - if (loc_w <= 0 || loc_w >= 1) return; - const float loc_h = sample_location[loc_offset + 1]; - if (loc_h <= 0 || loc_h >= 1) return; - - const float grad = grad_output[anchor_index*num_embeds + channel_index]; - - int cam_scale_index = cam_index * num_scale + scale_index; - const int value_offset = (batch_index * num_feat + scale_start_index[cam_scale_index]) * num_embeds + channel_index; - - cam_scale_index = cam_scale_index << 1; - const int h = spatial_shape[cam_scale_index]; - const int w = spatial_shape[cam_scale_index + 1]; - - const float h_im = loc_h * h - 0.5; - const float w_im = loc_w * w - 0.5; - - - const float weight = weights[weights_ptr]; - float *grad_weights_ptr = grad_weights + weights_ptr; - float *grad_location_ptr = grad_sampling_location + loc_offset; - bilinear_sampling_grad( - mc_ms_feat, weight, h, w, num_embeds, h_im, w_im, - value_offset, - grad, - grad_mc_ms_feat, grad_location_ptr, grad_weights_ptr - ); -} - -void deformable_aggregation( - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - // new grid: one block per (batch, anchor) - const int grid = batch_size * num_anchors; - - // choose block threads: try to use a power-of-two near num_embeds but <= 1024 - int threads = 256; - if (num_embeds <= 128) threads = 128; - else if (num_embeds < 256) threads = 256; - else if (num_embeds <= 512) threads = 512; - else threads = 1024; - - hipLaunchKernelGGL(( deformable_aggregation_kernel), dim3(grid), dim3(threads) , 0, 0, - 0,output, mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - -} - -void deformable_aggregation_grad( - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -) { - const int64_t num_kernels = (int64_t)batch_size * num_pts * num_embeds * num_anchors * num_cams * num_scale; - - if (num_embeds != 256 || ((num_embeds / num_groups) != 32)) { - hipLaunchKernelGGL(( deformable_aggregation_grad_kernel) - , dim3((int)ceil(((double)num_kernels/128))), dim3(128), 0, 0, - num_kernels, - mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - } else { - - int num_blocks = batch_size * num_anchors; - int threads_per_block = num_embeds; - hipLaunchKernelGGL(( deformable_aggregation_grad_kernel_sp), dim3(num_blocks), dim3(threads_per_block), 256 * 2 * sizeof(float), 0, - 0, - mc_ms_feat, spatial_shape, scale_start_index, sample_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - } -} - - diff --git a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_hip.cpp b/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_hip.cpp deleted file mode 100644 index 3aa4182d6604191e98328a596be9d615523a9661..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/projects/mmdet3d_plugin/ops/src/deformable_aggregation_hip.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// !!! This is a file automatically generated by hipify!!! -#include -#include -#include - -void deformable_aggregation( - float* output, - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -); - - - -/* feat: bs, num_feat, c */ -/* _spatial_shape: cam, scale, 2 */ -/* _scale_start_index: cam, scale */ -/* _sampling_location: bs, anchor, pts, cam, 2 */ -/* _weights: bs, anchor, pts, cam, scale, group */ -/* output: bs, anchor, c */ -/* kernel: bs, anchor, pts, c */ - - -at::Tensor deformable_aggregation_forward( - const at::Tensor &_mc_ms_feat, - const at::Tensor &_spatial_shape, - const at::Tensor &_scale_start_index, - const at::Tensor &_sampling_location, - const at::Tensor &_weights -) { - at::DeviceGuard guard(_mc_ms_feat.device()); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_mc_ms_feat)); - int batch_size = _mc_ms_feat.size(0); - int num_feat = _mc_ms_feat.size(1); - int num_embeds = _mc_ms_feat.size(2); - int num_cams = _spatial_shape.size(0); - int num_scale = _spatial_shape.size(1); - int num_anchors = _sampling_location.size(1); - int num_pts = _sampling_location.size(2); - int num_groups = _weights.size(5); - - const float* mc_ms_feat = _mc_ms_feat.data_ptr(); - const int* spatial_shape = _spatial_shape.data_ptr(); - const int* scale_start_index = _scale_start_index.data_ptr(); - const float* sampling_location = _sampling_location.data_ptr(); - const float* weights = _weights.data_ptr(); - - auto output = at::zeros({batch_size, num_anchors, num_embeds}, _mc_ms_feat.options()); - int warm_up = 10; - int prof_cnt = 50; - hipEvent_t start, stop; - float milliseconds = 0; - deformable_aggregation( - output.data_ptr(), - mc_ms_feat, spatial_shape, scale_start_index, sampling_location, weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - return output; -} - - - - -void deformable_aggregation_grad( - const float* mc_ms_feat, - const int* spatial_shape, - const int* scale_start_index, - const float* sample_location, - const float* weights, - const float* grad_output, - float* grad_mc_ms_feat, - float* grad_sampling_location, - float* grad_weights, - int batch_size, - int num_cams, - int num_feat, - int num_embeds, - int num_scale, - int num_anchors, - int num_pts, - int num_groups -); - -void deformable_aggregation_backward( - const at::Tensor &_mc_ms_feat, - const at::Tensor &_spatial_shape, - const at::Tensor &_scale_start_index, - const at::Tensor &_sampling_location, - const at::Tensor &_weights, - const at::Tensor &_grad_output, - at::Tensor &_grad_mc_ms_feat, - at::Tensor &_grad_sampling_location, - at::Tensor &_grad_weights -) { - at::DeviceGuard guard(_mc_ms_feat.device()); - const at::hip::OptionalHIPGuardMasqueradingAsCUDA device_guard(device_of(_mc_ms_feat)); - int batch_size = _mc_ms_feat.size(0); - int num_feat = _mc_ms_feat.size(1); - int num_embeds = _mc_ms_feat.size(2); - int num_cams = _spatial_shape.size(0); - int num_scale = _spatial_shape.size(1); - int num_anchors = _sampling_location.size(1); - int num_pts = _sampling_location.size(2); - int num_groups = _weights.size(5); - - const float* mc_ms_feat = _mc_ms_feat.data_ptr(); - const int* spatial_shape = _spatial_shape.data_ptr(); - const int* scale_start_index = _scale_start_index.data_ptr(); - const float* sampling_location = _sampling_location.data_ptr(); - const float* weights = _weights.data_ptr(); - const float* grad_output = _grad_output.data_ptr(); - - float* grad_mc_ms_feat = _grad_mc_ms_feat.data_ptr(); - float* grad_sampling_location = _grad_sampling_location.data_ptr(); - float* grad_weights = _grad_weights.data_ptr(); - - auto _test_grad_mc_ms_feat_tensor = _grad_mc_ms_feat.clone(); - auto _test_grad_sampling_location_tensor = _grad_sampling_location.clone(); - auto _test_grad_weights_tensor = _grad_weights.clone(); - - float* _test_grad_mc_ms_feat = _test_grad_mc_ms_feat_tensor.data_ptr(); - float* _test_grad_sampling_location = _test_grad_sampling_location_tensor.data_ptr(); - float* _test_grad_weights = _test_grad_weights_tensor.data_ptr(); - - deformable_aggregation_grad( - mc_ms_feat, spatial_shape, scale_start_index, sampling_location, weights, - grad_output, grad_mc_ms_feat, grad_sampling_location, grad_weights, - batch_size, num_cams, num_feat, num_embeds, num_scale, num_anchors, num_pts, num_groups - ); - -} - - - - - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def( - "deformable_aggregation_forward", - &deformable_aggregation_forward, - "deformable_aggregation_forward" - ); - - m.def( - "deformable_aggregation_backward", - &deformable_aggregation_backward, - "deformable_aggregation_backward" - ); - -} - diff --git a/docker-hub/Sparse4D/Sparse4D/rocblas_Sparse4D.log b/docker-hub/Sparse4D/Sparse4D/rocblas_Sparse4D.log deleted file mode 100644 index 94a209d6a4c85fe42c5af726a0041c568844fe79..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/rocblas_Sparse4D.log +++ /dev/null @@ -1,139 +0,0 @@ - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 1024 -n 18300 -k 256 --alpha 1 --lda 1024 --ldb 256 --beta 0 --ldc 1024 - 4272 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 128 -n 18300 -k 128 --alpha 1 --lda 128 --ldb 128 --beta 0 --ldc 128 - 672 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 128 -n 9000 -k 128 --alpha 1 --lda 128 --ldb 128 --beta 0 --ldc 128 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 109800 -k 416 --alpha 1 --lda 256 --ldb 416 --beta 0 --ldc 256 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 10 --alpha 1 --lda 256 --ldb 10 --beta 0 --ldc 256 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 11 --alpha 1 --lda 256 --ldb 11 --beta 0 --ldc 256 - 1195 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 18 --alpha 1 --lda 256 --ldb 18 --beta 0 --ldc 256 - 11456 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 256 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 2 --alpha 1 --lda 256 --ldb 2 --beta 0 --ldc 256 - 1194 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 18300 -k 512 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 256 -n 90 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 256 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 2 -n 18300 -k 32 --alpha 1 --lda 2 --ldb 32 --beta 0 --ldc 2 - 8544 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 32 -n 18300 -k 32 --alpha 1 --lda 32 --ldb 32 --beta 0 --ldc 32 - 1344 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 32 -n 9000 -k 32 --alpha 1 --lda 32 --ldb 32 --beta 0 --ldc 32 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 3 -n 18300 -k 128 --alpha 1 --lda 3 --ldb 128 --beta 0 --ldc 3 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 3 -n 18300 -k 32 --alpha 1 --lda 3 --ldb 32 --beta 0 --ldc 3 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 3 -n 18300 -k 64 --alpha 1 --lda 3 --ldb 64 --beta 0 --ldc 3 - 1431 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 512 -n 18300 -k 1024 --alpha 1 --lda 512 --ldb 1024 --beta 0 --ldc 512 - 3821 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 512 -n 18300 -k 256 --alpha 1 --lda 512 --ldb 256 --beta 0 --ldc 512 - 7247 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 512 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 2307 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 512 -n 9000 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 4272 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 64 -n 18300 -k 64 --alpha 1 --lda 64 --ldb 64 --beta 0 --ldc 64 - 672 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB N -m 64 -n 9000 -k 64 --alpha 1 --lda 64 --ldb 64 --beta 0 --ldc 64 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 1024 -n 256 -k 18300 --alpha 1 --lda 1024 --ldb 256 --beta 0 --ldc 1024 - 4272 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 128 -n 128 -k 18300 --alpha 1 --lda 128 --ldb 128 --beta 0 --ldc 128 - 672 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 128 -n 128 -k 9000 --alpha 1 --lda 128 --ldb 128 --beta 0 --ldc 128 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 12 -n 256 -k 90 --alpha 1 --lda 16 --ldb 256 --beta 0 --ldc 12 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 10 -k 18300 --alpha 1 --lda 256 --ldb 10 --beta 0 --ldc 256 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 11 -k 18300 --alpha 1 --lda 256 --ldb 11 --beta 0 --ldc 256 - 1427 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 18 -k 18300 --alpha 1 --lda 256 --ldb 18 --beta 0 --ldc 256 - 11456 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 256 -k 18300 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 256 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 256 -k 18300 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 256 -k 90 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 256 - 1432 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 2 -k 18300 --alpha 1 --lda 256 --ldb 2 --beta 0 --ldc 256 - 1428 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 416 -k 109800 --alpha 1 --lda 256 --ldb 416 --beta 0 --ldc 256 - 1194 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 512 -k 18300 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 1152 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 256 -n 512 -k 9000 --alpha 1 --lda 256 --ldb 512 --beta 0 --ldc 256 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 2 -n 32 -k 18300 --alpha 1 --lda 2 --ldb 32 --beta 0 --ldc 2 - 224 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 2 -n 32 -k 9000 --alpha 1 --lda 2 --ldb 32 --beta 0 --ldc 2 - 8544 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 32 -n 32 -k 18300 --alpha 1 --lda 32 --ldb 32 --beta 0 --ldc 32 - 1344 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 32 -n 32 -k 9000 --alpha 1 --lda 32 --ldb 32 --beta 0 --ldc 32 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 128 -k 18300 --alpha 1 --lda 3 --ldb 128 --beta 0 --ldc 3 - 224 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 128 -k 9000 --alpha 1 --lda 3 --ldb 128 --beta 0 --ldc 3 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 32 -k 18300 --alpha 1 --lda 3 --ldb 32 --beta 0 --ldc 3 - 224 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 32 -k 9000 --alpha 1 --lda 3 --ldb 32 --beta 0 --ldc 3 - 1424 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 64 -k 18300 --alpha 1 --lda 11 --ldb 64 --beta 0 --ldc 3 - 224 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 3 -n 64 -k 9000 --alpha 1 --lda 11 --ldb 64 --beta 0 --ldc 3 - 1430 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 512 -n 1024 -k 18300 --alpha 1 --lda 512 --ldb 1024 --beta 0 --ldc 512 - 3821 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 512 -n 256 -k 18300 --alpha 1 --lda 512 --ldb 256 --beta 0 --ldc 512 - 7247 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 512 -n 512 -k 18300 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 2308 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 512 -n 512 -k 9000 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 4272 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 64 -n 64 -k 18300 --alpha 1 --lda 64 --ldb 64 --beta 0 --ldc 64 - 672 ./rocblas-bench -f gemm -r f32_r --transposeA N --transposeB T -m 64 -n 64 -k 9000 --alpha 1 --lda 64 --ldb 64 --beta 0 --ldc 64 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 1024 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 1 --ldc 1024 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 10 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 10 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 11 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 11 - 4320 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 128 -n 18300 -k 128 --alpha 1 --lda 128 --ldb 128 --beta 1 --ldc 128 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 128 -n 18300 -k 3 --alpha 1 --lda 3 --ldb 3 --beta 1 --ldc 128 - 696 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 128 -n 9000 -k 128 --alpha 1 --lda 128 --ldb 128 --beta 1 --ldc 128 - 232 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 128 -n 9000 -k 3 --alpha 1 --lda 3 --ldb 3 --beta 1 --ldc 128 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 18 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 18 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 18300 -k 1024 --alpha 1 --lda 1024 --ldb 1024 --beta 1 --ldc 256 - 12960 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 256 - 2400 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 256 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 1 --ldc 256 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 90 -k 12 --alpha 1 --lda 12 --ldb 16 --beta 0 --ldc 256 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 256 -n 90 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 256 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 2 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 2 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 18300 -k 2 --alpha 1 --lda 2 --ldb 2 --beta 1 --ldc 32 - 8640 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 18300 -k 32 --alpha 1 --lda 32 --ldb 32 --beta 1 --ldc 32 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 18300 -k 3 --alpha 1 --lda 3 --ldb 3 --beta 1 --ldc 32 - 232 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 9000 -k 2 --alpha 1 --lda 2 --ldb 2 --beta 1 --ldc 32 - 1392 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 9000 -k 32 --alpha 1 --lda 32 --ldb 32 --beta 1 --ldc 32 - 232 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 32 -n 9000 -k 3 --alpha 1 --lda 3 --ldb 3 --beta 1 --ldc 32 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 416 -n 109800 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 1 --ldc 416 - 1200 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 18300 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 512 - 4880 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 2400 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 18300 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 1 --ldc 512 - 1160 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 9000 -k 256 --alpha 1 --lda 256 --ldb 256 --beta 0 --ldc 512 - 2320 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 512 -n 9000 -k 512 --alpha 1 --lda 512 --ldb 512 --beta 0 --ldc 512 - 1440 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 64 -n 18300 -k 3 --alpha 1 --lda 3 --ldb 11 --beta 0 --ldc 64 - 4320 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 64 -n 18300 -k 64 --alpha 1 --lda 64 --ldb 64 --beta 1 --ldc 64 - 232 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 64 -n 9000 -k 3 --alpha 1 --lda 3 --ldb 11 --beta 0 --ldc 64 - 696 ./rocblas-bench -f gemm -r f32_r --transposeA T --transposeB N -m 64 -n 9000 -k 64 --alpha 1 --lda 64 --ldb 64 --beta 1 --ldc 64 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 1024 -n 256 -k 63360 --alpha 1 --a_type f16_r --lda 1024 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 0 --beta 1 --c_type f16_r --ldc 1024 --stride_c 0 --d_type f16_r --ldd 1024 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 1024 -n 512 -k 63360 --alpha 1 --a_type f16_r --lda 1024 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 0 --beta 1 --c_type f16_r --ldc 1024 --stride_c 0 --d_type f16_r --ldd 1024 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 128 -n 512 -k 253440 --alpha 1 --a_type f16_r --lda 128 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 0 --beta 1 --c_type f16_r --ldc 128 --stride_c 0 --d_type f16_r --ldd 128 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 2048 -n 256 -k 15840 --alpha 1 --a_type f16_r --lda 2048 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 0 --beta 1 --c_type f16_r --ldc 2048 --stride_c 0 --d_type f16_r --ldd 2048 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 2048 -n 512 -k 15840 --alpha 1 --a_type f16_r --lda 2048 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 0 --beta 1 --c_type f16_r --ldc 2048 --stride_c 0 --d_type f16_r --ldd 2048 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 1024 -k 63360 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 1024 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 128 -k 1013760 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 128 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 1 -k 1013760 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 1 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 1 -k 253440 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 1 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 1 -k 63360 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 1 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 256 -k 1013760 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 256 -n 64 -k 1013760 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 64 --stride_b 0 --beta 1 --c_type f16_r --ldc 256 --stride_c 0 --d_type f16_r --ldd 256 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 512 -n 128 -k 253440 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 128 --stride_b 0 --beta 1 --c_type f16_r --ldc 512 --stride_c 0 --d_type f16_r --ldd 512 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 512 -n 2048 -k 15840 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 2048 --stride_b 0 --beta 1 --c_type f16_r --ldc 512 --stride_c 0 --d_type f16_r --ldd 512 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 512 -n 256 -k 253440 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 0 --beta 1 --c_type f16_r --ldc 512 --stride_c 0 --d_type f16_r --ldd 512 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 64 -n 256 -k 1013760 --alpha 1 --a_type f16_r --lda 64 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 0 --beta 1 --c_type f16_r --ldc 64 --stride_c 0 --d_type f16_r --ldd 64 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA N --transposeB T -m 64 -n 64 -k 1013760 --alpha 1 --a_type f16_r --lda 64 --stride_a 0 --b_type f16_r --ldb 64 --stride_b 0 --beta 1 --c_type f16_r --ldc 64 --stride_c 0 --d_type f16_r --ldd 64 --stride_d 0 --batch_count 1 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 1024 -n 704 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 180224 --beta 0 --c_type f16_r --ldc 1024 --stride_c 720896 --d_type f16_r --ldd 1024 --stride_d 720896 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 128 -n 11264 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 2883584 --beta 0 --c_type f16_r --ldc 128 --stride_c 1441792 --d_type f16_r --ldd 128 --stride_d 1441792 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 128 -n 2816 -k 512 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 1441792 --beta 0 --c_type f16_r --ldc 128 --stride_c 360448 --d_type f16_r --ldd 128 --stride_d 360448 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 1 -n 11264 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 2883584 --beta 0 --c_type f16_r --ldc 1 --stride_c 11264 --d_type f16_r --ldd 1 --stride_d 11264 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 1 -n 2816 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 720896 --beta 0 --c_type f16_r --ldc 1 --stride_c 2816 --d_type f16_r --ldd 1 --stride_d 2816 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 1 -n 704 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 180224 --beta 0 --c_type f16_r --ldc 1 --stride_c 704 --d_type f16_r --ldd 1 --stride_d 704 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 2048 -n 176 -k 512 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 90112 --beta 0 --c_type f16_r --ldc 2048 --stride_c 360448 --d_type f16_r --ldd 2048 --stride_d 360448 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 256 -n 11264 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 2883584 --beta 0 --c_type f16_r --ldc 256 --stride_c 2883584 --d_type f16_r --ldd 256 --stride_d 2883584 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 256 -n 11264 -k 64 --alpha 1 --a_type f16_r --lda 64 --stride_a 0 --b_type f16_r --ldb 64 --stride_b 720896 --beta 0 --c_type f16_r --ldc 256 --stride_c 2883584 --d_type f16_r --ldd 256 --stride_d 2883584 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 8 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 256 -n 176 -k 2048 --alpha 1 --a_type f16_r --lda 2048 --stride_a 0 --b_type f16_r --ldb 2048 --stride_b 360448 --beta 0 --c_type f16_r --ldc 256 --stride_c 45056 --d_type f16_r --ldd 256 --stride_d 45056 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 256 -n 2816 -k 512 --alpha 1 --a_type f16_r --lda 512 --stride_a 0 --b_type f16_r --ldb 512 --stride_b 1441792 --beta 0 --c_type f16_r --ldc 256 --stride_c 720896 --d_type f16_r --ldd 256 --stride_d 720896 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 256 -n 704 -k 1024 --alpha 1 --a_type f16_r --lda 1024 --stride_a 0 --b_type f16_r --ldb 1024 --stride_b 720896 --beta 0 --c_type f16_r --ldc 256 --stride_c 180224 --d_type f16_r --ldd 256 --stride_d 180224 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 512 -n 176 -k 2048 --alpha 1 --a_type f16_r --lda 2048 --stride_a 0 --b_type f16_r --ldb 2048 --stride_b 360448 --beta 0 --c_type f16_r --ldc 512 --stride_c 90112 --d_type f16_r --ldd 512 --stride_d 90112 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 512 -n 2816 -k 128 --alpha 1 --a_type f16_r --lda 128 --stride_a 0 --b_type f16_r --ldb 128 --stride_b 360448 --beta 0 --c_type f16_r --ldc 512 --stride_c 1441792 --d_type f16_r --ldd 512 --stride_d 1441792 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 512 -n 704 -k 1024 --alpha 1 --a_type f16_r --lda 1024 --stride_a 0 --b_type f16_r --ldb 1024 --stride_b 720896 --beta 0 --c_type f16_r --ldc 512 --stride_c 360448 --d_type f16_r --ldd 512 --stride_d 360448 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 16 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 64 -n 11264 -k 256 --alpha 1 --a_type f16_r --lda 256 --stride_a 0 --b_type f16_r --ldb 256 --stride_b 2883584 --beta 0 --c_type f16_r --ldc 64 --stride_c 720896 --d_type f16_r --ldd 64 --stride_d 720896 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 24 ./rocblas-bench -f gemm_strided_batched_ex --transposeA T --transposeB N -m 64 -n 11264 -k 64 --alpha 1 --a_type f16_r --lda 64 --stride_a 0 --b_type f16_r --ldb 64 --stride_b 720896 --beta 0 --c_type f16_r --ldc 64 --stride_c 720896 --d_type f16_r --ldd 64 --stride_d 720896 --batch_count 90 --compute_type f32_r --algo 0 --solution_index 0 --flags 0 - 2475 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB N -m 64 -n 1220 -k 1220 --alpha 1 --lda 7680 --stride_a 64 --ldb 1220 --stride_b 1488400 --beta 0 --ldc 64 --stride_c 78080 --batch_count 120 - 2314 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB N -m 64 -n 1220 -k 600 --alpha 1 --lda 7680 --stride_a 64 --ldb 600 --stride_b 732000 --beta 0 --ldc 64 --stride_c 78080 --batch_count 120 - 1235 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 1220 -n 64 -k 1220 --alpha 1 --lda 1220 --stride_a 1488400 --ldb 7680 --stride_b 64 --beta 0 --ldc 1220 --stride_c 78080 --batch_count 120 - 1427 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 4 --beta 0 --ldc 3 --stride_c 3 --batch_count 237900 - 1428 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 4 -n 1 -k 4 --alpha 1 --lda 4 --stride_a 16 --ldb 1 --stride_b 4 --beta 0 --ldc 4 --stride_c 4 --batch_count 1427400 - 1154 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 600 -n 64 -k 1220 --alpha 1 --lda 600 --stride_a 732000 --ldb 7680 --stride_b 64 --beta 0 --ldc 600 --stride_c 38400 --batch_count 120 - 1235 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 64 -n 1220 -k 1220 --alpha 1 --lda 7680 --stride_a 64 --ldb 1220 --stride_b 1488400 --beta 0 --ldc 64 --stride_c 78080 --batch_count 120 - 1154 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA N --transposeB T -m 64 -n 600 -k 1220 --alpha 1 --lda 7680 --stride_a 64 --ldb 600 --stride_b 732000 --beta 0 --ldc 64 --stride_c 38400 --batch_count 120 - 1235 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 1220 -n 1220 -k 64 --alpha 1 --lda 7680 --stride_a 64 --ldb 7680 --stride_b 64 --beta 0 --ldc 1220 --stride_c 1488400 --batch_count 120 - 1240 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 1220 -n 1220 -k 64 --alpha 1 --lda 7680 --stride_a 64 --ldb 7680 --stride_b 64 --beta 1 --ldc 1220 --stride_c 1488400 --batch_count 120 - 1427 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 3 -n 3 -k 1 --alpha 1 --lda 1 --stride_a 3 --ldb 1 --stride_b 4 --beta 0 --ldc 3 --stride_c 9 --batch_count 237900 - 2314 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB N -m 600 -n 1220 -k 64 --alpha 1 --lda 7680 --stride_a 64 --ldb 7680 --stride_b 64 --beta 0 --ldc 600 --stride_c 732000 --batch_count 120 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 2 -n 1 -k 2 --alpha 1 --lda 2 --stride_a 4 --ldb 1 --stride_b 2 --beta 0 --ldc 2 --stride_c 2 --batch_count 2880 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 2 -n 1 -k 2 --alpha 1 --lda 2 --stride_a 4 --ldb 1 --stride_b 2 --beta 0 --ldc 2 --stride_c 2 --batch_count 9000 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 11 --beta 0 --ldc 3 --stride_c 3 --batch_count 2880 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 11 --beta 0 --ldc 3 --stride_c 3 --batch_count 9000 - 1440 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 3 --beta 0 --ldc 3 --stride_c 3 --batch_count 237900 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 3 --beta 0 --ldc 3 --stride_c 3 --batch_count 2880 - 232 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 3 -n 1 -k 3 --alpha 1 --lda 3 --stride_a 9 --ldb 1 --stride_b 3 --beta 0 --ldc 3 --stride_c 3 --batch_count 9000 - 1440 ./rocblas-bench -f gemm_strided_batched -r f32_r --transposeA T --transposeB T -m 4 -n 1 -k 4 --alpha 1 --lda 4 --stride_a 16 --ldb 1 --stride_b 4 --beta 0 --ldc 4 --stride_c 4 --batch_count 1427400 diff --git a/docker-hub/Sparse4D/Sparse4D/start_sparse4d.sh b/docker-hub/Sparse4D/Sparse4D/start_sparse4d.sh deleted file mode 100755 index b224fb24d12d5744388f7abafe9ed7f2c7d217c5..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/start_sparse4d.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -export NCCL_TOPO_FILE=null -export NCCL_ALGO=Ring -export NCCL_RINGS="N0 0 7 6 5 4 3 2 1 N0|N1 1 2 3 4 5 6 7 0 N1|N2 2 1 0 7 6 5 4 3 N2|N3 3 4 5 6 7 0 1 2 N3|N4 4 3 2 1 0 7 6 5 N4|N5 5 6 7 0 1 2 3 4 N5|N6 6 5 4 3 2 1 0 7 N6|N7 7 0 1 2 3 4 5 6 N7" - -export PYTORCH_MIOPEN_SUGGEST_NHWC=1 -export MIOPEN_PRECISION_FP32_FP32_FP32_TF32_FP32=1 -export MIOPEN_FIND_MODE=1 -export ROCBLAS_MATH_MODE=1 - -export HSA_FORCE_FINE_GRAIN_PCIE=1 -#export LD_LIBRARY_PATH=/cfs/kehuan/haiguang/rocblas-install/lib/:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/cfs/kehuan/haiguang/miopen/lib/:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/cfs/auto/miopen_1110/lib:$LD_LIBRARY_PATH -export GPU_MAX_HW_QUEUES=10 - - -#export MIOPEN_ENABLE_LOGGING=1 # 打开MIOPEN LOGGING日志 default =0 -#export MIOPEN_ENABLE_LOGGING_CMD=1 # 输出日志CMD信息 default =0 -#export MIOPEN_LOG_LEVEL=6 # 设置日志打印level default=0 -#export ROCBLAS_LAYER=3 # 打开 rocblas输出日志 default=0 - - - -TIME=$(date "+%Y-%m-%d_%H_%M") - -MASTER_ADDR=${1:-localhost} -NNODES=${2:-1} -NODE_RANK=${3:-0} -CONFIG=${4:-projects/configs/sparse4dv3_temporal_r50_1x8_bs6_256x704.py} -bash tools/dist_train_numa.sh $MASTER_ADDR $NNODES $NODE_RANK $CONFIG \ - 2>&1 | tee cvm_bw1000_sparse4d_${NNODES}nodes_$TIME.log diff --git a/docker-hub/Sparse4D/Sparse4D/tools/dist_train.sh b/docker-hub/Sparse4D/Sparse4D/tools/dist_train.sh deleted file mode 100644 index 565905e2ffc6cdd391f148c45d9959b643090ebd..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/tools/dist_train.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -CONFIG=$1 -GPUS=$2 -PORT=${PORT:-28650} - -PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ -python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ - $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} diff --git a/docker-hub/Sparse4D/Sparse4D/tools/dist_train_numa.sh b/docker-hub/Sparse4D/Sparse4D/tools/dist_train_numa.sh deleted file mode 100644 index 97fa880a7f9508ca85e6081b0b73bd43ea536cff..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/tools/dist_train_numa.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -MASTER_ADDR=${1:-localhost} -MASTER_PORT=6000 -NNODES=${2:-1} -NODE_RANK=${3:-0} -GPUS_PER_NODE=8 -DISTRIBUTED_ARGS="--nproc_per_node $GPUS_PER_NODE --nnodes $NNODES --node_rank $NODE_RANK --master_addr $MASTER_ADDR --master_port $MASTER_PORT" - -CONFIG=$4 - -# add numa affinity config -PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ -torchrun $DISTRIBUTED_ARGS --no-python \ - bash -c 'numa_map=( $(hy-smi --showtopo | grep "Numa Node" | awk "{print \$6}") ); - LOCAL_RANK=${LOCAL_RANK:-0} - NUMA_ID=${numa_map[$LOCAL_RANK]} - numactl --cpunodebind=${NUMA_ID} --membind=${NUMA_ID} python $(dirname "$0")/tools/train.py "$@" - ' _ $CONFIG --launcher pytorch ${@:5} diff --git a/docker-hub/Sparse4D/Sparse4D/tools/train.py b/docker-hub/Sparse4D/Sparse4D/tools/train.py deleted file mode 100644 index ffee551ee677ca9a91b885a19677010e90d87a6c..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/Sparse4D/tools/train.py +++ /dev/null @@ -1,319 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from __future__ import division -import sys -import os - -print(sys.executable, os.path.abspath(__file__)) -# import init_paths # for conda pkgs submitting method -import argparse -import copy -import mmcv -import time -import torch -import warnings -from mmcv import Config, DictAction -from mmcv.runner import get_dist_info, init_dist -from os import path as osp - -from mmdet import __version__ as mmdet_version -from mmdet.apis import train_detector -from mmdet.datasets import build_dataset -from mmdet.models import build_detector -from mmdet.utils import collect_env, get_root_logger -from mmdet.apis import set_random_seed -from torch import distributed as dist -from datetime import timedelta - -import cv2 - -cv2.setNumThreads(8) - - -def parse_args(): - parser = argparse.ArgumentParser(description="Train a detector") - parser.add_argument("config", help="train config file path") - parser.add_argument("--work-dir", help="the dir to save logs and models") - parser.add_argument( - "--resume-from", help="the checkpoint file to resume from" - ) - parser.add_argument( - "--no-validate", - action="store_true", - help="whether not to evaluate the checkpoint during training", - ) - group_gpus = parser.add_mutually_exclusive_group() - group_gpus.add_argument( - "--gpus", - type=int, - help="number of gpus to use " - "(only applicable to non-distributed training)", - ) - group_gpus.add_argument( - "--gpu-ids", - type=int, - nargs="+", - help="ids of gpus to use " - "(only applicable to non-distributed training)", - ) - parser.add_argument("--seed", type=int, default=0, help="random seed") - parser.add_argument( - "--deterministic", - action="store_true", - help="whether to set deterministic options for CUDNN backend.", - ) - parser.add_argument( - "--options", - nargs="+", - action=DictAction, - help="override some settings in the used config, the key-value pair " - "in xxx=yyy format will be merged into config file (deprecate), " - "change to --cfg-options instead.", - ) - parser.add_argument( - "--cfg-options", - nargs="+", - action=DictAction, - help="override some settings in the used config, the key-value pair " - "in xxx=yyy format will be merged into config file. If the value to " - 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' - 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' - "Note that the quotation marks are necessary and that no white space " - "is allowed.", - ) - parser.add_argument( - "--dist-url", - type=str, - default="auto", - help="dist url for init process, such as tcp://localhost:8000", - ) - parser.add_argument("--gpus-per-machine", type=int, default=8) - parser.add_argument( - "--launcher", - choices=["none", "pytorch", "slurm", "mpi", "mpi_nccl"], - default="none", - help="job launcher", - ) - parser.add_argument("--local_rank", type=int, default=0) - parser.add_argument( - "--autoscale-lr", - action="store_true", - help="automatically scale lr with the number of gpus", - ) - args = parser.parse_args() - if "LOCAL_RANK" not in os.environ: - os.environ["LOCAL_RANK"] = str(args.local_rank) - - if args.options and args.cfg_options: - raise ValueError( - "--options and --cfg-options cannot be both specified, " - "--options is deprecated in favor of --cfg-options" - ) - if args.options: - warnings.warn("--options is deprecated in favor of --cfg-options") - args.cfg_options = args.options - - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - if args.cfg_options is not None: - cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get("custom_imports", None): - from mmcv.utils import import_modules_from_strings - - import_modules_from_strings(**cfg["custom_imports"]) - - # import modules from plguin/xx, registry will be updated - if hasattr(cfg, "plugin"): - if cfg.plugin: - import importlib - - if hasattr(cfg, "plugin_dir"): - plugin_dir = cfg.plugin_dir - _module_dir = os.path.dirname(plugin_dir) - _module_dir = _module_dir.split("/") - _module_path = _module_dir[0] - - for m in _module_dir[1:]: - _module_path = _module_path + "." + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - else: - # import dir is the dirpath for the config file - _module_dir = os.path.dirname(args.config) - _module_dir = _module_dir.split("/") - _module_path = _module_dir[0] - for m in _module_dir[1:]: - _module_path = _module_path + "." + m - print(_module_path) - plg_lib = importlib.import_module(_module_path) - from projects.mmdet3d_plugin.apis.train import custom_train_model - - # set cudnn_benchmark - #if cfg.get("cudnn_benchmark", False): - # torch.backends.cudnn.benchmark = True - torch.backends.cudnn.benchmark = True - - # work_dir is determined in this priority: CLI > segment in file > filename - if args.work_dir is not None: - # update configs according to CLI args if args.work_dir is not None - cfg.work_dir = args.work_dir - elif cfg.get("work_dir", None) is None: - # use config filename as default work_dir if cfg.work_dir is None - cfg.work_dir = osp.join( - "./work_dirs", osp.splitext(osp.basename(args.config))[0] - ) - if args.resume_from is not None: - cfg.resume_from = args.resume_from - if args.gpu_ids is not None: - cfg.gpu_ids = args.gpu_ids - else: - cfg.gpu_ids = range(1) if args.gpus is None else range(args.gpus) - - if args.autoscale_lr: - # apply the linear scaling rule (https://arxiv.org/abs/1706.02677) - cfg.optimizer["lr"] = cfg.optimizer["lr"] * len(cfg.gpu_ids) / 8 - - # init distributed env first, since logger depends on the dist info. - if args.launcher == "none": - distributed = False - elif args.launcher == "mpi_nccl": - distributed = True - - import mpi4py.MPI as MPI - - comm = MPI.COMM_WORLD - mpi_local_rank = comm.Get_rank() - mpi_world_size = comm.Get_size() - print( - "MPI local_rank=%d, world_size=%d" - % (mpi_local_rank, mpi_world_size) - ) - - # num_gpus = torch.cuda.device_count() - device_ids_on_machines = list(range(args.gpus_per_machine)) - str_ids = list(map(str, device_ids_on_machines)) - os.environ["CUDA_VISIBLE_DEVICES"] = ",".join(str_ids) - torch.cuda.set_device(mpi_local_rank % args.gpus_per_machine) - - dist.init_process_group( - backend="nccl", - init_method=args.dist_url, - world_size=mpi_world_size, - rank=mpi_local_rank, - timeout=timedelta(seconds=3600), - ) - - cfg.gpu_ids = range(mpi_world_size) - print("cfg.gpu_ids:", cfg.gpu_ids) - else: - distributed = True - init_dist( - args.launcher, timeout=timedelta(seconds=3600), **cfg.dist_params - ) - # re-set gpu_ids with distributed training mode - _, world_size = get_dist_info() - cfg.gpu_ids = range(world_size) - - # create work_dir - mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) - # dump config - cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config))) - # init the logger before other steps - timestamp = time.strftime("%Y%m%d_%H%M%S", time.localtime()) - log_file = osp.join(cfg.work_dir, f"{timestamp}.log") - # specify logger name, if we still use 'mmdet', the output info will be - # filtered and won't be saved in the log_file - # TODO: ugly workaround to judge whether we are training det or seg model - logger = get_root_logger( - log_file=log_file, log_level=cfg.log_level - ) - - # init the meta dict to record some important information such as - # environment info and seed, which will be logged - meta = dict() - # log env info - env_info_dict = collect_env() - env_info = "\n".join([(f"{k}: {v}") for k, v in env_info_dict.items()]) - dash_line = "-" * 60 + "\n" - logger.info( - "Environment info:\n" + dash_line + env_info + "\n" + dash_line - ) - meta["env_info"] = env_info - meta["config"] = cfg.pretty_text - - # log some basic info - logger.info(f"Distributed training: {distributed}") - logger.info(f"Config:\n{cfg.pretty_text}") - - # set random seeds - if args.seed is not None: - logger.info( - f"Set random seed to {args.seed}, " - f"deterministic: {args.deterministic}" - ) - set_random_seed(args.seed, deterministic=args.deterministic) - cfg.seed = args.seed - meta["seed"] = args.seed - meta["exp_name"] = osp.basename(args.config) - - model = build_detector( - cfg.model, train_cfg=cfg.get("train_cfg"), test_cfg=cfg.get("test_cfg") - ) - model.init_weights() - - logger.info(f"Model:\n{model}") - datasets = [build_dataset(cfg.data.train)] - if len(cfg.workflow) == 2: - val_dataset = copy.deepcopy(cfg.data.val) - # in case we use a dataset wrapper - if "dataset" in cfg.data.train: - val_dataset.pipeline = cfg.data.train.dataset.pipeline - else: - val_dataset.pipeline = cfg.data.train.pipeline - # set test_mode=False here in deep copied config - # which do not affect AP/AR calculation later - # refer to https://mmdetection3d.readthedocs.io/en/latest/tutorials/customize_runtime.html#customize-workflow # noqa - val_dataset.test_mode = False - datasets.append(build_dataset(val_dataset)) - if cfg.checkpoint_config is not None: - # save mmdet version, config file content and class names in - # checkpoints as meta data - cfg.checkpoint_config.meta = dict( - mmdet_version=mmdet_version, - config=cfg.pretty_text, - CLASSES=datasets[0].CLASSES, - ) - # add an attribute for visualization convenience - model.CLASSES = datasets[0].CLASSES - if hasattr(cfg, "plugin"): - custom_train_model( - model, - datasets, - cfg, - distributed=distributed, - validate=(not args.no_validate), - timestamp=timestamp, - meta=meta, - ) - else: - train_detector( - model, - datasets, - cfg, - distributed=distributed, - validate=(not args.no_validate), - timestamp=timestamp, - meta=meta, - ) - - -if __name__ == "__main__": - torch.multiprocessing.set_start_method( - "fork" - ) # use fork workers_per_gpu can be > 1 - main() diff --git a/docker-hub/Sparse4D/readme.md b/docker-hub/Sparse4D/readme.md deleted file mode 100644 index 8f275be98603654b7e5f37c502c9062dea150ca7..0000000000000000000000000000000000000000 --- a/docker-hub/Sparse4D/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# Sparse4D - -## 环境构建 - -``` - docker run -dit --network=host --name=Sparse4D --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal:/opt/hyhal:ro -v /public/opendas/DL_DATA/zijia:/data:ro harbor.sourcefind.cn:5443/dcu/admin/base/custom:pytorch2.5.1-driver-Sparse4D -``` - -数据集已完成处理在乌镇集群/public/opendas/DL_DATA/zijia路径内 - -## 代码执行 - -``` -## 代码已经在容器/workspace下了 -cd /workspace/Sparse4D -bash start_sparse4d.sh -``` - - - diff --git a/docker-hub/qwen2.5-vl/llama-factory/.dockerignore b/docker-hub/qwen2.5-vl/llama-factory/.dockerignore deleted file mode 100644 index bc56ab8bc41abac131b9d84e6f21a82f2a47ae08..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.dockerignore +++ /dev/null @@ -1,15 +0,0 @@ -.vscode -.git -.github -.venv -cache -data -docker -saves -hf_cache -ms_cache -om_cache -output -.dockerignore -.gitattributes -.gitignore diff --git a/docker-hub/qwen2.5-vl/llama-factory/.env.local b/docker-hub/qwen2.5-vl/llama-factory/.env.local deleted file mode 100644 index 88ac8a46f115203f1a3faaeae503f063062fbe0d..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.env.local +++ /dev/null @@ -1,42 +0,0 @@ -# Note: actually we do not support .env, just for reference -# api -API_HOST= -API_PORT= -API_KEY= -API_MODEL_NAME= -API_VERBOSE= -FASTAPI_ROOT_PATH= -MAX_CONCURRENT= -# general -DISABLE_VERSION_CHECK= -FORCE_CHECK_IMPORTS= -ALLOW_EXTRA_ARGS= -LLAMAFACTORY_VERBOSITY= -USE_MODELSCOPE_HUB= -USE_OPENMIND_HUB= -USE_RAY= -RECORD_VRAM= -OPTIM_TORCH= -NPU_JIT_COMPILE= -# torchrun -FORCE_TORCHRUN= -MASTER_ADDR= -MASTER_PORT= -NNODES= -NODE_RANK= -NPROC_PER_NODE= -# wandb -WANDB_DISABLED= -WANDB_PROJECT= -WANDB_API_KEY= -# gradio ui -GRADIO_SHARE= -GRADIO_SERVER_NAME= -GRADIO_SERVER_PORT= -GRADIO_ROOT_PATH= -GRADIO_IPV6= -# setup -ENABLE_SHORT_CONSOLE= -# reserved (do not use) -LLAMABOARD_ENABLED= -LLAMABOARD_WORKDIR= diff --git a/docker-hub/qwen2.5-vl/llama-factory/.gitattributes b/docker-hub/qwen2.5-vl/llama-factory/.gitattributes deleted file mode 100644 index dfe0770424b2a19faf507a501ebfc23be8f54e7b..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/docker-hub/qwen2.5-vl/llama-factory/.gitignore b/docker-hub/qwen2.5-vl/llama-factory/.gitignore deleted file mode 100644 index 603806e02651f93ab4d8c557f7cbac8bd92f24b5..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.gitignore +++ /dev/null @@ -1,178 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -.idea/ - -# vscode -.vscode/ - -# uv -uv.lock - -# custom .gitignore -ms_cache/ -hf_cache/ -om_cache/ -cache/ -config/ -saves/ -output/ -wandb/ -swanlog/ -generated_predictions.jsonl diff --git a/docker-hub/qwen2.5-vl/llama-factory/.pre-commit-config.yaml b/docker-hub/qwen2.5-vl/llama-factory/.pre-commit-config.yaml deleted file mode 100644 index cbe361eeb5ffb7dd31b9203b691316906f0b1fe8..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.pre-commit-config.yaml +++ /dev/null @@ -1,28 +0,0 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: check-ast - - id: check-added-large-files - args: ['--maxkb=25000'] - - id: check-merge-conflict - - id: check-yaml - - id: debug-statements - - id: end-of-file-fixer - - id: trailing-whitespace - args: [--markdown-linebreak-ext=md] - - id: no-commit-to-branch - args: ['--branch', 'main'] - -- repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 - hooks: - - id: pyupgrade - args: [--py38-plus] - -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 - hooks: - - id: ruff - args: [--fix] - - id: ruff-format diff --git a/docker-hub/qwen2.5-vl/llama-factory/.readthedocs.yaml b/docker-hub/qwen2.5-vl/llama-factory/.readthedocs.yaml deleted file mode 100644 index 3a9eaea1e817d8ee2413ef7ebaf585b654631d77..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/.readthedocs.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -version: 2 - -build: - os: ubuntu-22.04 - tools: - python: "3.8" - -sphinx: - configuration: docs/source/conf.py - -formats: - - pdf - -python: - install: - - requirements: docs/requirements-docs.txt diff --git a/docker-hub/qwen2.5-vl/llama-factory/=0.9.0 b/docker-hub/qwen2.5-vl/llama-factory/=0.9.0 deleted file mode 100644 index 3723ba98013893e8df8a7a30b711e3630ce52051..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/=0.9.0 +++ /dev/null @@ -1,96 +0,0 @@ -Requirement already satisfied: trl in /usr/local/lib/python3.10/dist-packages (1.0.0) -Requirement already satisfied: accelerate>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from trl) (1.6.0) -Collecting datasets>=4.7.0 (from trl) - Using cached datasets-4.8.4-py3-none-any.whl.metadata (19 kB) -Requirement already satisfied: packaging>20.0 in /usr/local/lib/python3.10/dist-packages (from trl) (25.0) -Collecting transformers>=4.56.2 (from trl) - Downloading transformers-5.5.0-py3-none-any.whl.metadata (32 kB) -Requirement already satisfied: numpy<3.0.0,>=1.17 in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (1.25.0) -Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (7.2.1) -Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (6.0.3) -Requirement already satisfied: torch>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (2.5.1+das.opt1.dtk25042.20260114.g7b1e7e04) -Requirement already satisfied: huggingface-hub>=0.21.0 in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (0.36.0) -Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.10/dist-packages (from accelerate>=1.4.0->trl) (0.7.0) -Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (3.20.3) -Requirement already satisfied: pyarrow>=21.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (22.0.0) -Requirement already satisfied: dill<0.4.2,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (0.3.8) -Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (2.3.3) -Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (2.32.5) -Requirement already satisfied: httpx<1.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (0.28.1) -Requirement already satisfied: tqdm>=4.66.3 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (4.67.1) -Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (3.6.0) -Requirement already satisfied: multiprocess<0.70.20 in /usr/local/lib/python3.10/dist-packages (from datasets>=4.7.0->trl) (0.70.16) -Requirement already satisfied: fsspec<=2026.2.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (2024.12.0) -Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (3.13.3) -Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx<1.0.0->datasets>=4.7.0->trl) (4.12.1) -Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1.0.0->datasets>=4.7.0->trl) (2026.1.4) -Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1.0.0->datasets>=4.7.0->trl) (1.0.9) -Requirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx<1.0.0->datasets>=4.7.0->trl) (3.11) -Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1.0.0->datasets>=4.7.0->trl) (0.16.0) -Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.21.0->accelerate>=1.4.0->trl) (4.15.0) -Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.21.0->accelerate>=1.4.0->trl) (1.2.0) -Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (2.6.1) -Requirement already satisfied: aiosignal>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (1.4.0) -Requirement already satisfied: async-timeout<6.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (5.0.1) -Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (25.4.0) -Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (1.8.0) -Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (6.7.0) -Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (0.4.1) -Requirement already satisfied: yarl<2.0,>=1.17.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.2.0,>=2023.1.0->datasets>=4.7.0->trl) (1.22.0) -Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets>=4.7.0->trl) (3.4.4) -Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets>=4.7.0->trl) (2.6.3) -Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=2.0.0->accelerate>=1.4.0->trl) (3.4.2) -Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=2.0.0->accelerate>=1.4.0->trl) (3.1.6) -Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.10/dist-packages (from torch>=2.0.0->accelerate>=1.4.0->trl) (1.13.1) -Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy==1.13.1->torch>=2.0.0->accelerate>=1.4.0->trl) (1.3.0) -Collecting huggingface-hub>=0.21.0 (from accelerate>=1.4.0->trl) - Downloading huggingface_hub-1.9.1-py3-none-any.whl.metadata (14 kB) -Requirement already satisfied: regex>=2025.10.22 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.56.2->trl) (2026.1.15) -Collecting tokenizers<=0.23.0,>=0.22.0 (from transformers>=4.56.2->trl) - Downloading tokenizers-0.22.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.3 kB) -Requirement already satisfied: typer in /usr/local/lib/python3.10/dist-packages (from transformers>=4.56.2->trl) (0.21.1) -Collecting hf-xet<2.0.0,>=1.4.3 (from huggingface-hub>=0.21.0->accelerate>=1.4.0->trl) - Downloading hf_xet-1.4.3-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (4.9 kB) -Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx<1.0.0->datasets>=4.7.0->trl) (1.3.1) -Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=2.0.0->accelerate>=1.4.0->trl) (3.0.3) -Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets>=4.7.0->trl) (2.9.0.post0) -Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets>=4.7.0->trl) (2025.2) -Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets>=4.7.0->trl) (2025.3) -Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->datasets>=4.7.0->trl) (1.16.0) -Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer->transformers>=4.56.2->trl) (8.2.1) -Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer->transformers>=4.56.2->trl) (1.5.4) -Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer->transformers>=4.56.2->trl) (14.2.0) -Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer->transformers>=4.56.2->trl) (4.0.0) -Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer->transformers>=4.56.2->trl) (2.19.2) -Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer->transformers>=4.56.2->trl) (0.1.2) -Using cached datasets-4.8.4-py3-none-any.whl (526 kB) -Downloading transformers-5.5.0-py3-none-any.whl (10.2 MB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.2/10.2 MB 25.1 MB/s 0:00:00 -Downloading huggingface_hub-1.9.1-py3-none-any.whl (637 kB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 637.4/637.4 kB 81.7 MB/s 0:00:00 -Downloading hf_xet-1.4.3-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.2 MB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 47.1 MB/s 0:00:00 -Downloading tokenizers-0.22.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 40.0 MB/s 0:00:00 -Installing collected packages: hf-xet, huggingface-hub, tokenizers, datasets, transformers - Attempting uninstall: hf-xet - Found existing installation: hf-xet 1.2.0 - Uninstalling hf-xet-1.2.0: - Successfully uninstalled hf-xet-1.2.0 - Attempting uninstall: huggingface-hub - Found existing installation: huggingface-hub 0.36.0 - Uninstalling huggingface-hub-0.36.0: - Successfully uninstalled huggingface-hub-0.36.0 - Attempting uninstall: tokenizers - Found existing installation: tokenizers 0.21.4 - Uninstalling tokenizers-0.21.4: - Successfully uninstalled tokenizers-0.21.4 - Attempting uninstall: datasets - Found existing installation: datasets 3.5.0 - Uninstalling datasets-3.5.0: - Successfully uninstalled datasets-3.5.0 - Attempting uninstall: transformers - Found existing installation: transformers 4.50.0 - Uninstalling transformers-4.50.0: - Successfully uninstalled transformers-4.50.0 - diff --git a/docker-hub/qwen2.5-vl/llama-factory/=2.16.0, b/docker-hub/qwen2.5-vl/llama-factory/=2.16.0, deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/docker-hub/qwen2.5-vl/llama-factory/CITATION.cff b/docker-hub/qwen2.5-vl/llama-factory/CITATION.cff deleted file mode 100644 index 01b4c9fd28aed295d50c71a7a3ed2e97a69434d4..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/CITATION.cff +++ /dev/null @@ -1,44 +0,0 @@ -cff-version: 1.2.0 -date-released: 2024-03 -message: "If you use this software, please cite it as below." -authors: -- family-names: "Zheng" - given-names: "Yaowei" -- family-names: "Zhang" - given-names: "Richong" -- family-names: "Zhang" - given-names: "Junhao" -- family-names: "Ye" - given-names: "Yanhan" -- family-names: "Luo" - given-names: "Zheyan" -- family-names: "Feng" - given-names: "Zhangchi" -- family-names: "Ma" - given-names: "Yongqiang" -title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models" -url: "https://arxiv.org/abs/2403.13372" -preferred-citation: - type: conference-paper - conference: - name: "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)" - authors: - - family-names: "Zheng" - given-names: "Yaowei" - - family-names: "Zhang" - given-names: "Richong" - - family-names: "Zhang" - given-names: "Junhao" - - family-names: "Ye" - given-names: "Yanhan" - - family-names: "Luo" - given-names: "Zheyan" - - family-names: "Feng" - given-names: "Zhangchi" - - family-names: "Ma" - given-names: "Yongqiang" - title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models" - url: "https://arxiv.org/abs/2403.13372" - year: 2024 - publisher: "Association for Computational Linguistics" - address: "Bangkok, Thailand" diff --git a/docker-hub/qwen2.5-vl/llama-factory/LICENSE b/docker-hub/qwen2.5-vl/llama-factory/LICENSE deleted file mode 100644 index b09cd7856d58590578ee1a4f3ad45d1310a97f87..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/docker-hub/qwen2.5-vl/llama-factory/MANIFEST.in b/docker-hub/qwen2.5-vl/llama-factory/MANIFEST.in deleted file mode 100644 index 82c51f6348a58f9da0c839a61b0063b9aba66d75..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include LICENSE requirements.txt diff --git a/docker-hub/qwen2.5-vl/llama-factory/Makefile b/docker-hub/qwen2.5-vl/llama-factory/Makefile deleted file mode 100644 index 2dcb7caf69b3b85b0c143dc62d2053515a5346a1..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -.PHONY: build commit license quality style test - -check_dirs := scripts src tests setup.py - -build: - pip3 install build && python3 -m build - -commit: - pre-commit install - pre-commit run --all-files - -license: - python3 tests/check_license.py $(check_dirs) - -quality: - ruff check $(check_dirs) - ruff format --check $(check_dirs) - -style: - ruff check $(check_dirs) --fix - ruff format $(check_dirs) - -test: - CUDA_VISIBLE_DEVICES= WANDB_DISABLED=true pytest -vv tests/ diff --git a/docker-hub/qwen2.5-vl/llama-factory/README.md b/docker-hub/qwen2.5-vl/llama-factory/README.md deleted file mode 100644 index 07eb4ec71497000096de7de549d4f9f588c3c09b..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/README.md +++ /dev/null @@ -1,266 +0,0 @@ -#
LLaMA Factory
-## 简介 - -LLaMA Factory是一个大语言模型训练和推理的框架,支持了魔搭社区(ModelScope)的模型和数据集资源。它允许用户通过内置的Web UI灵活定制100多个LLMs的微调,而无需编写代码。 - -## 项目特色 - -- **多种模型**:LLaMA、LLaVA、Mistral、Mixtral-MoE、Qwen、Yi、Gemma、Baichuan、ChatGLM、Phi 等等。 -- **集成方法**:(增量)预训练、(多模态)指令监督微调、奖励模型训练、PPO 训练、DPO 训练、KTO 训练、ORPO 训练等等。 -- **多种精度**:16 比特全参数微调、冻结微调、LoRA 微调和基于 AQLM/AWQ/GPTQ/LLM.int8/HQQ/EETQ 的 2/3/4/5/6/8 比特 QLoRA 微调。 -- **先进算法**:GaLore、BAdam、Adam-mini、DoRA、LongLoRA、LLaMA Pro、Mixture-of-Depths、LoRA+、LoftQ、PiSSA 和 Agent 微调。 -- **实用技巧**:FlashAttention-2、Unsloth、RoPE scaling、NEFTune 和 rsLoRA。 -- **实验监控**:LlamaBoard、TensorBoard、Wandb、MLflow 等等。 -- **极速推理**:基于 vLLM 的 OpenAI 风格 API、浏览器界面和命令行接口。 - -## 支持模型结构列表 - - -| 模型名 | 参数量 | Template | -| ----------------------------------------------------------------- | -------------------------------- | ------------------- | -| [Baichuan 2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 | -| [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 | -| [DeepSeek (Code/MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek | -| [DeepSeek 2.5/3](https://huggingface.co/deepseek-ai) | 236B/671B | deepseek3 | -| [DeepSeek R1 (Distill)](https://huggingface.co/deepseek-ai) | 1.5B/7B/8B/14B/32B/70B/671B | deepseekr1 | -| [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma | -| [Gemma 3](https://huggingface.co/google) | 1B/4B/12B/27B | gemma3/gemma (1B) | -| [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/THUDM)** | 9B/32B | glm4 | -| [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | -| [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | -| [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 | -| [InternVL 2.5-3](https://huggingface.co/OpenGVLab) | 1B/2B/8B/14B/38B/78B | intern_vl | -| [Llama 2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 | -| [Llama 3-3.3](https://huggingface.co/meta-llama) | 1B/3B/8B/70B | llama3 | -| [Llama 4](https://huggingface.co/meta-llama) | 109B/402B | llama4 | -| [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral | -| [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral | -| [Mistral Small](https://huggingface.co/mistralai) | 24B | mistral_small | -| [OLMo](https://hf-mirror.com/allenai) | 1B/7B | olmo | -| [Qwen (1-2.5) (Code/Math/MoE/QwQ)](https://huggingface.co/Qwen) | 0.5B/1.5B/3B/7B/14B/32B/72B/110B | qwen | -| [Qwen3 (MoE)](https://huggingface.co/Qwen) | 0.6B/1.7B/4B/8B/14B/32B/235B | qwen3 | -| [XVERSE](https://hf-mirror.com/xverse) | 7B/13B | xverse | - -持续更新中... - -> **[!NOTE]** -> -> 对于所有“基座”(Base)模型,`template` 参数可以是 `default`, `alpaca`, `vicuna` 等任意值。但“对话”(Instruct/Chat)模型请务必使用**对应的模板**。 -> -> 请务必在训练和推理时采用**完全一致**的模板。 -> 您也可以在 [template.py](src/llamafactory/data/template.py) 中添加自己的对话模板。 -> - -> **已知问题及解决方案** -> 1. `Baichuan 2` 需要卸载掉环境中的xformers库,当前仅支持Lora方式训练。 -> -> 2. `XVERSE`在`tokenizer > 0.19`的版本下有兼容性问题报错`Exception: data did not match any variant of untagged enum PyPreTokenizerTypeWrappe`,需要使用[XVERSE-13B-256K-hf](https://huggingface.co/xverse/XVERSE-13B-256K/tree/main)中的`tokenizer_config.json.update`/`tokenizer.json.update`替换原有模型文件中的对应tokenizer文件,具体解决方法参考[xverse-ai/XVERSE-7B issues](https://github.com/xverse-ai/XVERSE-7B/issues/1) -> -> 3. `Qwen2`训练仅支持bf16格式,**fp16会出现loss为0,lr为0的问题**,参考[issues](https://github.com/hiyouga/LLaMA-Factory/issues/4848) -> -> 4. `deepspeed-cpu-offload-stage3`出现`RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!`错误,是deepspeed本身bug,解决办法参考官方[issuse](https://github.com/microsoft/DeepSpeed/issues/5634) -> -> 5. `TypeError: argument of type 'NoneType' is not iterable`错误是官方transformers版本问题,参考[issuse](https://github.com/huggingface/transformers/pull/38328) -> -> \*:您需要从 main 分支安装 `transformers` 并使用 `DISABLE_VERSION_CHECK=1` 来跳过版本检查。 -> -> \*\*:您需要安装特定版本的 `transformers` 以使用该模型,如**GLM4需要transformers==4.51.3** - -## 使用源码编译方式安装 -### 环境准备 - -`-v 路径`、`docker_name`和`imageID`根据实际情况修改 - -#### Docker(方法一) - -基于光源pytorch2.4.1基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch2.4.1、python、dtk及系统下载对应的镜像版本。 - -```bash -docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04-py3.10 -docker run -it --shm-size 200g --network=host --name {docker_name} --privileged --device=/dev/kfd --device=/dev/dri --device=/dev/mkfd --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal/:/opt/hyhal/:ro {imageID} bash - -cd /your_code_path/llama_factory -pip install -e ".[torch,metrics]" --no-build-isolation -``` - -#### Dockerfile(方法二) - -```bash -cd docker -docker build --no-cache -t llama-factory:latest . -docker run -it --shm-size 200g --network=host --name {docker_name} --privileged --device=/dev/kfd --device=/dev/dri --device=/dev/mkfd --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal/:/opt/hyhal/:ro {imageID} bash - -cd /your_code_path/llama_factory -pip install -e ".[torch,metrics]" --no-build-isolation -``` - -#### Anaconda(方法三) - -关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.hpccube.com/tool/)开发者社区下载安装。 -```bash -DTK: 25.04 -python: 3.10 -torch: 2.4.1 -vllm: ≥0.4.3 -deepspeed: 0.14.2+das.opt2.dtk2504 -``` -`Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应` - -### 源码编译安装 - -> [!TIP] -> 遇到包冲突时,可使用 `pip install --no-deps -e .` 解决。 - -```bash -git clone http://developer.hpccube.com/codes/OpenDAS/llama-factory.git -cd /your_code_path/llama_factory -pip install -e ".[torch,metrics]" --no-build-isolation - -# (可选)deepspeed多机训练 -# pdsh安装,若已安装,可忽略。 -# 安装需要root权限 -cd ../ -#下载解压 -wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pdsh/pdsh-2.29.tar.bz2 && tar -xf pdsh-2.29.tar.bz2 -#编译安装 -cd pdsh-2.29 && ./configure --with-ssh --enable-static-modules --prefix=/usr/local && make && make install -#测试 -pdsh -V -``` - -## 数据集 - -
预训练数据集 - -- [Wiki Demo (en)](data/wiki_demo.txt) -- [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) -- [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2) -- [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220) -- [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered) -- [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile) -- [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B) -- [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb) -- [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) -- [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack) -- [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata) - -
- -
指令微调数据集 - -- [Identity (en&zh)](data/identity.json) -- [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca) -- [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3) -- [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM) -- [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) -- [LIMA (en)](https://huggingface.co/datasets/GAIR/lima) -- [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset) -- [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN) -- [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN) -- [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN) -- [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M) -- [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M) -- [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M) -- [UltraChat (en)](https://github.com/thunlp/UltraChat) -- [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus) -- [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k) -- [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT) -- [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca) -- [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca) -- [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) -- [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M) -- [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa) -- [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa) -- [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data) -- [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen) -- [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k) -- [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4) -- [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) -- [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct) -- [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) -- [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k) -- [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia) -- [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction) -- [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo) -- [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2) -- [Magpie-Pro-300K-Filtered (en)](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-300K-Filtered) -- [Magpie-ultra-v0.1 (en)](https://huggingface.co/datasets/argilla/magpie-ultra-v0.1) -- [WebInstructSub (en)](https://huggingface.co/datasets/TIGER-Lab/WebInstructSub) -- [OpenO1-SFT (en&zh)](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT) -- [Open-Thoughts (en)](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) -- [Open-R1-Math (en)](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) -- [Chinese-DeepSeek-R1-Distill (zh)](https://huggingface.co/datasets/Congliu/Chinese-DeepSeek-R1-Distill-data-110k-SFT) -- [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k) -- [Pokemon-gpt4o-captions (en&zh)](https://huggingface.co/datasets/jugg1024/pokemon-gpt4o-captions) -- [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de) -- [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de) -- [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de) -- [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de) -- [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de) -- [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de) -- [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de) -- [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de) -- [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de) - -
- -
偏好数据集 - -- [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k) -- [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized) -- [COIG-P (en&zh)](https://huggingface.co/datasets/m-a-p/COIG-P) -- [RLHF-V (en)](https://huggingface.co/datasets/openbmb/RLHF-V-Dataset) -- [VLFeedback (en)](https://huggingface.co/datasets/Zhihui/VLFeedback) -- [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs) -- [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de) -- [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k) - -
- - -部分数据集的使用需要确认,我们推荐使用下述命令登录您的 Hugging Face 账户。 - -```bash -pip install --upgrade huggingface_hub -huggingface-cli login -``` - -### 数据准备 - -关于数据集文件的格式,请参考 [data/README_zh.md](data/README_zh.md) 的内容。你可以使用 HuggingFace / ModelScope 上的数据集或加载本地数据集。 - -> [!NOTE] -> 使用自定义数据集时,请更新 `data/dataset_info.json` 文件。 - -## 如何使用 -### 快速开始 - -下面三行命令分别对 Llama3-8B-Instruct 模型进行 LoRA **微调**、**推理**和**合并**。根据实际情况修改参数,如`model_name_or_path`/`dataset`/`template`等。 - -```bash -llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml -llamafactory-cli chat examples/inference/llama3_lora_sft.yaml -llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml -``` - -高级用法请参考 [examples/README_zh.md](examples/README_zh.md)(包括多 GPU 微调)。 - -> [!TIP] -> 使用 `llamafactory-cli help` 显示帮助信息。 -> -> 自有数据集推理精度验证方法推荐使用:`python scripts/vllm_infer.py`生成结果,`python scripts/eval_bleu_rouge.py`计算得分,具体参数信息请参考脚本内容。 - -### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动) - -```bash -llamafactory-cli webui -``` - -## 参考资料 - -- [README_zh](README_zh.md) -- [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) diff --git a/docker-hub/qwen2.5-vl/llama-factory/README_en.md b/docker-hub/qwen2.5-vl/llama-factory/README_en.md deleted file mode 100644 index d7f8ae85424b19a038a0d1e8e5ba09d1da66f8d0..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/README_en.md +++ /dev/null @@ -1,948 +0,0 @@ -![# LLaMA Factory](assets/logo.png) - -[![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/LLaMA-Factory?style=social)](https://github.com/hiyouga/LLaMA-Factory/stargazers) -[![GitHub last commit](https://img.shields.io/github/last-commit/hiyouga/LLaMA-Factory)](https://github.com/hiyouga/LLaMA-Factory/commits/main) -[![GitHub contributors](https://img.shields.io/github/contributors/hiyouga/LLaMA-Factory?color=orange)](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors) -[![GitHub workflow](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml/badge.svg)](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml) -[![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/) -[![Citation](https://img.shields.io/badge/citation-651-green)](https://scholar.google.com/scholar?cites=12620864006390196564) -[![Docker Pulls](https://img.shields.io/docker/pulls/hiyouga/llamafactory)](https://hub.docker.com/r/hiyouga/llamafactory/tags) - -[![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai) -[![Discord](https://dcbadge.vercel.app/api/server/rKfvV9r9FK?compact=true&style=flat)](https://discord.gg/rKfvV9r9FK) -[![GitCode](https://gitcode.com/zhengyaowei/LLaMA-Factory/star/badge.svg)](https://gitcode.com/zhengyaowei/LLaMA-Factory) - -[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing) -[![Open in DSW](https://gallery.pai-ml.com/assets/open-in-dsw.svg)](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory) -[![Open in Alaya](assets/alaya_new.svg)](https://docs.alayanew.com/docs/documents/newActivities/llamafactory/?utm_source=LLaMA-Factory) -[![Open in Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/hiyouga/LLaMA-Board) -[![Open in Studios](https://img.shields.io/badge/ModelScope-Open%20in%20Studios-blue)](https://modelscope.cn/studios/hiyouga/LLaMA-Board) -[![Open in Novita](https://img.shields.io/badge/Novita-Deploy%20Template-blue)](https://novita.ai/templates-library/105981?sharer=88115474-394e-4bda-968e-b88e123d0c47) - -### Used by [Amazon](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/), [NVIDIA](https://developer.nvidia.com/rtx/ai-toolkit), [Aliyun](https://help.aliyun.com/zh/pai/use-cases/fine-tune-a-llama-3-model-with-llama-factory), etc. - -
- -### Supporters ❤️ - - - Warp sponsorship - - -#### [Warp, the agentic terminal for developers](https://warp.dev/llama-factory) - -[Available for MacOS, Linux, & Windows](https://warp.dev/llama-factory) - ----- - -### Easily fine-tune 100+ large language models with zero-code [CLI](#quickstart) and [Web UI](#fine-tuning-with-llama-board-gui-powered-by-gradio) - -![GitHub Trend](https://trendshift.io/api/badge/repositories/4535) - -
- -👋 Join our [WeChat group](assets/wechat.jpg), [NPU user group](assets/wechat_npu.jpg) or [Alaya NeW user group](assets/wechat_alaya.png). - -\[ English | [中文](README_zh.md) \] - -**Fine-tuning a large language model can be easy as...** - -https://github.com/user-attachments/assets/3991a3a8-4276-4d30-9cab-4cb0c4b9b99e - -Choose your path: - -- **Documentation (WIP)**: https://llamafactory.readthedocs.io/en/latest/ -- **Documentation (AMD GPU)**: https://rocm.docs.amd.com/projects/ai-developer-hub/en/latest/notebooks/fine_tune/llama_factory_llama3.html -- **Colab (free)**: https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing -- **Local machine**: Please refer to [usage](#getting-started) -- **PAI-DSW (free trial)**: https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory -- **Alaya NeW (cloud GPU deal)**: https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory - -> [!NOTE] -> Except for the above links, all other websites are unauthorized third-party websites. Please carefully use them. - -## Table of Contents - -- [Features](#features) -- [Blogs](#blogs) -- [Changelog](#changelog) -- [Supported Models](#supported-models) -- [Supported Training Approaches](#supported-training-approaches) -- [Provided Datasets](#provided-datasets) -- [Requirement](#requirement) -- [Getting Started](#getting-started) - - [Installation](#installation) - - [Data Preparation](#data-preparation) - - [Quickstart](#quickstart) - - [Fine-Tuning with LLaMA Board GUI](#fine-tuning-with-llama-board-gui-powered-by-gradio) - - [Build Docker](#build-docker) - - [Deploy with OpenAI-style API and vLLM](#deploy-with-openai-style-api-and-vllm) - - [Download from ModelScope Hub](#download-from-modelscope-hub) - - [Download from Modelers Hub](#download-from-modelers-hub) - - [Use W&B Logger](#use-wb-logger) - - [Use SwanLab Logger](#use-swanlab-logger) -- [Projects using LLaMA Factory](#projects-using-llama-factory) -- [License](#license) -- [Citation](#citation) -- [Acknowledgement](#acknowledgement) - -## Features - -- **Various models**: LLaMA, LLaVA, Mistral, Mixtral-MoE, Qwen, Qwen2-VL, DeepSeek, Yi, Gemma, ChatGLM, Phi, etc. -- **Integrated methods**: (Continuous) pre-training, (multimodal) supervised fine-tuning, reward modeling, PPO, DPO, KTO, ORPO, etc. -- **Scalable resources**: 16-bit full-tuning, freeze-tuning, LoRA and 2/3/4/5/6/8-bit QLoRA via AQLM/AWQ/GPTQ/LLM.int8/HQQ/EETQ. -- **Advanced algorithms**: [GaLore](https://github.com/jiaweizzhao/GaLore), [BAdam](https://github.com/Ledzy/BAdam), [APOLLO](https://github.com/zhuhanqing/APOLLO), [Adam-mini](https://github.com/zyushun/Adam-mini), [Muon](https://github.com/KellerJordan/Muon), DoRA, LongLoRA, LLaMA Pro, Mixture-of-Depths, LoRA+, LoftQ and PiSSA. -- **Practical tricks**: [FlashAttention-2](https://github.com/Dao-AILab/flash-attention), [Unsloth](https://github.com/unslothai/unsloth), [Liger Kernel](https://github.com/linkedin/Liger-Kernel), RoPE scaling, NEFTune and rsLoRA. -- **Wide tasks**: Multi-turn dialogue, tool using, image understanding, visual grounding, video recognition, audio understanding, etc. -- **Experiment monitors**: LlamaBoard, TensorBoard, Wandb, MLflow, [SwanLab](https://github.com/SwanHubX/SwanLab), etc. -- **Faster inference**: OpenAI-style API, Gradio UI and CLI with [vLLM worker](https://github.com/vllm-project/vllm) or [SGLang worker](https://github.com/sgl-project/sglang). - -### Day-N Support for Fine-Tuning Cutting-Edge Models - -| Support Date | Model Name | -| ------------ | -------------------------------------------------------------------- | -| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM-4.1V / InternLM 3 / MiniCPM-o-2.6 | -| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | - -## Blogs - -- [A One-Stop Code-Free Model Reinforcement Learning and Deployment Platform based on LLaMA-Factory and EasyR1](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/) (Chinese) -- [Fine-tune Qwen2.5-VL for Autonomous Driving using LLaMA-Factory](https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory) (Chinese) -- [How Apoidea Group enhances visual information extraction from banking documents with multimodal models using LLaMA-Factory on Amazon SageMaker HyperPod](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/) (English) -- [Easy Dataset × LLaMA Factory: Enabling LLMs to Efficiently Learn Domain Knowledge](https://buaa-act.feishu.cn/wiki/GVzlwYcRFiR8OLkHbL6cQpYin7g) (English) - -
All Blogs - -- [LLaMA Factory: Fine-tuning the DeepSeek-R1-Distill-Qwen-7B Model for News Classifier](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b) (Chinese) -- [A One-Stop Code-Free Model Fine-Tuning \& Deployment Platform based on SageMaker and LLaMA-Factory](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/) (Chinese) -- [LLaMA Factory Multi-Modal Fine-Tuning Practice: Fine-Tuning Qwen2-VL for Personal Tourist Guide](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl) (Chinese) -- [LLaMA Factory: Fine-tuning the LLaMA3 Model for Role-Playing](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory) (Chinese) - -
- -## Changelog - -[25/07/02] We supported fine-tuning the **[GLM-4.1V-9B-Thinking](https://github.com/THUDM/GLM-4.1V-Thinking)** model. Please install transformers from **main** branch to use. - -[25/04/28] We supported fine-tuning the **[Qwen3](https://qwenlm.github.io/blog/qwen3/)** model family. - -[25/04/21] We supported the **[Muon](https://github.com/KellerJordan/Muon)** optimizer. See [examples](examples/README.md) for usage. Thank [@tianshijing](https://github.com/tianshijing)'s PR. - -[25/04/16] We supported fine-tuning the **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** model. See [PR #7258](https://github.com/hiyouga/LLaMA-Factory/pull/7258) to get started. - -[25/04/14] We supported fine-tuning the **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** and **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** models. - -[25/04/06] We supported fine-tuning the **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** model. See [PR #7611](https://github.com/hiyouga/LLaMA-Factory/pull/7611) to get started. - -
Full Changelog - -[25/03/31] We supported fine-tuning the **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** model. See [PR #7537](https://github.com/hiyouga/LLaMA-Factory/pull/7537) to get started. - -[25/03/15] We supported **[SGLang](https://github.com/sgl-project/sglang)** as inference backend. Try `infer_backend: sglang` to accelerate inference. - -[25/03/12] We supported fine-tuning the **[Gemma 3](https://huggingface.co/blog/gemma3)** model. - -[25/02/24] Announcing **[EasyR1](https://github.com/hiyouga/EasyR1)**, an efficient, scalable and multi-modality RL training framework for efficient GRPO training. - -[25/02/11] We supported saving the **[Ollama](https://github.com/ollama/ollama)** modelfile when exporting the model checkpoints. See [examples](examples/README.md) for usage. - -[25/02/05] We supported fine-tuning the **[Qwen2-Audio](Qwen/Qwen2-Audio-7B-Instruct)** and **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** on audio understanding tasks. - -[25/01/31] We supported fine-tuning the **[DeepSeek-R1](https://huggingface.co/deepseek-ai/DeepSeek-R1)** and **[Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)** models. - -[25/01/15] We supported **[APOLLO](https://arxiv.org/abs/2412.05270)** optimizer. See [examples](examples/README.md) for usage. - -[25/01/14] We supported fine-tuning the **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** and **[MiniCPM-V-2.6](https://huggingface.co/openbmb/MiniCPM-V-2_6)** models. Thank [@BUAADreamer](https://github.com/BUAADreamer)'s PR. - -[25/01/14] We supported fine-tuning the **[InternLM 3](https://huggingface.co/collections/internlm/)** models. Thank [@hhaAndroid](https://github.com/hhaAndroid)'s PR. - -[25/01/10] We supported fine-tuning the **[Phi-4](https://huggingface.co/microsoft/phi-4)** model. - -[24/12/21] We supported using **[SwanLab](https://github.com/SwanHubX/SwanLab)** for experiment tracking and visualization. See [this section](#use-swanlab-logger) for details. - -[24/11/27] We supported fine-tuning the **[Skywork-o1](https://huggingface.co/Skywork/Skywork-o1-Open-Llama-3.1-8B)** model and the **[OpenO1](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT)** dataset. - -[24/10/09] We supported downloading pre-trained models and datasets from the **[Modelers Hub](https://modelers.cn/models)**. See [this tutorial](#download-from-modelers-hub) for usage. - -[24/09/19] We supported fine-tuning the **[Qwen2.5](https://qwenlm.github.io/blog/qwen2.5/)** models. - -[24/08/30] We supported fine-tuning the **[Qwen2-VL](https://qwenlm.github.io/blog/qwen2-vl/)** models. Thank [@simonJJJ](https://github.com/simonJJJ)'s PR. - -[24/08/27] We supported **[Liger Kernel](https://github.com/linkedin/Liger-Kernel)**. Try `enable_liger_kernel: true` for efficient training. - -[24/08/09] We supported **[Adam-mini](https://github.com/zyushun/Adam-mini)** optimizer. See [examples](examples/README.md) for usage. Thank [@relic-yuexi](https://github.com/relic-yuexi)'s PR. - -[24/07/04] We supported [contamination-free packed training](https://github.com/MeetKai/functionary/tree/main/functionary/train/packing). Use `neat_packing: true` to activate it. Thank [@chuan298](https://github.com/chuan298)'s PR. - -[24/06/16] We supported **[PiSSA](https://arxiv.org/abs/2404.02948)** algorithm. See [examples](examples/README.md) for usage. - -[24/06/07] We supported fine-tuning the **[Qwen2](https://qwenlm.github.io/blog/qwen2/)** and **[GLM-4](https://github.com/THUDM/GLM-4)** models. - -[24/05/26] We supported **[SimPO](https://arxiv.org/abs/2405.14734)** algorithm for preference learning. See [examples](examples/README.md) for usage. - -[24/05/20] We supported fine-tuning the **PaliGemma** series models. Note that the PaliGemma models are pre-trained models, you need to fine-tune them with `paligemma` template for chat completion. - -[24/05/18] We supported **[KTO](https://arxiv.org/abs/2402.01306)** algorithm for preference learning. See [examples](examples/README.md) for usage. - -[24/05/14] We supported training and inference on the Ascend NPU devices. Check [installation](#installation) section for details. - -[24/04/26] We supported fine-tuning the **LLaVA-1.5** multimodal LLMs. See [examples](examples/README.md) for usage. - -[24/04/22] We provided a **[Colab notebook](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing)** for fine-tuning the Llama-3 model on a free T4 GPU. Two Llama-3-derived models fine-tuned using LLaMA Factory are available at Hugging Face, check [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) and [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese) for details. - -[24/04/21] We supported **[Mixture-of-Depths](https://arxiv.org/abs/2404.02258)** according to [AstraMindAI's implementation](https://github.com/astramind-ai/Mixture-of-depths). See [examples](examples/README.md) for usage. - -[24/04/16] We supported **[BAdam](https://arxiv.org/abs/2404.02827)** optimizer. See [examples](examples/README.md) for usage. - -[24/04/16] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s long-sequence training (Llama-2-7B-56k within 24GB). It achieves **117%** speed and **50%** memory compared with FlashAttention-2, more benchmarks can be found in [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison). - -[24/03/31] We supported **[ORPO](https://arxiv.org/abs/2403.07691)**. See [examples](examples/README.md) for usage. - -[24/03/21] Our paper "[LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models](https://arxiv.org/abs/2403.13372)" is available at arXiv! - -[24/03/20] We supported **FSDP+QLoRA** that fine-tunes a 70B model on 2x24GB GPUs. See [examples](examples/README.md) for usage. - -[24/03/13] We supported **[LoRA+](https://arxiv.org/abs/2402.12354)**. See [examples](examples/README.md) for usage. - -[24/03/07] We supported **[GaLore](https://arxiv.org/abs/2403.03507)** optimizer. See [examples](examples/README.md) for usage. - -[24/03/07] We integrated **[vLLM](https://github.com/vllm-project/vllm)** for faster and concurrent inference. Try `infer_backend: vllm` to enjoy **270%** inference speed. - -[24/02/28] We supported weight-decomposed LoRA (**[DoRA](https://arxiv.org/abs/2402.09353)**). Try `use_dora: true` to activate DoRA training. - -[24/02/15] We supported **block expansion** proposed by [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro). See [examples](examples/README.md) for usage. - -[24/02/05] Qwen1.5 (Qwen2 beta version) series models are supported in LLaMA-Factory. Check this [blog post](https://qwenlm.github.io/blog/qwen1.5/) for details. - -[24/01/18] We supported **agent tuning** for most models, equipping model with tool using abilities by fine-tuning with `dataset: glaive_toolcall_en`. - -[23/12/23] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s implementation to boost LoRA tuning for the LLaMA, Mistral and Yi models. Try `use_unsloth: true` argument to activate unsloth patch. It achieves **170%** speed in our benchmark, check [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison) for details. - -[23/12/12] We supported fine-tuning the latest MoE model **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)** in our framework. See hardware requirement [here](#hardware-requirement). - -[23/12/01] We supported downloading pre-trained models and datasets from the **[ModelScope Hub](https://modelscope.cn/models)**. See [this tutorial](#download-from-modelscope-hub) for usage. - -[23/10/21] We supported **[NEFTune](https://arxiv.org/abs/2310.05914)** trick for fine-tuning. Try `neftune_noise_alpha: 5` argument to activate NEFTune. - -[23/09/27] We supported **$S^2$-Attn** proposed by [LongLoRA](https://github.com/dvlab-research/LongLoRA) for the LLaMA models. Try `shift_attn: true` argument to enable shift short attention. - -[23/09/23] We integrated MMLU, C-Eval and CMMLU benchmarks in this repo. See [examples](examples/README.md) for usage. - -[23/09/10] We supported **[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)**. Try `flash_attn: fa2` argument to enable FlashAttention-2 if you are using RTX4090, A100 or H100 GPUs. - -[23/08/12] We supported **RoPE scaling** to extend the context length of the LLaMA models. Try `rope_scaling: linear` argument in training and `rope_scaling: dynamic` argument at inference to extrapolate the position embeddings. - -[23/08/11] We supported **[DPO training](https://arxiv.org/abs/2305.18290)** for instruction-tuned models. See [examples](examples/README.md) for usage. - -[23/07/31] We supported **dataset streaming**. Try `streaming: true` and `max_steps: 10000` arguments to load your dataset in streaming mode. - -[23/07/29] We released two instruction-tuned 13B models at Hugging Face. See these Hugging Face Repos ([LLaMA-2](https://huggingface.co/hiyouga/Llama-2-Chinese-13b-chat) / [Baichuan](https://huggingface.co/hiyouga/Baichuan-13B-sft)) for details. - -[23/07/18] We developed an **all-in-one Web UI** for training, evaluation and inference. Try `train_web.py` to fine-tune models in your Web browser. Thank [@KanadeSiina](https://github.com/KanadeSiina) and [@codemayq](https://github.com/codemayq) for their efforts in the development. - -[23/07/09] We released **[FastEdit](https://github.com/hiyouga/FastEdit)** ⚡🩹, an easy-to-use package for editing the factual knowledge of large language models efficiently. Please follow [FastEdit](https://github.com/hiyouga/FastEdit) if you are interested. - -[23/06/29] We provided a **reproducible example** of training a chat model using instruction-following datasets, see [Baichuan-7B-sft](https://huggingface.co/hiyouga/Baichuan-7B-sft) for details. - -[23/06/22] We aligned the [demo API](src/api_demo.py) with the [OpenAI's](https://platform.openai.com/docs/api-reference/chat) format where you can insert the fine-tuned model in **arbitrary ChatGPT-based applications**. - -[23/06/03] We supported quantized training and inference (aka **[QLoRA](https://github.com/artidoro/qlora)**). See [examples](examples/README.md) for usage. - -
- -> [!TIP] -> If you cannot use the latest feature, please pull the latest code and install LLaMA-Factory again. - -## Supported Models - -| Model | Model size | Template | -| ----------------------------------------------------------------- | -------------------------------- | ------------------- | -| [Baichuan 2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 | -| [BLOOM/BLOOMZ](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - | -| [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 | -| [Command R](https://huggingface.co/CohereForAI) | 35B/104B | cohere | -| [DeepSeek (Code/MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek | -| [DeepSeek 2.5/3](https://huggingface.co/deepseek-ai) | 236B/671B | deepseek3 | -| [DeepSeek R1 (Distill)](https://huggingface.co/deepseek-ai) | 1.5B/7B/8B/14B/32B/70B/671B | deepseekr1 | -| [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon | -| [Falcon-H1](https://huggingface.co/tiiuae) | 0.5B/1.5B/3B/7B/34B | falcon_h1 | -| [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma/gemma2 | -| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3/gemma3n | -| [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/THUDM) | 9B/32B | glm4/glmz1 | -| [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | -| [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | -| [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | -| [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | -| [Index](https://huggingface.co/IndexTeam) | 1.9B | index | -| [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 | -| [InternVL 2.5-3](https://huggingface.co/OpenGVLab) | 1B/2B/8B/14B/38B/78B | intern_vl | -| [Kimi-VL](https://huggingface.co/moonshotai) | 16B | kimi_vl | -| [Llama](https://github.com/facebookresearch/llama) | 7B/13B/33B/65B | - | -| [Llama 2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 | -| [Llama 3-3.3](https://huggingface.co/meta-llama) | 1B/3B/8B/70B | llama3 | -| [Llama 4](https://huggingface.co/meta-llama) | 109B/402B | llama4 | -| [Llama 3.2 Vision](https://huggingface.co/meta-llama) | 11B/90B | mllama | -| [LLaVA-1.5](https://huggingface.co/llava-hf) | 7B/13B | llava | -| [LLaVA-NeXT](https://huggingface.co/llava-hf) | 7B/8B/13B/34B/72B/110B | llava_next | -| [LLaVA-NeXT-Video](https://huggingface.co/llava-hf) | 7B/34B | llava_next_video | -| [MiMo](https://huggingface.co/XiaomiMiMo) | 7B | mimo | -| [MiniCPM](https://huggingface.co/openbmb) | 0.5B/1B/2B/4B/8B | cpm/cpm3/cpm4 | -| [MiniCPM-o-2.6/MiniCPM-V-2.6](https://huggingface.co/openbmb) | 8B | minicpm_o/minicpm_v | -| [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral | -| [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral | -| [Mistral Small](https://huggingface.co/mistralai) | 24B | mistral_small | -| [OLMo](https://huggingface.co/allenai) | 1B/7B | - | -| [PaliGemma/PaliGemma2](https://huggingface.co/google) | 3B/10B/28B | paligemma | -| [Phi-1.5/Phi-2](https://huggingface.co/microsoft) | 1.3B/2.7B | - | -| [Phi-3/Phi-3.5](https://huggingface.co/microsoft) | 4B/14B | phi | -| [Phi-3-small](https://huggingface.co/microsoft) | 7B | phi_small | -| [Phi-4](https://huggingface.co/microsoft) | 14B | phi4 | -| [Pixtral](https://huggingface.co/mistralai) | 12B | pixtral | -| [Qwen (1-2.5) (Code/Math/MoE/QwQ)](https://huggingface.co/Qwen) | 0.5B/1.5B/3B/7B/14B/32B/72B/110B | qwen | -| [Qwen3 (MoE)](https://huggingface.co/Qwen) | 0.6B/1.7B/4B/8B/14B/32B/235B | qwen3 | -| [Qwen2-Audio](https://huggingface.co/Qwen) | 7B | qwen2_audio | -| [Qwen2.5-Omni](https://huggingface.co/Qwen) | 3B/7B | qwen2_omni | -| [Qwen2-VL/Qwen2.5-VL/QVQ](https://huggingface.co/Qwen) | 2B/3B/7B/32B/72B | qwen2_vl | -| [Seed Coder](https://huggingface.co/ByteDance-Seed) | 8B | seed_coder | -| [Skywork o1](https://huggingface.co/Skywork) | 8B | skywork_o1 | -| [StarCoder 2](https://huggingface.co/bigcode) | 3B/7B/15B | - | -| [TeleChat2](https://huggingface.co/Tele-AI) | 3B/7B/35B/115B | telechat2 | -| [XVERSE](https://huggingface.co/xverse) | 7B/13B/65B | xverse | -| [Yi/Yi-1.5 (Code)](https://huggingface.co/01-ai) | 1.5B/6B/9B/34B | yi | -| [Yi-VL](https://huggingface.co/01-ai) | 6B/34B | yi_vl | -| [Yuan 2](https://huggingface.co/IEITYuan) | 2B/51B/102B | yuan | - -> [!NOTE] -> For the "base" models, the `template` argument can be chosen from `default`, `alpaca`, `vicuna` etc. But make sure to use the **corresponding template** for the "instruct/chat" models. -> -> Remember to use the **SAME** template in training and inference. -> -> \*: You should install the `transformers` from main branch and use `DISABLE_VERSION_CHECK=1` to skip version check. -> -> \*\*: You need to install a specific version of `transformers` to use the corresponding model. - -Please refer to [constants.py](src/llamafactory/extras/constants.py) for a full list of models we supported. - -You also can add a custom chat template to [template.py](src/llamafactory/data/template.py). - -## Supported Training Approaches - -| Approach | Full-tuning | Freeze-tuning | LoRA | QLoRA | -| ---------------------- | ------------------ | ------------------ | ------------------ | ------------------ | -| Pre-Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Supervised Fine-Tuning | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Reward Modeling | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| PPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| DPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| KTO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| ORPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| SimPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | - -> [!TIP] -> The implementation details of PPO can be found in [this blog](https://newfacade.github.io/notes-on-reinforcement-learning/17-ppo-trl.html). - -## Provided Datasets - -
Pre-training datasets - -- [Wiki Demo (en)](data/wiki_demo.txt) -- [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) -- [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2) -- [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220) -- [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered) -- [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile) -- [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B) -- [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb) -- [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) -- [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack) -- [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata) - -
- -
Supervised fine-tuning datasets - -- [Identity (en&zh)](data/identity.json) -- [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca) -- [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3) -- [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM) -- [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) -- [LIMA (en)](https://huggingface.co/datasets/GAIR/lima) -- [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset) -- [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN) -- [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN) -- [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN) -- [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M) -- [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M) -- [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M) -- [UltraChat (en)](https://github.com/thunlp/UltraChat) -- [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus) -- [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k) -- [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT) -- [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca) -- [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca) -- [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) -- [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M) -- [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa) -- [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa) -- [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data) -- [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen) -- [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k) -- [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4) -- [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) -- [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct) -- [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) -- [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k) -- [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia) -- [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction) -- [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo) -- [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2) -- [Magpie-Pro-300K-Filtered (en)](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-300K-Filtered) -- [Magpie-ultra-v0.1 (en)](https://huggingface.co/datasets/argilla/magpie-ultra-v0.1) -- [WebInstructSub (en)](https://huggingface.co/datasets/TIGER-Lab/WebInstructSub) -- [OpenO1-SFT (en&zh)](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT) -- [Open-Thoughts (en)](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) -- [Open-R1-Math (en)](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) -- [Chinese-DeepSeek-R1-Distill (zh)](https://huggingface.co/datasets/Congliu/Chinese-DeepSeek-R1-Distill-data-110k-SFT) -- [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k) -- [Pokemon-gpt4o-captions (en&zh)](https://huggingface.co/datasets/jugg1024/pokemon-gpt4o-captions) -- [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de) -- [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de) -- [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de) -- [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de) -- [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de) -- [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de) -- [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de) -- [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de) -- [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de) - -
- -
Preference datasets - -- [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k) -- [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized) -- [COIG-P (zh)](https://huggingface.co/datasets/m-a-p/COIG-P) -- [RLHF-V (en)](https://huggingface.co/datasets/openbmb/RLHF-V-Dataset) -- [VLFeedback (en)](https://huggingface.co/datasets/Zhihui/VLFeedback) -- [RLAIF-V (en)](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset) -- [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs) -- [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de) -- [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k) - -
- -Some datasets require confirmation before using them, so we recommend logging in with your Hugging Face account using these commands. - -```bash -pip install --upgrade huggingface_hub -huggingface-cli login -``` - -## Requirement - -| Mandatory | Minimum | Recommend | -| ------------ | ------- | --------- | -| python | 3.9 | 3.10 | -| torch | 2.0.0 | 2.6.0 | -| torchvision | 0.15.0 | 0.21.0 | -| transformers | 4.49.0 | 4.50.0 | -| datasets | 2.16.0 | 3.2.0 | -| accelerate | 0.34.0 | 1.2.1 | -| peft | 0.14.0 | 0.15.1 | -| trl | 0.8.6 | 0.9.6 | - -| Optional | Minimum | Recommend | -| ------------ | ------- | --------- | -| CUDA | 11.6 | 12.2 | -| deepspeed | 0.10.0 | 0.16.4 | -| bitsandbytes | 0.39.0 | 0.43.1 | -| vllm | 0.4.3 | 0.8.2 | -| flash-attn | 2.5.6 | 2.7.2 | - -### Hardware Requirement - -\* *estimated* - -| Method | Bits | 7B | 14B | 30B | 70B | `x`B | -| ------------------------------- | ---- | ----- | ----- | ----- | ------ | ------- | -| Full (`bf16` or `fp16`) | 32 | 120GB | 240GB | 600GB | 1200GB | `18x`GB | -| Full (`pure_bf16`) | 16 | 60GB | 120GB | 300GB | 600GB | `8x`GB | -| Freeze/LoRA/GaLore/APOLLO/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | `2x`GB | -| QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | `x`GB | -| QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | `x/2`GB | -| QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | `x/4`GB | - -## Getting Started - -### Installation - -> [!IMPORTANT] -> Installation is mandatory. - -#### Install from Source - -```bash -git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git -cd LLaMA-Factory -pip install -e ".[torch,metrics]" --no-build-isolation -``` - -Extra dependencies available: torch, torch-npu, metrics, deepspeed, liger-kernel, bitsandbytes, hqq, eetq, gptq, aqlm, vllm, sglang, galore, apollo, badam, adam-mini, qwen, minicpm_v, openmind, swanlab, dev - -#### Install from Docker Image - -```bash -docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest -``` - -This image is built on Ubuntu 22.04 (x86\_64), CUDA 12.4, Python 3.11, PyTorch 2.6.0, and Flash-attn 2.7.4. - -Find the pre-built images: https://hub.docker.com/r/hiyouga/llamafactory/tags - -Please refer to [build docker](#build-docker) to build the image yourself. - -
Setting up a virtual environment with uv - -Create an isolated Python environment with [uv](https://github.com/astral-sh/uv): - -```bash -uv sync --extra torch --extra metrics --prerelease=allow -``` - -Run LLaMA-Factory in the isolated environment: - -```bash -uv run --prerelease=allow llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml -``` - -
- -
For Windows users - -#### Install PyTorch - -You need to manually install the GPU version of PyTorch on the Windows platform. Please refer to the [official website](https://pytorch.org/get-started/locally/) and the following command to install PyTorch with CUDA support: - -```bash -pip uninstall torch torchvision torchaudio -pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 -python -c "import torch; print(torch.cuda.is_available())" -``` - -If you see `True` then you have successfully installed PyTorch with CUDA support. - -Try `dataloader_num_workers: 0` if you encounter `Can't pickle local object` error. - -#### Install BitsAndBytes - -If you want to enable the quantized LoRA (QLoRA) on the Windows platform, you need to install a pre-built version of `bitsandbytes` library, which supports CUDA 11.1 to 12.2, please select the appropriate [release version](https://github.com/jllllll/bitsandbytes-windows-webui/releases/tag/wheels) based on your CUDA version. - -```bash -pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl -``` - -#### Install Flash Attention-2 - -To enable FlashAttention-2 on the Windows platform, please use the script from [flash-attention-windows-wheel](https://huggingface.co/lldacing/flash-attention-windows-wheel) to compile and install it by yourself. - -
- -
For Ascend NPU users - -To install LLaMA Factory on Ascend NPU devices, please upgrade Python to version 3.10 or higher and specify extra dependencies: `pip install -e ".[torch-npu,metrics]"`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands: - -```bash -# replace the url according to your CANN version and devices -# install CANN Toolkit -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C20SPC702/Ascend-cann-toolkit_8.0.0.alpha002_linux-"$(uname -i)".run -bash Ascend-cann-toolkit_8.0.0.alpha002_linux-"$(uname -i)".run --install - -# install CANN Kernels -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C20SPC702/Ascend-cann-kernels-910b_8.0.0.alpha002_linux-"$(uname -i)".run -bash Ascend-cann-kernels-910b_8.0.0.alpha002_linux-"$(uname -i)".run --install - -# set env variables -source /usr/local/Ascend/ascend-toolkit/set_env.sh -``` - -| Requirement | Minimum | Recommend | -| ------------ | ------- | -------------- | -| CANN | 8.0.RC1 | 8.0.0.alpha002 | -| torch | 2.1.0 | 2.4.0 | -| torch-npu | 2.1.0 | 2.4.0.post2 | -| deepspeed | 0.13.2 | 0.13.2 | -| vllm-ascend | - | 0.7.3 | - -Remember to use `ASCEND_RT_VISIBLE_DEVICES` instead of `CUDA_VISIBLE_DEVICES` to specify the device to use. - -If you cannot infer model on NPU devices, try setting `do_sample: false` in the configurations. - -Download the pre-built Docker images: [32GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html) | [64GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html) - -#### Install BitsAndBytes - -To use QLoRA based on bitsandbytes on Ascend NPU, please follow these 3 steps: - -1. Manually compile bitsandbytes: Refer to [the installation documentation](https://huggingface.co/docs/bitsandbytes/installation?backend=Ascend+NPU&platform=Ascend+NPU) for the NPU version of bitsandbytes to complete the compilation and installation. The compilation requires a cmake version of at least 3.22.1 and a g++ version of at least 12.x. - -```bash -# Install bitsandbytes from source -# Clone bitsandbytes repo, Ascend NPU backend is currently enabled on multi-backend-refactor branch -git clone -b multi-backend-refactor https://github.com/bitsandbytes-foundation/bitsandbytes.git -cd bitsandbytes/ - -# Install dependencies -pip install -r requirements-dev.txt - -# Install the dependencies for the compilation tools. Note that the commands for this step may vary depending on the operating system. The following are provided for reference -apt-get install -y build-essential cmake - -# Compile & install -cmake -DCOMPUTE_BACKEND=npu -S . -make -pip install . -``` - -2. Install transformers from the main branch. - -```bash -git clone -b main https://github.com/huggingface/transformers.git -cd transformers -pip install . -``` - -3. Set `double_quantization: false` in the configuration. You can refer to the [example](examples/train_qlora/llama3_lora_sft_bnb_npu.yaml). - -
- -### Data Preparation - -Please refer to [data/README.md](data/README.md) for checking the details about the format of dataset files. You can use datasets on HuggingFace / ModelScope / Modelers hub, load the dataset in local disk, or specify a path to s3/gcs cloud storage. - -> [!NOTE] -> Please update `data/dataset_info.json` to use your custom dataset. - -You can also use **[Easy Dataset](https://github.com/ConardLi/easy-dataset)** or **[GraphGen](https://github.com/open-sciencelab/GraphGen)** to create synthetic data for fine-tuning. - -### Quickstart - -Use the following 3 commands to run LoRA **fine-tuning**, **inference** and **merging** of the Llama3-8B-Instruct model, respectively. - -```bash -llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml -llamafactory-cli chat examples/inference/llama3_lora_sft.yaml -llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml -``` - -See [examples/README.md](examples/README.md) for advanced usage (including distributed training). - -> [!TIP] -> Use `llamafactory-cli help` to show help information. -> -> Read [FAQs](https://github.com/hiyouga/LLaMA-Factory/issues/4614) first if you encounter any problems. - -### Fine-Tuning with LLaMA Board GUI (powered by [Gradio](https://github.com/gradio-app/gradio)) - -```bash -llamafactory-cli webui -``` - -### Build Docker - -For CUDA users: - -```bash -cd docker/docker-cuda/ -docker compose up -d -docker compose exec llamafactory bash -``` - -For Ascend NPU users: - -```bash -cd docker/docker-npu/ -docker compose up -d -docker compose exec llamafactory bash -``` - -For AMD ROCm users: - -```bash -cd docker/docker-rocm/ -docker compose up -d -docker compose exec llamafactory bash -``` - -
Build without Docker Compose - -For CUDA users: - -```bash -docker build -f ./docker/docker-cuda/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host --gpus=all \ - -p 7860:7860 \ - -p 8000:8000 \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -For Ascend NPU users: - -```bash -docker build -f ./docker/docker-npu/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=torch-npu,metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host \ - -v /usr/local/dcmi:/usr/local/dcmi \ - -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ - -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ - -v /etc/ascend_install.info:/etc/ascend_install.info \ - -p 7860:7860 \ - -p 8000:8000 \ - --device /dev/davinci0 \ - --device /dev/davinci_manager \ - --device /dev/devmm_svm \ - --device /dev/hisi_hdc \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -For AMD ROCm users: - -```bash -docker build -f ./docker/docker-rocm/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host \ - -p 7860:7860 \ - -p 8000:8000 \ - --device /dev/kfd \ - --device /dev/dri \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -
- -
Use Docker volumes - -You can uncomment `VOLUME [ "/root/.cache/huggingface", "/app/shared_data", "/app/output" ]` in the Dockerfile to use data volumes. - -When building the Docker image, use `-v ./hf_cache:/root/.cache/huggingface` argument to mount the local directory to the container. The following data volumes are available. - -- `hf_cache`: Utilize Hugging Face cache on the host machine. -- `shared_data`: The directionary to store datasets on the host machine. -- `output`: Set export dir to this location so that the merged result can be accessed directly on the host machine. - -
- -### Deploy with OpenAI-style API and vLLM - -```bash -API_PORT=8000 llamafactory-cli api examples/inference/llama3.yaml infer_backend=vllm vllm_enforce_eager=true -``` - -> [!TIP] -> Visit [this page](https://platform.openai.com/docs/api-reference/chat/create) for API document. -> -> Examples: [Image understanding](scripts/api_example/test_image.py) | [Function calling](scripts/api_example/test_toolcall.py) - -### Download from ModelScope Hub - -If you have trouble with downloading models and datasets from Hugging Face, you can use ModelScope. - -```bash -export USE_MODELSCOPE_HUB=1 # `set USE_MODELSCOPE_HUB=1` for Windows -``` - -Train the model by specifying a model ID of the ModelScope Hub as the `model_name_or_path`. You can find a full list of model IDs at [ModelScope Hub](https://modelscope.cn/models), e.g., `LLM-Research/Meta-Llama-3-8B-Instruct`. - -### Download from Modelers Hub - -You can also use Modelers Hub to download models and datasets. - -```bash -export USE_OPENMIND_HUB=1 # `set USE_OPENMIND_HUB=1` for Windows -``` - -Train the model by specifying a model ID of the Modelers Hub as the `model_name_or_path`. You can find a full list of model IDs at [Modelers Hub](https://modelers.cn/models), e.g., `TeleAI/TeleChat-7B-pt`. - -### Use W&B Logger - -To use [Weights & Biases](https://wandb.ai) for logging experimental results, you need to add the following arguments to yaml files. - -```yaml -report_to: wandb -run_name: test_run # optional -``` - -Set `WANDB_API_KEY` to [your key](https://wandb.ai/authorize) when launching training tasks to log in with your W&B account. - -### Use SwanLab Logger - -To use [SwanLab](https://github.com/SwanHubX/SwanLab) for logging experimental results, you need to add the following arguments to yaml files. - -```yaml -use_swanlab: true -swanlab_run_name: test_run # optional -``` - -When launching training tasks, you can log in to SwanLab in three ways: - -1. Add `swanlab_api_key=` to the yaml file, and set it to your [API key](https://swanlab.cn/settings). -2. Set the environment variable `SWANLAB_API_KEY` to your [API key](https://swanlab.cn/settings). -3. Use the `swanlab login` command to complete the login. - -## Projects using LLaMA Factory - -If you have a project that should be incorporated, please contact via email or create a pull request. - -
Click to show - -1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223) -1. Yu et al. Open, Closed, or Small Language Models for Text Classification? 2023. [[arxiv]](https://arxiv.org/abs/2308.10092) -1. Wang et al. UbiPhysio: Support Daily Functioning, Fitness, and Rehabilitation with Action Understanding and Feedback in Natural Language. 2023. [[arxiv]](https://arxiv.org/abs/2308.10526) -1. Luceri et al. Leveraging Large Language Models to Detect Influence Campaigns in Social Media. 2023. [[arxiv]](https://arxiv.org/abs/2311.07816) -1. Zhang et al. Alleviating Hallucinations of Large Language Models through Induced Hallucinations. 2023. [[arxiv]](https://arxiv.org/abs/2312.15710) -1. Wang et al. Know Your Needs Better: Towards Structured Understanding of Marketer Demands with Analogical Reasoning Augmented LLMs. KDD 2024. [[arxiv]](https://arxiv.org/abs/2401.04319) -1. Wang et al. CANDLE: Iterative Conceptualization and Instantiation Distillation from Large Language Models for Commonsense Reasoning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2401.07286) -1. Choi et al. FACT-GPT: Fact-Checking Augmentation via Claim Matching with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2402.05904) -1. Zhang et al. AutoMathText: Autonomous Data Selection with Language Models for Mathematical Texts. 2024. [[arxiv]](https://arxiv.org/abs/2402.07625) -1. Lyu et al. KnowTuning: Knowledge-aware Fine-tuning for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11176) -1. Yang et al. LaCo: Large Language Model Pruning via Layer Collaps. 2024. [[arxiv]](https://arxiv.org/abs/2402.11187) -1. Bhardwaj et al. Language Models are Homer Simpson! Safety Re-Alignment of Fine-tuned Language Models through Task Arithmetic. 2024. [[arxiv]](https://arxiv.org/abs/2402.11746) -1. Yang et al. Enhancing Empathetic Response Generation by Augmenting LLMs with Small-scale Empathetic Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11801) -1. Yi et al. Generation Meets Verification: Accelerating Large Language Model Inference with Smart Parallel Auto-Correct Decoding. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2402.11809) -1. Cao et al. Head-wise Shareable Attention for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11819) -1. Zhang et al. Enhancing Multilingual Capabilities of Large Language Models through Self-Distillation from Resource-Rich Languages. 2024. [[arxiv]](https://arxiv.org/abs/2402.12204) -1. Kim et al. Efficient and Effective Vocabulary Expansion Towards Multilingual Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.14714) -1. Yu et al. KIEval: A Knowledge-grounded Interactive Evaluation Framework for Large Language Models. ACL 2024. [[arxiv]](https://arxiv.org/abs/2402.15043) -1. Huang et al. Key-Point-Driven Data Synthesis with its Enhancement on Mathematical Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2403.02333) -1. Duan et al. Negating Negatives: Alignment without Human Positive Samples via Distributional Dispreference Optimization. 2024. [[arxiv]](https://arxiv.org/abs/2403.03419) -1. Xie and Schwertfeger. Empowering Robotics with Large Language Models: osmAG Map Comprehension with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2403.08228) -1. Wu et al. Large Language Models are Parallel Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2403.09073) -1. Zhang et al. EDT: Improving Large Language Models' Generation by Entropy-based Dynamic Temperature Sampling. 2024. [[arxiv]](https://arxiv.org/abs/2403.14541) -1. Weller et al. FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2403.15246) -1. Hongbin Na. CBT-LLM: A Chinese Large Language Model for Cognitive Behavioral Therapy-based Mental Health Question Answering. COLING 2024. [[arxiv]](https://arxiv.org/abs/2403.16008) -1. Zan et al. CodeS: Natural Language to Code Repository via Multi-Layer Sketch. 2024. [[arxiv]](https://arxiv.org/abs/2403.16443) -1. Liu et al. Extensive Self-Contrast Enables Feedback-Free Language Model Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2404.00604) -1. Luo et al. BAdam: A Memory Efficient Full Parameter Training Method for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.02827) -1. Du et al. Chinese Tiny LLM: Pretraining a Chinese-Centric Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2404.04167) -1. Ma et al. Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation. ICML 2024. [[arxiv]](https://arxiv.org/abs/2404.04316) -1. Liu et al. Dynamic Generation of Personalities with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.07084) -1. Shang et al. How Far Have We Gone in Stripped Binary Code Understanding Using Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.09836) -1. Huang et al. LLMTune: Accelerate Database Knob Tuning with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.11581) -1. Deng et al. Text-Tuple-Table: Towards Information Integration in Text-to-Table Generation via Global Tuple Extraction. 2024. [[arxiv]](https://arxiv.org/abs/2404.14215) -1. Acikgoz et al. Hippocrates: An Open-Source Framework for Advancing Large Language Models in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2404.16621) -1. Zhang et al. Small Language Models Need Strong Verifiers to Self-Correct Reasoning. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2404.17140) -1. Zhou et al. FREB-TQA: A Fine-Grained Robustness Evaluation Benchmark for Table Question Answering. NAACL 2024. [[arxiv]](https://arxiv.org/abs/2404.18585) -1. Xu et al. Large Language Models for Cyber Security: A Systematic Literature Review. 2024. [[arxiv]](https://arxiv.org/abs/2405.04760) -1. Dammu et al. "They are uncultured": Unveiling Covert Harms and Social Threats in LLM Generated Conversations. 2024. [[arxiv]](https://arxiv.org/abs/2405.05378) -1. Yi et al. A safety realignment framework via subspace-oriented model fusion for large language models. 2024. [[arxiv]](https://arxiv.org/abs/2405.09055) -1. Lou et al. SPO: Multi-Dimensional Preference Sequential Alignment With Implicit Reward Modeling. 2024. [[arxiv]](https://arxiv.org/abs/2405.12739) -1. Zhang et al. Getting More from Less: Large Language Models are Good Spontaneous Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2405.13816) -1. Zhang et al. TS-Align: A Teacher-Student Collaborative Framework for Scalable Iterative Finetuning of Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2405.20215) -1. Zihong Chen. Sentence Segmentation and Sentence Punctuation Based on XunziALLM. 2024. [[paper]](https://aclanthology.org/2024.lt4hala-1.30) -1. Gao et al. The Best of Both Worlds: Toward an Honest and Helpful Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2406.00380) -1. Wang and Song. MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Dataset. 2024. [[arxiv]](https://arxiv.org/abs/2406.02106) -1. Hu et al. Computational Limits of Low-Rank Adaptation (LoRA) for Transformer-Based Models. 2024. [[arxiv]](https://arxiv.org/abs/2406.03136) -1. Ge et al. Time Sensitive Knowledge Editing through Efficient Finetuning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2406.04496) -1. Tan et al. Peer Review as A Multi-Turn and Long-Context Dialogue with Role-Based Interactions. 2024. [[arxiv]](https://arxiv.org/abs/2406.05688) -1. Song et al. Turbo Sparse: Achieving LLM SOTA Performance with Minimal Activated Parameters. 2024. [[arxiv]](https://arxiv.org/abs/2406.05955) -1. Gu et al. RWKV-CLIP: A Robust Vision-Language Representation Learner. 2024. [[arxiv]](https://arxiv.org/abs/2406.06973) -1. Chen et al. Advancing Tool-Augmented Large Language Models: Integrating Insights from Errors in Inference Trees. 2024. [[arxiv]](https://arxiv.org/abs/2406.07115) -1. Zhu et al. Are Large Language Models Good Statisticians?. 2024. [[arxiv]](https://arxiv.org/abs/2406.07815) -1. Li et al. Know the Unknown: An Uncertainty-Sensitive Method for LLM Instruction Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2406.10099) -1. Ding et al. IntentionQA: A Benchmark for Evaluating Purchase Intention Comprehension Abilities of Language Models in E-commerce. 2024. [[arxiv]](https://arxiv.org/abs/2406.10173) -1. He et al. COMMUNITY-CROSS-INSTRUCT: Unsupervised Instruction Generation for Aligning Large Language Models to Online Communities. 2024. [[arxiv]](https://arxiv.org/abs/2406.12074) -1. Lin et al. FVEL: Interactive Formal Verification Environment with Large Language Models via Theorem Proving. 2024. [[arxiv]](https://arxiv.org/abs/2406.14408) -1. Treutlein et al. Connecting the Dots: LLMs can Infer and Verbalize Latent Structure from Disparate Training Data. 2024. [[arxiv]](https://arxiv.org/abs/2406.14546) -1. Feng et al. SS-Bench: A Benchmark for Social Story Generation and Evaluation. 2024. [[arxiv]](https://arxiv.org/abs/2406.15695) -1. Feng et al. Self-Constructed Context Decompilation with Fined-grained Alignment Enhancement. 2024. [[arxiv]](https://arxiv.org/abs/2406.17233) -1. Liu et al. Large Language Models for Cuffless Blood Pressure Measurement From Wearable Biosignals. 2024. [[arxiv]](https://arxiv.org/abs/2406.18069) -1. Iyer et al. Exploring Very Low-Resource Translation with LLMs: The University of Edinburgh's Submission to AmericasNLP 2024 Translation Task. AmericasNLP 2024. [[paper]](https://aclanthology.org/2024.americasnlp-1.25) -1. Li et al. Calibrating LLMs with Preference Optimization on Thought Trees for Generating Rationale in Science Question Scoring. 2024. [[arxiv]](https://arxiv.org/abs/2406.19949) -1. Yang et al. Financial Knowledge Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2407.00365) -1. Lin et al. DogeRM: Equipping Reward Models with Domain Knowledge through Model Merging. 2024. [[arxiv]](https://arxiv.org/abs/2407.01470) -1. Bako et al. Evaluating the Semantic Profiling Abilities of LLMs for Natural Language Utterances in Data Visualization. 2024. [[arxiv]](https://arxiv.org/abs/2407.06129) -1. Huang et al. RoLoRA: Fine-tuning Rotated Outlier-free LLMs for Effective Weight-Activation Quantization. 2024. [[arxiv]](https://arxiv.org/abs/2407.08044) -1. Jiang et al. LLM-Collaboration on Automatic Science Journalism for the General Audience. 2024. [[arxiv]](https://arxiv.org/abs/2407.09756) -1. Inouye et al. Applied Auto-tuning on LoRA Hyperparameters. 2024. [[paper]](https://scholarcommons.scu.edu/cseng_senior/272/) -1. Qi et al. Research on Tibetan Tourism Viewpoints information generation system based on LLM. 2024. [[arxiv]](https://arxiv.org/abs/2407.13561) -1. Xu et al. Course-Correction: Safety Alignment Using Synthetic Preferences. 2024. [[arxiv]](https://arxiv.org/abs/2407.16637) -1. Sun et al. LAMBDA: A Large Model Based Data Agent. 2024. [[arxiv]](https://arxiv.org/abs/2407.17535) -1. Zhu et al. CollectiveSFT: Scaling Large Language Models for Chinese Medical Benchmark with Collective Instructions in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2407.19705) -1. Yu et al. Correcting Negative Bias in Large Language Models through Negative Attention Score Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2408.00137) -1. Xie et al. The Power of Personalized Datasets: Advancing Chinese Composition Writing for Elementary School through Targeted Model Fine-Tuning. IALP 2024. [[paper]](https://www.asianlp.sg/conferences/ialp2024/proceedings/papers/IALP2024_P055.pdf) -1. Liu et al. Instruct-Code-Llama: Improving Capabilities of Language Model in Competition Level Code Generation by Online Judge Feedback. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_11) -1. Wang et al. Cybernetic Sentinels: Unveiling the Impact of Safety Data Selection on Model Security in Supervised Fine-Tuning. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_23) -1. Xia et al. Understanding the Performance and Estimating the Cost of LLM Fine-Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2408.04693) -1. Zeng et al. Perceive, Reflect, and Plan: Designing LLM Agent for Goal-Directed City Navigation without Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2408.04168) -1. Xia et al. Using Pre-trained Language Model for Accurate ESG Prediction. FinNLP 2024. [[paper]](https://aclanthology.org/2024.finnlp-2.1/) -1. Liang et al. I-SHEEP: Self-Alignment of LLM from Scratch through an Iterative Self-Enhancement Paradigm. 2024. [[arxiv]](https://arxiv.org/abs/2408.08072) -1. Bai et al. Aligning Large Language Model with Direct Multi-Preference Optimization for Recommendation. CIKM 2024. [[paper]](https://dl.acm.org/doi/10.1145/3627673.3679611) -1. Zhang et al. CPsyCoun: A Report-based Multi-turn Dialogue Reconstruction and Evaluation Framework for Chinese Psychological Counseling. ACL 2024. [[paper]](https://aclanthology.org/2024.findings-acl.830.pdf) -1. **[StarWhisper](https://github.com/Yu-Yang-Li/StarWhisper)**: A large language model for Astronomy, based on ChatGLM2-6B and Qwen-14B. -1. **[DISC-LawLLM](https://github.com/FudanDISC/DISC-LawLLM)**: A large language model specialized in Chinese legal domain, based on Baichuan-13B, is capable of retrieving and reasoning on legal knowledge. -1. **[Sunsimiao](https://github.com/X-D-Lab/Sunsimiao)**: A large language model specialized in Chinese medical domain, based on Baichuan-7B and ChatGLM-6B. -1. **[CareGPT](https://github.com/WangRongsheng/CareGPT)**: A series of large language models for Chinese medical domain, based on LLaMA2-7B and Baichuan-13B. -1. **[MachineMindset](https://github.com/PKU-YuanGroup/Machine-Mindset/)**: A series of MBTI Personality large language models, capable of giving any LLM 16 different personality types based on different datasets and training methods. -1. **[Luminia-13B-v3](https://huggingface.co/Nekochu/Luminia-13B-v3)**: A large language model specialized in generate metadata for stable diffusion. [[demo]](https://huggingface.co/spaces/Nekochu/Luminia-13B_SD_Prompt) -1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**: A multimodal large language model specialized in Chinese medical domain, based on LLaVA-1.5-7B. -1. **[AutoRE](https://github.com/THUDM/AutoRE)**: A document-level relation extraction system based on large language models. -1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**: SDKs for fine-tuning LLMs on Windows PC for NVIDIA RTX. -1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**: An easy and lazy way for building multi-agent LLMs applications and supports model fine-tuning via LLaMA Factory. -1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**: A full pipeline for RAG retrieval model fine-tuning, inference, and distillation. [[blog]](https://zhuanlan.zhihu.com/p/987727357) -1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**: A modified library that supports long sequence SFT & DPO using ring attention. -1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**: An o1-like model fine-tuned by NovaSky AI with very small cost. -1. **[WeClone](https://github.com/xming521/WeClone)**: One-stop solution for creating your digital avatar from chat logs. -1. **[EmoLLM](https://github.com/SmartFlowAI/EmoLLM)**: A project about large language models (LLMs) and mental health. -
- -## License - -This repository is licensed under the [Apache-2.0 License](LICENSE). - -Please follow the model licenses to use the corresponding model weights: [Baichuan 2](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/blob/main/Community%20License%20for%20Baichuan%202%20Model.pdf) / [BLOOM](https://huggingface.co/spaces/bigscience/license) / [ChatGLM3](https://github.com/THUDM/ChatGLM3/blob/main/MODEL_LICENSE) / [Command R](https://cohere.com/c4ai-cc-by-nc-license) / [DeepSeek](https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/LICENSE-MODEL) / [Falcon](https://huggingface.co/tiiuae/falcon-180B/blob/main/LICENSE.txt) / [Gemma](https://ai.google.dev/gemma/terms) / [GLM-4](https://huggingface.co/THUDM/glm-4-9b/blob/main/LICENSE) / [GPT-2](https://github.com/openai/gpt-2/blob/master/LICENSE) / [Granite](LICENSE) / [Index](https://huggingface.co/IndexTeam/Index-1.9B/blob/main/LICENSE) / [InternLM](https://github.com/InternLM/InternLM#license) / [Llama](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) / [Llama 2](https://ai.meta.com/llama/license/) / [Llama 3](https://llama.meta.com/llama3/license/) / [Llama 4](https://github.com/meta-llama/llama-models/blob/main/models/llama4/LICENSE) / [MiniCPM](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md) / [Mistral/Mixtral/Pixtral](LICENSE) / [OLMo](LICENSE) / [Phi-1.5/Phi-2](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx) / [Phi-3/Phi-4](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/LICENSE) / [Qwen](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) / [Skywork](https://huggingface.co/Skywork/Skywork-13B-base/blob/main/Skywork%20Community%20License.pdf) / [StarCoder 2](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) / [TeleChat2](https://huggingface.co/Tele-AI/telechat-7B/blob/main/TeleChat%E6%A8%A1%E5%9E%8B%E7%A4%BE%E5%8C%BA%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.pdf) / [XVERSE](https://github.com/xverse-ai/XVERSE-13B/blob/main/MODEL_LICENSE.pdf) / [Yi](https://huggingface.co/01-ai/Yi-6B/blob/main/LICENSE) / [Yi-1.5](LICENSE) / [Yuan 2](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/LICENSE-Yuan) - -## Citation - -If this work is helpful, please kindly cite as: - -```bibtex -@inproceedings{zheng2024llamafactory, - title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models}, - author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma}, - booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)}, - address={Bangkok, Thailand}, - publisher={Association for Computational Linguistics}, - year={2024}, - url={http://arxiv.org/abs/2403.13372} -} -``` - -## Acknowledgement - -This repo benefits from [PEFT](https://github.com/huggingface/peft), [TRL](https://github.com/huggingface/trl), [QLoRA](https://github.com/artidoro/qlora) and [FastChat](https://github.com/lm-sys/FastChat). Thanks for their wonderful works. - -## Star History - -![Star History Chart](https://api.star-history.com/svg?repos=hiyouga/LLaMA-Factory&type=Date) diff --git a/docker-hub/qwen2.5-vl/llama-factory/README_zh.md b/docker-hub/qwen2.5-vl/llama-factory/README_zh.md deleted file mode 100644 index 466f57d5277d252be7356c25a11fea58d2f8e76b..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/README_zh.md +++ /dev/null @@ -1,949 +0,0 @@ -![# LLaMA Factory](assets/logo.png) - -[![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/LLaMA-Factory?style=social)](https://github.com/hiyouga/LLaMA-Factory/stargazers) -[![GitHub last commit](https://img.shields.io/github/last-commit/hiyouga/LLaMA-Factory)](https://github.com/hiyouga/LLaMA-Factory/commits/main) -[![GitHub contributors](https://img.shields.io/github/contributors/hiyouga/LLaMA-Factory?color=orange)](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors) -[![GitHub workflow](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml/badge.svg)](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml) -[![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/) -[![Citation](https://img.shields.io/badge/citation-651-green)](https://scholar.google.com/scholar?cites=12620864006390196564) -[![Docker Pulls](https://img.shields.io/docker/pulls/hiyouga/llamafactory)](https://hub.docker.com/r/hiyouga/llamafactory/tags) - -[![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai) -[![Discord](https://dcbadge.vercel.app/api/server/rKfvV9r9FK?compact=true&style=flat)](https://discord.gg/rKfvV9r9FK) -[![GitCode](https://gitcode.com/zhengyaowei/LLaMA-Factory/star/badge.svg)](https://gitcode.com/zhengyaowei/LLaMA-Factory) - -[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing) -[![Open in DSW](https://gallery.pai-ml.com/assets/open-in-dsw.svg)](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory) -[![Open in Alaya](assets/alaya_new.svg)](https://docs.alayanew.com/docs/documents/newActivities/llamafactory/?utm_source=LLaMA-Factory) -[![Open in Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/hiyouga/LLaMA-Board) -[![Open in Studios](https://img.shields.io/badge/ModelScope-Open%20in%20Studios-blue)](https://modelscope.cn/studios/hiyouga/LLaMA-Board) -[![Open in Novita](https://img.shields.io/badge/Novita-Deploy%20Template-blue)](https://novita.ai/templates-library/105981?sharer=88115474-394e-4bda-968e-b88e123d0c47) - -### 获得[亚马逊](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)、[英伟达](https://developer.nvidia.cn/rtx/ai-toolkit)、[阿里云](https://help.aliyun.com/zh/pai/use-cases/fine-tune-a-llama-3-model-with-llama-factory)等的应用。 - -
- -### 赞助商 ❤️ - - - Warp sponsorship - - -#### [Warp,面向开发者的智能终端](https://warp.dev/llama-factory) - -[适用于 MacOS、Linux 和 Windows](https://warp.dev/llama-factory) - ----- - -### 使用零代码[命令行](#快速开始)与 [Web UI](#llama-board-可视化微调由-gradio-驱动) 轻松微调百余种大模型 - -![GitHub Trend](https://trendshift.io/api/badge/repositories/4535) - -
- -👋 加入我们的[微信群](assets/wechat.jpg)、[NPU 用户群](assets/wechat_npu.jpg)或 [九章智算云算力优惠群](assets/wechat_alaya.png)。 - -\[ [English](README.md) | 中文 \] - -**微调大模型可以像这样轻松…** - -https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc - -选择你的打开方式: - -- **入门教程**:https://zhuanlan.zhihu.com/p/695287607 -- **微调视频教程**:https://www.bilibili.com/video/BV1djgRzxEts/ -- **框架文档**:https://llamafactory.readthedocs.io/zh-cn/latest/ -- **框架文档(昇腾 NPU)**:https://ascend.github.io/docs/sources/llamafactory/ -- **Colab(免费)**:https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing -- **本地机器**:请见[如何使用](#如何使用) -- **PAI-DSW(免费试用)**:https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory -- **九章智算云(算力优惠活动)**:https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory - -> [!NOTE] -> 除上述链接以外的其他网站均为未经许可的第三方网站,请小心甄别。 - -## 目录 - -- [项目特色](#项目特色) -- [官方博客](#官方博客) -- [更新日志](#更新日志) -- [模型](#模型) -- [训练方法](#训练方法) -- [数据集](#数据集) -- [软硬件依赖](#软硬件依赖) -- [如何使用](#如何使用) - - [安装 LLaMA Factory](#安装-llama-factory) - - [数据准备](#数据准备) - - [快速开始](#快速开始) - - [LLaMA Board 可视化微调](#llama-board-可视化微调由-gradio-驱动) - - [构建 Docker](#构建-docker) - - [利用 vLLM 部署 OpenAI API](#利用-vllm-部署-openai-api) - - [从魔搭社区下载](#从魔搭社区下载) - - [从魔乐社区下载](#从魔乐社区下载) - - [使用 W&B 面板](#使用-wb-面板) - - [使用 SwanLab 面板](#使用-swanlab-面板) -- [使用了 LLaMA Factory 的项目](#使用了-llama-factory-的项目) -- [协议](#协议) -- [引用](#引用) -- [致谢](#致谢) - -## 项目特色 - -- **多种模型**:LLaMA、LLaVA、Mistral、Mixtral-MoE、Qwen、Qwen2-VL、DeepSeek、Yi、Gemma、ChatGLM、Phi 等等。 -- **集成方法**:(增量)预训练、(多模态)指令监督微调、奖励模型训练、PPO 训练、DPO 训练、KTO 训练、ORPO 训练等等。 -- **多种精度**:16 比特全参数微调、冻结微调、LoRA 微调和基于 AQLM/AWQ/GPTQ/LLM.int8/HQQ/EETQ 的 2/3/4/5/6/8 比特 QLoRA 微调。 -- **先进算法**:[GaLore](https://github.com/jiaweizzhao/GaLore)、[BAdam](https://github.com/Ledzy/BAdam)、[APOLLO](https://github.com/zhuhanqing/APOLLO)、[Adam-mini](https://github.com/zyushun/Adam-mini)、[Muon](https://github.com/KellerJordan/Muon)、DoRA、LongLoRA、LLaMA Pro、Mixture-of-Depths、LoRA+、LoftQ 和 PiSSA。 -- **实用技巧**:[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)、[Unsloth](https://github.com/unslothai/unsloth)、[Liger Kernel](https://github.com/linkedin/Liger-Kernel)、RoPE scaling、NEFTune 和 rsLoRA。 -- **广泛任务**:多轮对话、工具调用、图像理解、视觉定位、视频识别和语音理解等等。 -- **实验监控**:LlamaBoard、TensorBoard、Wandb、MLflow、[SwanLab](https://github.com/SwanHubX/SwanLab) 等等。 -- **极速推理**:基于 [vLLM](https://github.com/vllm-project/vllm) 或 [SGLang](https://github.com/sgl-project/sglang) 的 OpenAI 风格 API、浏览器界面和命令行接口。 - -### 最新模型的 Day-N 微调适配 - -| 适配时间 | 模型名称 | -| ------------ | -------------------------------------------------------------------- | -| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM-4.1V / InternLM 3 / MiniCPM-o-2.6 | -| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | - -## 官方博客 - -- [基于 LLaMA-Factory 和 EasyR1 打造一站式无代码大模型强化学习和部署平台 LLM Model Hub](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/)(中文) -- [使用 LLaMA-Factory 微调 Qwen2.5-VL 实现自动驾驶场景微调](https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory)(中文) -- [通过亚马逊 SageMaker HyperPod 上的 LLaMA-Factory 增强多模态模型银行文档的视觉信息提取](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/)(英文) -- [Easy Dataset × LLaMA Factory: 让大模型高效学习领域知识](https://buaa-act.feishu.cn/wiki/KY9xwTGs1iqHrRkjXBwcZP9WnL9)(中文) - -
全部博客 - -- [LLaMA Factory:微调 DeepSeek-R1-Distill-Qwen-7B 模型实现新闻标题分类器](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b)(中文) -- [基于 Amazon SageMaker 和 LLaMA-Factory 打造一站式无代码模型微调部署平台 Model Hub](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)(中文) -- [LLaMA Factory 多模态微调实践:微调 Qwen2-VL 构建文旅大模型](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl)(中文) -- [LLaMA Factory:微调LLaMA3模型实现角色扮演](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)(中文) - -
- -## 更新日志 - -[25/07/02] 我们支持了 **[GLM-4.1V-9B-Thinking](https://github.com/THUDM/GLM-4.1V-Thinking)** 模型的微调。请安装 transformers 的 main 分支版本以使用。 - -[25/04/28] 我们支持了 **[Qwen3](https://qwenlm.github.io/blog/qwen3/)** 系列模型的微调。 - -[25/04/21] 我们支持了 **[Muon](https://github.com/KellerJordan/Muon)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@tianshijing](https://github.com/tianshijing) 的 PR。 - -[25/04/16] 我们支持了 **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** 模型的微调。查看 [PR #7258](https://github.com/hiyouga/LLaMA-Factory/pull/7258) 以使用。 - -[25/04/14] 我们支持了 **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** 和 **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** 模型的微调。 - -[25/04/06] 我们支持了 **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** 模型的微调。查看 [PR #7611](https://github.com/hiyouga/LLaMA-Factory/pull/7611) 以使用。 - -
展开日志 - -[25/03/31] 我们支持了 **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** 模型的微调。查看 [PR #7537](https://github.com/hiyouga/LLaMA-Factory/pull/7537) 以使用。 - -[25/03/15] 我们支持了 **[SGLang](https://github.com/sgl-project/sglang)** 推理后端,请使用 `infer_backend: sglang` 启用。 - -[25/03/12] 我们支持了 **[Gemma 3](https://huggingface.co/blog/gemma3)** 模型的微调。 - -[25/02/24] 我们宣布开源 **[EasyR1](https://github.com/hiyouga/EasyR1)**,一个高效可扩展的多模态强化学习框架,支持高效的 GRPO 训练。 - -[25/02/11] 我们支持了在导出模型时保存 **[Ollama](https://github.com/ollama/ollama)** 配置文件。详细用法请参照 [examples](examples/README_zh.md)。 - -[25/02/05] 我们支持了在语音理解任务上微调 **[Qwen2-Audio](Qwen/Qwen2-Audio-7B-Instruct)** 和 **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** 模型。 - -[25/01/31] 我们支持了 **[DeepSeek-R1](https://huggingface.co/deepseek-ai/DeepSeek-R1)** 和 **[Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)** 模型的微调。 - -[25/01/15] 我们支持了 **[APOLLO](https://arxiv.org/abs/2412.05270)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。 - -[25/01/14] 我们支持了 **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** 和 **[MiniCPM-V-2.6](https://huggingface.co/openbmb/MiniCPM-V-2_6)** 模型的微调。 感谢 [@BUAADreamer](https://github.com/BUAADreamer) 的 PR. - -[25/01/14] 我们支持了 **[InternLM 3](https://huggingface.co/collections/internlm/)** 模型的微调。感谢 [@hhaAndroid](https://github.com/hhaAndroid) 的 PR。 - -[25/01/10] 我们支持了 **[Phi-4](https://huggingface.co/microsoft/phi-4)** 模型的微调。 - -[24/12/21] 我们支持了使用 **[SwanLab](https://github.com/SwanHubX/SwanLab)** 跟踪与可视化实验。详细用法请参考 [此部分](#使用-swanlab-面板)。 - -[24/11/27] 我们支持了 **[Skywork-o1](https://huggingface.co/Skywork/Skywork-o1-Open-Llama-3.1-8B)** 模型的微调和 **[OpenO1](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT)** 数据集。 - -[24/10/09] 我们支持了从 **[魔乐社区](https://modelers.cn/models)** 下载预训练模型和数据集。详细用法请参照 [此教程](#从魔乐社区下载)。 - -[24/09/19] 我们支持了 **[Qwen2.5](https://qwenlm.github.io/blog/qwen2.5/)** 模型的微调。 - -[24/08/30] 我们支持了 **[Qwen2-VL](https://qwenlm.github.io/blog/qwen2-vl/)** 模型的微调。感谢 [@simonJJJ](https://github.com/simonJJJ) 的 PR。 - -[24/08/27] 我们支持了 **[Liger Kernel](https://github.com/linkedin/Liger-Kernel)**。请使用 `enable_liger_kernel: true` 来加速训练。 - -[24/08/09] 我们支持了 **[Adam-mini](https://github.com/zyushun/Adam-mini)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@relic-yuexi](https://github.com/relic-yuexi) 的 PR。 - -[24/07/04] 我们支持了[无污染打包训练](https://github.com/MeetKai/functionary/tree/main/functionary/train/packing)。请使用 `neat_packing: true` 参数。感谢 [@chuan298](https://github.com/chuan298) 的 PR。 - -[24/06/16] 我们支持了 **[PiSSA](https://arxiv.org/abs/2404.02948)** 算法。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/06/07] 我们支持了 **[Qwen2](https://qwenlm.github.io/blog/qwen2/)** 和 **[GLM-4](https://github.com/THUDM/GLM-4)** 模型的微调。 - -[24/05/26] 我们支持了 **[SimPO](https://arxiv.org/abs/2405.14734)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/05/20] 我们支持了 **PaliGemma** 系列模型的微调。注意 PaliGemma 是预训练模型,你需要使用 `paligemma` 模板进行微调使其获得对话能力。 - -[24/05/18] 我们支持了 **[KTO](https://arxiv.org/abs/2402.01306)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/05/14] 我们支持了昇腾 NPU 设备的训练和推理。详情请查阅[安装](#安装-llama-factory)部分。 - -[24/04/26] 我们支持了多模态模型 **LLaVA-1.5** 的微调。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/04/22] 我们提供了在免费 T4 GPU 上微调 Llama-3 模型的 **[Colab 笔记本](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)**。Hugging Face 社区公开了两个利用 LLaMA Factory 微调的 Llama-3 模型,详情请见 [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) 和 [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese)。 - -[24/04/21] 我们基于 [AstraMindAI 的仓库](https://github.com/astramind-ai/Mixture-of-depths)支持了 **[混合深度训练](https://arxiv.org/abs/2404.02258)**。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/04/16] 我们支持了 **[BAdam](https://arxiv.org/abs/2404.02827)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/04/16] 我们支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的长序列训练(24GB 可训练 Llama-2-7B-56k)。该方法相比 FlashAttention-2 提供了 **117%** 的训练速度和 **50%** 的显存节约。更多数据请见[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。 - -[24/03/31] 我们支持了 **[ORPO](https://arxiv.org/abs/2403.07691)**。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/03/21] 我们的论文 "[LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models](https://arxiv.org/abs/2403.13372)" 可在 arXiv 上查看! - -[24/03/20] 我们支持了能在 2x24GB GPU 上微调 70B 模型的 **FSDP+QLoRA**。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/03/13] 我们支持了 **[LoRA+](https://arxiv.org/abs/2402.12354)**。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/03/07] 我们支持了 **[GaLore](https://arxiv.org/abs/2403.03507)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/03/07] 我们集成了 **[vLLM](https://github.com/vllm-project/vllm)** 以实现极速并发推理。请使用 `infer_backend: vllm` 来获得 **270%** 的推理速度。 - -[24/02/28] 我们支持了 **[DoRA](https://arxiv.org/abs/2402.09353)** 微调。请使用 `use_dora: true` 参数进行 DoRA 微调。 - -[24/02/15] 我们支持了 [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro) 提出的**块扩展**方法。详细用法请参照 [examples](examples/README_zh.md)。 - -[24/02/05] Qwen1.5(Qwen2 测试版)系列模型已在 LLaMA-Factory 中实现微调支持。详情请查阅该[博客页面](https://qwenlm.github.io/zh/blog/qwen1.5/)。 - -[24/01/18] 我们针对绝大多数模型实现了 **Agent 微调**,微调时指定 `dataset: glaive_toolcall_zh` 即可使模型获得工具调用能力。 - -[23/12/23] 我们针对 LLaMA, Mistral 和 Yi 模型支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的 LoRA 训练加速。请使用 `use_unsloth: true` 参数启用 unsloth 优化。该方法可提供 **170%** 的训练速度,详情请查阅[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。 - -[23/12/12] 我们支持了微调最新的混合专家模型 **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)**。硬件需求请查阅[此处](#硬件依赖)。 - -[23/12/01] 我们支持了从 **[魔搭社区](https://modelscope.cn/models)** 下载预训练模型和数据集。详细用法请参照 [此教程](#从魔搭社区下载)。 - -[23/10/21] 我们支持了 **[NEFTune](https://arxiv.org/abs/2310.05914)** 训练技巧。请使用 `neftune_noise_alpha: 5` 参数启用 NEFTune。 - -[23/09/27] 我们针对 LLaMA 模型支持了 [LongLoRA](https://github.com/dvlab-research/LongLoRA) 提出的 **$S^2$-Attn**。请使用 `shift_attn: true` 参数以启用该功能。 - -[23/09/23] 我们在项目中集成了 MMLU、C-Eval 和 CMMLU 评估集。详细用法请参照 [examples](examples/README_zh.md)。 - -[23/09/10] 我们支持了 **[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)**。如果您使用的是 RTX4090、A100 或 H100 GPU,请使用 `flash_attn: fa2` 参数以启用 FlashAttention-2。 - -[23/08/12] 我们支持了 **RoPE 插值**来扩展 LLaMA 模型的上下文长度。请使用 `rope_scaling: linear` 参数训练模型或使用 `rope_scaling: dynamic` 参数评估模型。 - -[23/08/11] 我们支持了指令模型的 **[DPO 训练](https://arxiv.org/abs/2305.18290)**。详细用法请参照 [examples](examples/README_zh.md)。 - -[23/07/31] 我们支持了**数据流式加载**。请使用 `streaming: true` 和 `max_steps: 10000` 参数来流式加载数据集。 - -[23/07/29] 我们在 Hugging Face 发布了两个 13B 指令微调模型。详细内容请查阅我们的 Hugging Face 项目([LLaMA-2](https://huggingface.co/hiyouga/Llama-2-Chinese-13b-chat) / [Baichuan](https://huggingface.co/hiyouga/Baichuan-13B-sft))。 - -[23/07/18] 我们开发了支持训练和测试的**浏览器一体化界面**。请使用 `train_web.py` 在您的浏览器中微调模型。感谢 [@KanadeSiina](https://github.com/KanadeSiina) 和 [@codemayq](https://github.com/codemayq) 在该功能开发中付出的努力。 - -[23/07/09] 我们开源了 **[FastEdit](https://github.com/hiyouga/FastEdit)** ⚡🩹,一个简单易用的、能迅速编辑大模型事实记忆的工具包。如果您感兴趣请关注我们的 [FastEdit](https://github.com/hiyouga/FastEdit) 项目。 - -[23/06/29] 我们提供了一个**可复现的**指令模型微调示例,详细内容请查阅 [Baichuan-7B-sft](https://huggingface.co/hiyouga/Baichuan-7B-sft)。 - -[23/06/22] 我们对齐了[示例 API](src/api_demo.py) 与 [OpenAI API](https://platform.openai.com/docs/api-reference/chat) 的格式,您可以将微调模型接入**任意基于 ChatGPT 的应用**中。 - -[23/06/03] 我们实现了 4 比特的 LoRA 训练(也称 **[QLoRA](https://github.com/artidoro/qlora)**)。详细用法请参照 [examples](examples/README_zh.md)。 - -
- -> [!TIP] -> 如果您无法使用最新的功能,请尝试重新拉取代码并再次安装 LLaMA-Factory。 - -## 模型 - -| 模型名 | 参数量 | Template | -| ----------------------------------------------------------------- | -------------------------------- | ------------------- | -| [Baichuan 2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 | -| [BLOOM/BLOOMZ](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - | -| [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 | -| [Command R](https://huggingface.co/CohereForAI) | 35B/104B | cohere | -| [DeepSeek (Code/MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek | -| [DeepSeek 2.5/3](https://huggingface.co/deepseek-ai) | 236B/671B | deepseek3 | -| [DeepSeek R1 (Distill)](https://huggingface.co/deepseek-ai) | 1.5B/7B/8B/14B/32B/70B/671B | deepseekr1 | -| [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon | -| [Falcon-H1](https://huggingface.co/tiiuae) | 0.5B/1.5B/3B/7B/34B | falcon_h1 | -| [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma/gemma2 | -| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3/gemma3n | -| [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/THUDM) | 9B/32B | glm4/glmz1 | -| [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | -| [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | -| [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | -| [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | -| [Index](https://huggingface.co/IndexTeam) | 1.9B | index | -| [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 | -| [InternVL 2.5-3](https://huggingface.co/OpenGVLab) | 1B/2B/8B/14B/38B/78B | intern_vl | -| [Kimi-VL](https://huggingface.co/moonshotai) | 16B | kimi_vl | -| [Llama](https://github.com/facebookresearch/llama) | 7B/13B/33B/65B | - | -| [Llama 2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 | -| [Llama 3-3.3](https://huggingface.co/meta-llama) | 1B/3B/8B/70B | llama3 | -| [Llama 4](https://huggingface.co/meta-llama) | 109B/402B | llama4 | -| [Llama 3.2 Vision](https://huggingface.co/meta-llama) | 11B/90B | mllama | -| [LLaVA-1.5](https://huggingface.co/llava-hf) | 7B/13B | llava | -| [LLaVA-NeXT](https://huggingface.co/llava-hf) | 7B/8B/13B/34B/72B/110B | llava_next | -| [LLaVA-NeXT-Video](https://huggingface.co/llava-hf) | 7B/34B | llava_next_video | -| [MiMo](https://huggingface.co/XiaomiMiMo) | 7B | mimo | -| [MiniCPM](https://huggingface.co/openbmb) | 0.5B/1B/2B/4B/8B | cpm/cpm3/cpm4 | -| [MiniCPM-o-2.6/MiniCPM-V-2.6](https://huggingface.co/openbmb) | 8B | minicpm_o/minicpm_v | -| [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral | -| [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral | -| [Mistral Small](https://huggingface.co/mistralai) | 24B | mistral_small | -| [OLMo](https://huggingface.co/allenai) | 1B/7B | - | -| [PaliGemma/PaliGemma2](https://huggingface.co/google) | 3B/10B/28B | paligemma | -| [Phi-1.5/Phi-2](https://huggingface.co/microsoft) | 1.3B/2.7B | - | -| [Phi-3/Phi-3.5](https://huggingface.co/microsoft) | 4B/14B | phi | -| [Phi-3-small](https://huggingface.co/microsoft) | 7B | phi_small | -| [Phi-4](https://huggingface.co/microsoft) | 14B | phi4 | -| [Pixtral](https://huggingface.co/mistralai) | 12B | pixtral | -| [Qwen (1-2.5) (Code/Math/MoE/QwQ)](https://huggingface.co/Qwen) | 0.5B/1.5B/3B/7B/14B/32B/72B/110B | qwen | -| [Qwen3 (MoE)](https://huggingface.co/Qwen) | 0.6B/1.7B/4B/8B/14B/32B/235B | qwen3 | -| [Qwen2-Audio](https://huggingface.co/Qwen) | 7B | qwen2_audio | -| [Qwen2.5-Omni](https://huggingface.co/Qwen) | 3B/7B | qwen2_omni | -| [Qwen2-VL/Qwen2.5-VL/QVQ](https://huggingface.co/Qwen) | 2B/3B/7B/32B/72B | qwen2_vl | -| [Seed Coder](https://huggingface.co/ByteDance-Seed) | 8B | seed_coder | -| [Skywork o1](https://huggingface.co/Skywork) | 8B | skywork_o1 | -| [StarCoder 2](https://huggingface.co/bigcode) | 3B/7B/15B | - | -| [TeleChat2](https://huggingface.co/Tele-AI) | 3B/7B/35B/115B | telechat2 | -| [XVERSE](https://huggingface.co/xverse) | 7B/13B/65B | xverse | -| [Yi/Yi-1.5 (Code)](https://huggingface.co/01-ai) | 1.5B/6B/9B/34B | yi | -| [Yi-VL](https://huggingface.co/01-ai) | 6B/34B | yi_vl | -| [Yuan 2](https://huggingface.co/IEITYuan) | 2B/51B/102B | yuan | - -> [!NOTE] -> 对于所有“基座”(Base)模型,`template` 参数可以是 `default`, `alpaca`, `vicuna` 等任意值。但“对话”(Instruct/Chat)模型请务必使用**对应的模板**。 -> -> 请务必在训练和推理时采用**完全一致**的模板。 -> -> \*:您需要从 main 分支安装 `transformers` 并使用 `DISABLE_VERSION_CHECK=1` 来跳过版本检查。 -> -> \*\*:您需要安装特定版本的 `transformers` 以使用该模型。 - -项目所支持模型的完整列表请参阅 [constants.py](src/llamafactory/extras/constants.py)。 - -您也可以在 [template.py](src/llamafactory/data/template.py) 中添加自己的对话模板。 - -## 训练方法 - -| 方法 | 全参数训练 | 部分参数训练 | LoRA | QLoRA | -| --------------------- | ------------------ | ------------------ | ------------------ | ------------------ | -| 预训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 指令监督微调 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 奖励模型训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| PPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| DPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| KTO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| ORPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| SimPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | - -> [!TIP] -> 有关 PPO 的实现细节,请参考[此博客](https://newfacade.github.io/notes-on-reinforcement-learning/17-ppo-trl.html)。 - -## 数据集 - -
预训练数据集 - -- [Wiki Demo (en)](data/wiki_demo.txt) -- [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) -- [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2) -- [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220) -- [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered) -- [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile) -- [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B) -- [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb) -- [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) -- [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack) -- [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata) - -
- -
指令微调数据集 - -- [Identity (en&zh)](data/identity.json) -- [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca) -- [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3) -- [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM) -- [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) -- [LIMA (en)](https://huggingface.co/datasets/GAIR/lima) -- [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset) -- [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN) -- [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN) -- [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN) -- [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M) -- [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M) -- [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M) -- [UltraChat (en)](https://github.com/thunlp/UltraChat) -- [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus) -- [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k) -- [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT) -- [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca) -- [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca) -- [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) -- [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M) -- [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa) -- [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa) -- [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data) -- [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen) -- [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k) -- [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4) -- [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) -- [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct) -- [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) -- [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k) -- [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia) -- [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction) -- [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo) -- [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2) -- [Magpie-Pro-300K-Filtered (en)](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-300K-Filtered) -- [Magpie-ultra-v0.1 (en)](https://huggingface.co/datasets/argilla/magpie-ultra-v0.1) -- [WebInstructSub (en)](https://huggingface.co/datasets/TIGER-Lab/WebInstructSub) -- [OpenO1-SFT (en&zh)](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT) -- [Open-Thoughts (en)](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) -- [Open-R1-Math (en)](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) -- [Chinese-DeepSeek-R1-Distill (zh)](https://huggingface.co/datasets/Congliu/Chinese-DeepSeek-R1-Distill-data-110k-SFT) -- [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k) -- [Pokemon-gpt4o-captions (en&zh)](https://huggingface.co/datasets/jugg1024/pokemon-gpt4o-captions) -- [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de) -- [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de) -- [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de) -- [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de) -- [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de) -- [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de) -- [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de) -- [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de) -- [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de) - -
- -
偏好数据集 - -- [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k) -- [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized) -- [COIG-P (zh)](https://huggingface.co/datasets/m-a-p/COIG-P) -- [RLHF-V (en)](https://huggingface.co/datasets/openbmb/RLHF-V-Dataset) -- [VLFeedback (en)](https://huggingface.co/datasets/Zhihui/VLFeedback) -- [RLAIF-V (en)](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset) -- [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs) -- [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf) -- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar) -- [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de) -- [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k) - -
- -部分数据集的使用需要确认,我们推荐使用下述命令登录您的 Hugging Face 账户。 - -```bash -pip install --upgrade huggingface_hub -huggingface-cli login -``` - -## 软硬件依赖 - -| 必需项 | 至少 | 推荐 | -| ------------ | ------- | --------- | -| python | 3.9 | 3.10 | -| torch | 2.0.0 | 2.6.0 | -| torchvision | 0.15.0 | 0.21.0 | -| transformers | 4.49.0 | 4.50.0 | -| datasets | 2.16.0 | 3.2.0 | -| accelerate | 0.34.0 | 1.2.1 | -| peft | 0.14.0 | 0.15.1 | -| trl | 0.8.6 | 0.9.6 | - -| 可选项 | 至少 | 推荐 | -| ------------ | ------- | --------- | -| CUDA | 11.6 | 12.2 | -| deepspeed | 0.10.0 | 0.16.4 | -| bitsandbytes | 0.39.0 | 0.43.1 | -| vllm | 0.4.3 | 0.8.2 | -| flash-attn | 2.5.6 | 2.7.2 | - -### 硬件依赖 - -\* *估算值* - -| 方法 | 精度 | 7B | 14B | 30B | 70B | `x`B | -| ------------------------------- | ---- | ----- | ----- | ----- | ------ | ------- | -| Full (`bf16` or `fp16`) | 32 | 120GB | 240GB | 600GB | 1200GB | `18x`GB | -| Full (`pure_bf16`) | 16 | 60GB | 120GB | 300GB | 600GB | `8x`GB | -| Freeze/LoRA/GaLore/APOLLO/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | `2x`GB | -| QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | `x`GB | -| QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | `x/2`GB | -| QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | `x/4`GB | - -## 如何使用 - -### 安装 LLaMA Factory - -> [!IMPORTANT] -> 此步骤为必需。 - -#### 从源码安装 - -```bash -git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git -cd LLaMA-Factory -pip install -e ".[torch,metrics]" --no-build-isolation -``` - -可选的额外依赖项:torch、torch-npu、metrics、deepspeed、liger-kernel、bitsandbytes、hqq、eetq、gptq、aqlm、vllm、sglang、galore、apollo、badam、adam-mini、qwen、minicpm_v、openmind、swanlab、dev - -#### 从镜像安装 - -```bash -docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest -``` - -该镜像基于 Ubuntu 22.04(x86\_64)、CUDA 12.4、Python 3.11、PyTorch 2.6.0 和 Flash-attn 2.7.4 构建。 - -查看全部镜像:https://hub.docker.com/r/hiyouga/llamafactory/tags - -请参阅[构建 Docker](#构建-docker) 来重新构建镜像。 - -
使用 uv 构建虚拟环境 - -使用 [uv](https://github.com/astral-sh/uv) 创建隔离的 Python 环境: - -```bash -uv sync --extra torch --extra metrics --prerelease=allow -``` - -在环境中运行 LLaMA-Factory: - -```bash -uv run --prerelease=allow llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml -``` - -
- -
Windows 用户指南 - -#### 安装 PyTorch - -Windows 平台需要额外手动安装 GPU 版本的 PyTorch 依赖包,您可以参考[官方网站](https://pytorch.org/get-started/locally/)和以下命令安装并测试 PyTorch 是否正确安装。 - -```bash -pip uninstall torch torchvision torchaudio -pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 -python -c "import torch; print(torch.cuda.is_available())" -``` - -如果看到 `True` 则说明安装成功。 - -若遇到类似 `Can't pickle local object` 的报错,请设置 `dataloader_num_workers: 0`。 - -#### 安装 BitsAndBytes - -如果要在 Windows 平台上开启量化 LoRA(QLoRA),需要安装预编译的 `bitsandbytes` 库, 支持 CUDA 11.1 到 12.2, 请根据您的 CUDA 版本情况选择适合的[发布版本](https://github.com/jllllll/bitsandbytes-windows-webui/releases/tag/wheels)。 - -```bash -pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl -``` - -#### 安装 Flash Attention-2 - -如果要在 Windows 平台上开启 FlashAttention-2,请使用 [flash-attention-windows-wheel](https://huggingface.co/lldacing/flash-attention-windows-wheel) 中的脚本自行编译与安装。 - -
- -
昇腾 NPU 用户指南 - -在昇腾 NPU 设备上安装 LLaMA Factory 时,请升级 Python 到 3.10 及以上,并需要指定额外依赖项,使用 `pip install -e ".[torch-npu,metrics]"` 命令安装。此外,还需要安装 **[Ascend CANN Toolkit 与 Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**,安装方法请参考[安装教程](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)或使用以下命令: - -```bash -# 请替换 URL 为 CANN 版本和设备型号对应的 URL -# 安装 CANN Toolkit -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run -bash Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install - -# 安装 CANN Kernels -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run -bash Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install - -# 设置环境变量 -source /usr/local/Ascend/ascend-toolkit/set_env.sh -``` - -| 依赖项 | 至少 | 推荐 | -| ------------ | ------- | -------------- | -| CANN | 8.0.RC1 | 8.0.0.alpha002 | -| torch | 2.1.0 | 2.4.0 | -| torch-npu | 2.1.0 | 2.4.0.post2 | -| deepspeed | 0.13.2 | 0.13.2 | -| vllm-ascend | - | 0.7.3 | - -请使用 `ASCEND_RT_VISIBLE_DEVICES` 而非 `CUDA_VISIBLE_DEVICES` 来指定运算设备。 - -如果遇到无法正常推理的情况,请尝试设置 `do_sample: false`。 - -下载预构建 Docker 镜像:[32GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html) | [64GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html) - -#### 安装 BitsAndBytes - -如果要在 Ascend NPU 上进行基于 bitsandbytes 的 QLoRA 量化微调,请执行如下步骤: - -1. 手动编译 bitsandbytes:请参考[安装文档](https://huggingface.co/docs/bitsandbytes/installation?backend=Ascend+NPU&platform=Ascend+NPU)完成 NPU 版的 bitsandbytes 安装,编译要求环境 cmake 版本不低于 3.22.1,g++ 版本不低于 12.x。 - -```bash -# 从源码安装 bitsandbytes -# 克隆 bitsandbytes 仓库, Ascend NPU 目前在 multi-backend-refactor 中支持 -git clone -b multi-backend-refactor https://github.com/bitsandbytes-foundation/bitsandbytes.git -cd bitsandbytes/ - -# 安装依赖 -pip install -r requirements-dev.txt - -# 安装编译工具依赖,该步骤在不同系统上命令有所不同,供参考 -apt-get install -y build-essential cmake - -# 编译 & 安装 -cmake -DCOMPUTE_BACKEND=npu -S . -make -pip install . -``` - -2. 安装 transformers 的 main 分支版本。 - -```bash -git clone -b main https://github.com/huggingface/transformers.git -cd transformers -pip install . -``` - -3. 在训练参数中设置 `double_quantization: false`,可参考[示例](examples/train_qlora/llama3_lora_sft_bnb_npu.yaml)。 - -
- -### 数据准备 - -关于数据集文件的格式,请参考 [data/README_zh.md](data/README_zh.md) 的内容。你可以使用 HuggingFace / ModelScope / Modelers 上的数据集或加载本地数据集。 - -> [!NOTE] -> 使用自定义数据集时,请更新 `data/dataset_info.json` 文件。 - -您也可以使用 **[Easy Dataset](https://github.com/ConardLi/easy-dataset)** 或 **[GraphGen](https://github.com/open-sciencelab/GraphGen)** 构建用于微调的合成数据。 - -### 快速开始 - -下面三行命令分别对 Llama3-8B-Instruct 模型进行 LoRA **微调**、**推理**和**合并**。 - -```bash -llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml -llamafactory-cli chat examples/inference/llama3_lora_sft.yaml -llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml -``` - -高级用法请参考 [examples/README_zh.md](examples/README_zh.md)(包括多 GPU 微调)。 - -> [!TIP] -> 使用 `llamafactory-cli help` 显示帮助信息。 -> -> 遇到报错请先看[常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614)。 - -### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动) - -```bash -llamafactory-cli webui -``` - -### 构建 Docker - -CUDA 用户: - -```bash -cd docker/docker-cuda/ -docker compose up -d -docker compose exec llamafactory bash -``` - -昇腾 NPU 用户: - -```bash -cd docker/docker-npu/ -docker compose up -d -docker compose exec llamafactory bash -``` - -AMD ROCm 用户: - -```bash -cd docker/docker-rocm/ -docker compose up -d -docker compose exec llamafactory bash -``` - -
不使用 Docker Compose 构建 - -CUDA 用户: - -```bash -docker build -f ./docker/docker-cuda/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host --gpus=all \ - -p 7860:7860 \ - -p 8000:8000 \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -昇腾 NPU 用户: - -```bash -docker build -f ./docker/docker-npu/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=torch-npu,metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host \ - -v /usr/local/dcmi:/usr/local/dcmi \ - -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ - -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ - -v /etc/ascend_install.info:/etc/ascend_install.info \ - -p 7860:7860 \ - -p 8000:8000 \ - --device /dev/davinci0 \ - --device /dev/davinci_manager \ - --device /dev/devmm_svm \ - --device /dev/hisi_hdc \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -AMD ROCm 用户: - -```bash -docker build -f ./docker/docker-rocm/Dockerfile \ - --build-arg PIP_INDEX=https://pypi.org/simple \ - --build-arg EXTRAS=metrics \ - -t llamafactory:latest . - -docker run -dit --ipc=host \ - -p 7860:7860 \ - -p 8000:8000 \ - --device /dev/kfd \ - --device /dev/dri \ - --name llamafactory \ - llamafactory:latest - -docker exec -it llamafactory bash -``` - -
- -
使用数据卷 - -您可以通过移除 Dockerfile 中 `VOLUME [ "/root/.cache/huggingface", "/app/shared_data", "/app/output" ]` 的注释来使用数据卷。 - -在构建 Docker 时使用参数 `-v ./hf_cache:/root/.cache/huggingface` 来挂载数据卷。各个数据卷的含义表示如下。 - -- `hf_cache`:使用宿主机的 Hugging Face 缓存文件夹。 -- `shared_data`:宿主机中存放数据集的文件夹路径。 -- `output`:将导出目录设置为该路径后,即可在宿主机中访问导出后的模型。 - -
- -### 利用 vLLM 部署 OpenAI API - -```bash -API_PORT=8000 llamafactory-cli api examples/inference/llama3.yaml infer_backend=vllm vllm_enforce_eager=true -``` - -> [!TIP] -> API 文档请查阅[这里](https://platform.openai.com/docs/api-reference/chat/create)。 -> -> 示例:[图像理解](scripts/api_example/test_image.py) | [工具调用](scripts/api_example/test_toolcall.py) - -### 从魔搭社区下载 - -如果您在 Hugging Face 模型和数据集的下载中遇到了问题,可以通过下述方法使用魔搭社区。 - -```bash -export USE_MODELSCOPE_HUB=1 # Windows 使用 `set USE_MODELSCOPE_HUB=1` -``` - -将 `model_name_or_path` 设置为模型 ID 来加载对应的模型。在[魔搭社区](https://modelscope.cn/models)查看所有可用的模型,例如 `LLM-Research/Meta-Llama-3-8B-Instruct`。 - -### 从魔乐社区下载 - -您也可以通过下述方法,使用魔乐社区下载数据集和模型。 - -```bash -export USE_OPENMIND_HUB=1 # Windows 使用 `set USE_OPENMIND_HUB=1` -``` - -将 `model_name_or_path` 设置为模型 ID 来加载对应的模型。在[魔乐社区](https://modelers.cn/models)查看所有可用的模型,例如 `TeleAI/TeleChat-7B-pt`。 - -### 使用 W&B 面板 - -若要使用 [Weights & Biases](https://wandb.ai) 记录实验数据,请在 yaml 文件中添加下面的参数。 - -```yaml -report_to: wandb -run_name: test_run # 可选 -``` - -在启动训练任务时,将 `WANDB_API_KEY` 设置为[密钥](https://wandb.ai/authorize)来登录 W&B 账户。 - -### 使用 SwanLab 面板 - -若要使用 [SwanLab](https://github.com/SwanHubX/SwanLab) 记录实验数据,请在 yaml 文件中添加下面的参数。 - -```yaml -use_swanlab: true -swanlab_run_name: test_run # 可选 -``` - -在启动训练任务时,登录SwanLab账户有以下三种方式: - -方式一:在 yaml 文件中添加 `swanlab_api_key=` ,并设置为你的 [API 密钥](https://swanlab.cn/settings)。 -方式二:将环境变量 `SWANLAB_API_KEY` 设置为你的 [API 密钥](https://swanlab.cn/settings)。 -方式三:启动前使用 `swanlab login` 命令完成登录。 - -## 使用了 LLaMA Factory 的项目 - -如果您有项目希望添加至下述列表,请通过邮件联系或者创建一个 PR。 - -
点击显示 - -1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223) -1. Yu et al. Open, Closed, or Small Language Models for Text Classification? 2023. [[arxiv]](https://arxiv.org/abs/2308.10092) -1. Wang et al. UbiPhysio: Support Daily Functioning, Fitness, and Rehabilitation with Action Understanding and Feedback in Natural Language. 2023. [[arxiv]](https://arxiv.org/abs/2308.10526) -1. Luceri et al. Leveraging Large Language Models to Detect Influence Campaigns in Social Media. 2023. [[arxiv]](https://arxiv.org/abs/2311.07816) -1. Zhang et al. Alleviating Hallucinations of Large Language Models through Induced Hallucinations. 2023. [[arxiv]](https://arxiv.org/abs/2312.15710) -1. Wang et al. Know Your Needs Better: Towards Structured Understanding of Marketer Demands with Analogical Reasoning Augmented LLMs. KDD 2024. [[arxiv]](https://arxiv.org/abs/2401.04319) -1. Wang et al. CANDLE: Iterative Conceptualization and Instantiation Distillation from Large Language Models for Commonsense Reasoning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2401.07286) -1. Choi et al. FACT-GPT: Fact-Checking Augmentation via Claim Matching with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2402.05904) -1. Zhang et al. AutoMathText: Autonomous Data Selection with Language Models for Mathematical Texts. 2024. [[arxiv]](https://arxiv.org/abs/2402.07625) -1. Lyu et al. KnowTuning: Knowledge-aware Fine-tuning for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11176) -1. Yang et al. LaCo: Large Language Model Pruning via Layer Collaps. 2024. [[arxiv]](https://arxiv.org/abs/2402.11187) -1. Bhardwaj et al. Language Models are Homer Simpson! Safety Re-Alignment of Fine-tuned Language Models through Task Arithmetic. 2024. [[arxiv]](https://arxiv.org/abs/2402.11746) -1. Yang et al. Enhancing Empathetic Response Generation by Augmenting LLMs with Small-scale Empathetic Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11801) -1. Yi et al. Generation Meets Verification: Accelerating Large Language Model Inference with Smart Parallel Auto-Correct Decoding. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2402.11809) -1. Cao et al. Head-wise Shareable Attention for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11819) -1. Zhang et al. Enhancing Multilingual Capabilities of Large Language Models through Self-Distillation from Resource-Rich Languages. 2024. [[arxiv]](https://arxiv.org/abs/2402.12204) -1. Kim et al. Efficient and Effective Vocabulary Expansion Towards Multilingual Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.14714) -1. Yu et al. KIEval: A Knowledge-grounded Interactive Evaluation Framework for Large Language Models. ACL 2024. [[arxiv]](https://arxiv.org/abs/2402.15043) -1. Huang et al. Key-Point-Driven Data Synthesis with its Enhancement on Mathematical Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2403.02333) -1. Duan et al. Negating Negatives: Alignment without Human Positive Samples via Distributional Dispreference Optimization. 2024. [[arxiv]](https://arxiv.org/abs/2403.03419) -1. Xie and Schwertfeger. Empowering Robotics with Large Language Models: osmAG Map Comprehension with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2403.08228) -1. Wu et al. Large Language Models are Parallel Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2403.09073) -1. Zhang et al. EDT: Improving Large Language Models' Generation by Entropy-based Dynamic Temperature Sampling. 2024. [[arxiv]](https://arxiv.org/abs/2403.14541) -1. Weller et al. FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2403.15246) -1. Hongbin Na. CBT-LLM: A Chinese Large Language Model for Cognitive Behavioral Therapy-based Mental Health Question Answering. COLING 2024. [[arxiv]](https://arxiv.org/abs/2403.16008) -1. Zan et al. CodeS: Natural Language to Code Repository via Multi-Layer Sketch. 2024. [[arxiv]](https://arxiv.org/abs/2403.16443) -1. Liu et al. Extensive Self-Contrast Enables Feedback-Free Language Model Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2404.00604) -1. Luo et al. BAdam: A Memory Efficient Full Parameter Training Method for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.02827) -1. Du et al. Chinese Tiny LLM: Pretraining a Chinese-Centric Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2404.04167) -1. Ma et al. Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation. ICML 2024. [[arxiv]](https://arxiv.org/abs/2404.04316) -1. Liu et al. Dynamic Generation of Personalities with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.07084) -1. Shang et al. How Far Have We Gone in Stripped Binary Code Understanding Using Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.09836) -1. Huang et al. LLMTune: Accelerate Database Knob Tuning with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.11581) -1. Deng et al. Text-Tuple-Table: Towards Information Integration in Text-to-Table Generation via Global Tuple Extraction. 2024. [[arxiv]](https://arxiv.org/abs/2404.14215) -1. Acikgoz et al. Hippocrates: An Open-Source Framework for Advancing Large Language Models in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2404.16621) -1. Zhang et al. Small Language Models Need Strong Verifiers to Self-Correct Reasoning. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2404.17140) -1. Zhou et al. FREB-TQA: A Fine-Grained Robustness Evaluation Benchmark for Table Question Answering. NAACL 2024. [[arxiv]](https://arxiv.org/abs/2404.18585) -1. Xu et al. Large Language Models for Cyber Security: A Systematic Literature Review. 2024. [[arxiv]](https://arxiv.org/abs/2405.04760) -1. Dammu et al. "They are uncultured": Unveiling Covert Harms and Social Threats in LLM Generated Conversations. 2024. [[arxiv]](https://arxiv.org/abs/2405.05378) -1. Yi et al. A safety realignment framework via subspace-oriented model fusion for large language models. 2024. [[arxiv]](https://arxiv.org/abs/2405.09055) -1. Lou et al. SPO: Multi-Dimensional Preference Sequential Alignment With Implicit Reward Modeling. 2024. [[arxiv]](https://arxiv.org/abs/2405.12739) -1. Zhang et al. Getting More from Less: Large Language Models are Good Spontaneous Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2405.13816) -1. Zhang et al. TS-Align: A Teacher-Student Collaborative Framework for Scalable Iterative Finetuning of Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2405.20215) -1. Zihong Chen. Sentence Segmentation and Sentence Punctuation Based on XunziALLM. 2024. [[paper]](https://aclanthology.org/2024.lt4hala-1.30) -1. Gao et al. The Best of Both Worlds: Toward an Honest and Helpful Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2406.00380) -1. Wang and Song. MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Dataset. 2024. [[arxiv]](https://arxiv.org/abs/2406.02106) -1. Hu et al. Computational Limits of Low-Rank Adaptation (LoRA) for Transformer-Based Models. 2024. [[arxiv]](https://arxiv.org/abs/2406.03136) -1. Ge et al. Time Sensitive Knowledge Editing through Efficient Finetuning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2406.04496) -1. Tan et al. Peer Review as A Multi-Turn and Long-Context Dialogue with Role-Based Interactions. 2024. [[arxiv]](https://arxiv.org/abs/2406.05688) -1. Song et al. Turbo Sparse: Achieving LLM SOTA Performance with Minimal Activated Parameters. 2024. [[arxiv]](https://arxiv.org/abs/2406.05955) -1. Gu et al. RWKV-CLIP: A Robust Vision-Language Representation Learner. 2024. [[arxiv]](https://arxiv.org/abs/2406.06973) -1. Chen et al. Advancing Tool-Augmented Large Language Models: Integrating Insights from Errors in Inference Trees. 2024. [[arxiv]](https://arxiv.org/abs/2406.07115) -1. Zhu et al. Are Large Language Models Good Statisticians?. 2024. [[arxiv]](https://arxiv.org/abs/2406.07815) -1. Li et al. Know the Unknown: An Uncertainty-Sensitive Method for LLM Instruction Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2406.10099) -1. Ding et al. IntentionQA: A Benchmark for Evaluating Purchase Intention Comprehension Abilities of Language Models in E-commerce. 2024. [[arxiv]](https://arxiv.org/abs/2406.10173) -1. He et al. COMMUNITY-CROSS-INSTRUCT: Unsupervised Instruction Generation for Aligning Large Language Models to Online Communities. 2024. [[arxiv]](https://arxiv.org/abs/2406.12074) -1. Lin et al. FVEL: Interactive Formal Verification Environment with Large Language Models via Theorem Proving. 2024. [[arxiv]](https://arxiv.org/abs/2406.14408) -1. Treutlein et al. Connecting the Dots: LLMs can Infer and Verbalize Latent Structure from Disparate Training Data. 2024. [[arxiv]](https://arxiv.org/abs/2406.14546) -1. Feng et al. SS-Bench: A Benchmark for Social Story Generation and Evaluation. 2024. [[arxiv]](https://arxiv.org/abs/2406.15695) -1. Feng et al. Self-Constructed Context Decompilation with Fined-grained Alignment Enhancement. 2024. [[arxiv]](https://arxiv.org/abs/2406.17233) -1. Liu et al. Large Language Models for Cuffless Blood Pressure Measurement From Wearable Biosignals. 2024. [[arxiv]](https://arxiv.org/abs/2406.18069) -1. Iyer et al. Exploring Very Low-Resource Translation with LLMs: The University of Edinburgh's Submission to AmericasNLP 2024 Translation Task. AmericasNLP 2024. [[paper]](https://aclanthology.org/2024.americasnlp-1.25) -1. Li et al. Calibrating LLMs with Preference Optimization on Thought Trees for Generating Rationale in Science Question Scoring. 2024. [[arxiv]](https://arxiv.org/abs/2406.19949) -1. Yang et al. Financial Knowledge Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2407.00365) -1. Lin et al. DogeRM: Equipping Reward Models with Domain Knowledge through Model Merging. 2024. [[arxiv]](https://arxiv.org/abs/2407.01470) -1. Bako et al. Evaluating the Semantic Profiling Abilities of LLMs for Natural Language Utterances in Data Visualization. 2024. [[arxiv]](https://arxiv.org/abs/2407.06129) -1. Huang et al. RoLoRA: Fine-tuning Rotated Outlier-free LLMs for Effective Weight-Activation Quantization. 2024. [[arxiv]](https://arxiv.org/abs/2407.08044) -1. Jiang et al. LLM-Collaboration on Automatic Science Journalism for the General Audience. 2024. [[arxiv]](https://arxiv.org/abs/2407.09756) -1. Inouye et al. Applied Auto-tuning on LoRA Hyperparameters. 2024. [[paper]](https://scholarcommons.scu.edu/cseng_senior/272/) -1. Qi et al. Research on Tibetan Tourism Viewpoints information generation system based on LLM. 2024. [[arxiv]](https://arxiv.org/abs/2407.13561) -1. Xu et al. Course-Correction: Safety Alignment Using Synthetic Preferences. 2024. [[arxiv]](https://arxiv.org/abs/2407.16637) -1. Sun et al. LAMBDA: A Large Model Based Data Agent. 2024. [[arxiv]](https://arxiv.org/abs/2407.17535) -1. Zhu et al. CollectiveSFT: Scaling Large Language Models for Chinese Medical Benchmark with Collective Instructions in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2407.19705) -1. Yu et al. Correcting Negative Bias in Large Language Models through Negative Attention Score Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2408.00137) -1. Xie et al. The Power of Personalized Datasets: Advancing Chinese Composition Writing for Elementary School through Targeted Model Fine-Tuning. IALP 2024. [[paper]](https://www.asianlp.sg/conferences/ialp2024/proceedings/papers/IALP2024_P055.pdf) -1. Liu et al. Instruct-Code-Llama: Improving Capabilities of Language Model in Competition Level Code Generation by Online Judge Feedback. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_11) -1. Wang et al. Cybernetic Sentinels: Unveiling the Impact of Safety Data Selection on Model Security in Supervised Fine-Tuning. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_23) -1. Xia et al. Understanding the Performance and Estimating the Cost of LLM Fine-Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2408.04693) -1. Zeng et al. Perceive, Reflect, and Plan: Designing LLM Agent for Goal-Directed City Navigation without Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2408.04168) -1. Xia et al. Using Pre-trained Language Model for Accurate ESG Prediction. FinNLP 2024. [[paper]](https://aclanthology.org/2024.finnlp-2.1/) -1. Liang et al. I-SHEEP: Self-Alignment of LLM from Scratch through an Iterative Self-Enhancement Paradigm. 2024. [[arxiv]](https://arxiv.org/abs/2408.08072) -1. Bai et al. Aligning Large Language Model with Direct Multi-Preference Optimization for Recommendation. CIKM 2024. [[paper]](https://dl.acm.org/doi/10.1145/3627673.3679611) -1. **[StarWhisper](https://github.com/Yu-Yang-Li/StarWhisper)**: 天文大模型 StarWhisper,基于 ChatGLM2-6B 和 Qwen-14B 在天文数据上微调而得。 -1. **[DISC-LawLLM](https://github.com/FudanDISC/DISC-LawLLM)**: 中文法律领域大模型 DISC-LawLLM,基于 Baichuan-13B 微调而得,具有法律推理和知识检索能力。 -1. **[Sunsimiao](https://github.com/X-D-Lab/Sunsimiao)**: 孙思邈中文医疗大模型 Sumsimiao,基于 Baichuan-7B 和 ChatGLM-6B 在中文医疗数据上微调而得。 -1. **[CareGPT](https://github.com/WangRongsheng/CareGPT)**: 医疗大模型项目 CareGPT,基于 LLaMA2-7B 和 Baichuan-13B 在中文医疗数据上微调而得。 -1. **[MachineMindset](https://github.com/PKU-YuanGroup/Machine-Mindset/)**:MBTI性格大模型项目,根据数据集与训练方式让任意 LLM 拥有 16 个不同的性格类型。 -1. **[Luminia-13B-v3](https://huggingface.co/Nekochu/Luminia-13B-v3)**:一个用于生成 Stable Diffusion 提示词的大型语言模型。[[demo]](https://huggingface.co/spaces/Nekochu/Luminia-13B_SD_Prompt) -1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**:中文多模态医学大模型,基于 LLaVA-1.5-7B 在中文多模态医疗数据上微调而得。 -1. **[AutoRE](https://github.com/THUDM/AutoRE)**:基于大语言模型的文档级关系抽取系统。 -1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**:在 Windows 主机上利用英伟达 RTX 设备进行大型语言模型微调的开发包。 -1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**:一个低代码构建多 Agent 大模型应用的开发工具,支持基于 LLaMA Factory 的模型微调. -1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**:一个全链路 RAG 检索模型微调、推理和蒸馏代码库。[[blog]](https://zhuanlan.zhihu.com/p/987727357) -1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**:一个魔改后的代码库,通过 Ring Attention 支持长序列的 SFT 和 DPO 训练。 -1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**:由 NovaSky AI 微调的低成本类 o1 长推理模型。 -1. **[WeClone](https://github.com/xming521/WeClone)**:从聊天记录创造数字分身的一站式解决方案。 - -
- -## 协议 - -本仓库的代码依照 [Apache-2.0](LICENSE) 协议开源。 - -使用模型权重时,请遵循对应的模型协议:[Baichuan 2](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/blob/main/Community%20License%20for%20Baichuan%202%20Model.pdf) / [BLOOM](https://huggingface.co/spaces/bigscience/license) / [ChatGLM3](https://github.com/THUDM/ChatGLM3/blob/main/MODEL_LICENSE) / [Command R](https://cohere.com/c4ai-cc-by-nc-license) / [DeepSeek](https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/LICENSE-MODEL) / [Falcon](https://huggingface.co/tiiuae/falcon-180B/blob/main/LICENSE.txt) / [Gemma](https://ai.google.dev/gemma/terms) / [GLM-4](https://huggingface.co/THUDM/glm-4-9b/blob/main/LICENSE) / [GPT-2](https://github.com/openai/gpt-2/blob/master/LICENSE) / [Granite](LICENSE) / [Index](https://huggingface.co/IndexTeam/Index-1.9B/blob/main/LICENSE) / [InternLM](https://github.com/InternLM/InternLM#license) / [Llama](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) / [Llama 2](https://ai.meta.com/llama/license/) / [Llama 3](https://llama.meta.com/llama3/license/) / [Llama 4](https://github.com/meta-llama/llama-models/blob/main/models/llama4/LICENSE) / [MiniCPM](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md) / [Mistral/Mixtral/Pixtral](LICENSE) / [OLMo](LICENSE) / [Phi-1.5/Phi-2](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx) / [Phi-3/Phi-4](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/LICENSE) / [Qwen](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) / [Skywork](https://huggingface.co/Skywork/Skywork-13B-base/blob/main/Skywork%20Community%20License.pdf) / [StarCoder 2](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) / [TeleChat2](https://huggingface.co/Tele-AI/telechat-7B/blob/main/TeleChat%E6%A8%A1%E5%9E%8B%E7%A4%BE%E5%8C%BA%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.pdf) / [XVERSE](https://github.com/xverse-ai/XVERSE-13B/blob/main/MODEL_LICENSE.pdf) / [Yi](https://huggingface.co/01-ai/Yi-6B/blob/main/LICENSE) / [Yi-1.5](LICENSE) / [Yuan 2](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/LICENSE-Yuan) - -## 引用 - -如果您觉得此项目有帮助,请考虑以下列格式引用 - -```bibtex -@inproceedings{zheng2024llamafactory, - title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models}, - author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma}, - booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)}, - address={Bangkok, Thailand}, - publisher={Association for Computational Linguistics}, - year={2024}, - url={http://arxiv.org/abs/2403.13372} -} -``` - -## 致谢 - -本项目受益于 [PEFT](https://github.com/huggingface/peft)、[TRL](https://github.com/huggingface/trl)、[QLoRA](https://github.com/artidoro/qlora) 和 [FastChat](https://github.com/lm-sys/FastChat),感谢以上诸位作者的付出。 - -## Star History - -![Star History Chart](https://api.star-history.com/svg?repos=hiyouga/LLaMA-Factory&type=Date) diff --git a/docker-hub/qwen2.5-vl/llama-factory/assets/alaya_new.svg b/docker-hub/qwen2.5-vl/llama-factory/assets/alaya_new.svg deleted file mode 100644 index 3568e1511fb758b46cfc84122554ea23c8a0b1c7..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/assets/alaya_new.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - background - - - - Layer 1 - - - - - - - - - Open in Alaya NeW - - - - - diff --git a/docker-hub/qwen2.5-vl/llama-factory/assets/logo.png b/docker-hub/qwen2.5-vl/llama-factory/assets/logo.png deleted file mode 100644 index 5fb3dd569342ca3cd30a582fd664145bd88b360c..0000000000000000000000000000000000000000 Binary files a/docker-hub/qwen2.5-vl/llama-factory/assets/logo.png and /dev/null differ diff --git a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat.jpg b/docker-hub/qwen2.5-vl/llama-factory/assets/wechat.jpg deleted file mode 100644 index af072fb433d83f137665ca30aeb50ad26c81af08..0000000000000000000000000000000000000000 Binary files a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat.jpg and /dev/null differ diff --git a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_alaya.png b/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_alaya.png deleted file mode 100644 index 4b638e1c559bcd685ac6a4abc47491c0126cc8bb..0000000000000000000000000000000000000000 Binary files a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_alaya.png and /dev/null differ diff --git a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_npu.jpg b/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_npu.jpg deleted file mode 100644 index 948754cc3f6d835fc8c8ce505a51c87d49f958d2..0000000000000000000000000000000000000000 Binary files a/docker-hub/qwen2.5-vl/llama-factory/assets/wechat_npu.jpg and /dev/null differ diff --git a/docker-hub/qwen2.5-vl/llama-factory/data/README.md b/docker-hub/qwen2.5-vl/llama-factory/data/README.md deleted file mode 100644 index 4cc92b43960dd78688010540418455448aabe63d..0000000000000000000000000000000000000000 --- a/docker-hub/qwen2.5-vl/llama-factory/data/README.md +++ /dev/null @@ -1,475 +0,0 @@ -The [dataset_info.json](dataset_info.json) contains all available datasets. If you are using a custom dataset, please **make sure** to add a *dataset description* in `dataset_info.json` and specify `dataset: dataset_name` before training to use it. - -The `dataset_info.json` file should be put in the `dataset_dir` directory. You can change `dataset_dir` to use another directory. The default value is `./data`. - -Currently we support datasets in **alpaca** and **sharegpt** format. Allowed file types include json, jsonl, csv, parquet, arrow. - -```json -"dataset_name": { - "hf_hub_url": "the name of the dataset repository on the Hugging Face hub. (if specified, ignore script_url, file_name and cloud_file_name)", - "ms_hub_url": "the name of the dataset repository on the Model Scope hub. (if specified, ignore script_url, file_name and cloud_file_name)", - "script_url": "the name of the directory containing a dataset loading script. (if specified, ignore file_name and cloud_file_name)", - "cloud_file_name": "the name of the dataset file in s3/gcs cloud storage. (if specified, ignore file_name)", - "file_name": "the name of the dataset folder or dataset file in this directory. (required if above are not specified)", - "formatting": "the format of the dataset. (optional, default: alpaca, can be chosen from {alpaca, sharegpt})", - "ranking": "whether the dataset is a preference dataset or not. (default: False)", - "subset": "the name of the subset. (optional, default: None)", - "split": "the name of dataset split to be used. (optional, default: train)", - "folder": "the name of the folder of the dataset repository on the Hugging Face hub. (optional, default: None)", - "num_samples": "the number of samples in the dataset to be used. (optional, default: None)", - "columns (optional)": { - "prompt": "the column name in the dataset containing the prompts. (default: instruction)", - "query": "the column name in the dataset containing the queries. (default: input)", - "response": "the column name in the dataset containing the responses. (default: output)", - "history": "the column name in the dataset containing the histories. (default: None)", - "messages": "the column name in the dataset containing the messages. (default: conversations)", - "system": "the column name in the dataset containing the system prompts. (default: None)", - "tools": "the column name in the dataset containing the tool description. (default: None)", - "images": "the column name in the dataset containing the image inputs. (default: None)", - "videos": "the column name in the dataset containing the videos inputs. (default: None)", - "audios": "the column name in the dataset containing the audios inputs. (default: None)", - "chosen": "the column name in the dataset containing the chosen answers. (default: None)", - "rejected": "the column name in the dataset containing the rejected answers. (default: None)", - "kto_tag": "the column name in the dataset containing the kto tags. (default: None)" - }, - "tags (optional, used for the sharegpt format)": { - "role_tag": "the key in the message represents the identity. (default: from)", - "content_tag": "the key in the message represents the content. (default: value)", - "user_tag": "the value of the role_tag represents the user. (default: human)", - "assistant_tag": "the value of the role_tag represents the assistant. (default: gpt)", - "observation_tag": "the value of the role_tag represents the tool results. (default: observation)", - "function_tag": "the value of the role_tag represents the function call. (default: function_call)", - "system_tag": "the value of the role_tag represents the system prompt. (default: system, can override system column)" - } -} -``` - -## Alpaca Format - -### Supervised Fine-Tuning Dataset - -* [Example dataset](alpaca_en_demo.json) - -In supervised fine-tuning, the `instruction` column will be concatenated with the `input` column and used as the user prompt, then the user prompt would be `instruction\ninput`. The `output` column represents the model response. - -For reasoning models, if the dataset contains chain-of-thought (CoT), the CoT needs to be placed in the model responses, such as `cotoutput`. - -The `system` column will be used as the system prompt if specified. - -The `history` column is a list consisting of string tuples representing prompt-response pairs in the history messages. Note that the responses in the history **will also be learned by the model** in supervised fine-tuning. - -```json -[ - { - "instruction": "user instruction (required)", - "input": "user input (optional)", - "output": "model response (required)", - "system": "system prompt (optional)", - "history": [ - ["user instruction in the first round (optional)", "model response in the first round (optional)"], - ["user instruction in the second round (optional)", "model response in the second round (optional)"] - ] - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "columns": { - "prompt": "instruction", - "query": "input", - "response": "output", - "system": "system", - "history": "history" - } -} -``` - -> [!TIP] -> If the model has reasoning capabilities (e.g. Qwen3) but the dataset does not contain chain-of-thought (CoT), LLaMA-Factory will automatically add empty CoT to the data. When `enable_thinking` is `True` (slow thinking, by default), the empty CoT will be added to the model responses and loss computation will be considered; otherwise (fast thinking), it will be added to the user prompts and loss computation will be ignored. Please keep the `enable_thinking` parameter consistent during training and inference. -> -> If you want to train data containing CoT with slow thinking and data without CoT with fast thinking, you can set `enable_thinking` to `None`. However, this feature is relatively complicated and should be used with caution. - -### Pre-training Dataset - -- [Example dataset](c4_demo.jsonl) - -In pre-training, only the `text` column will be used for model learning. - -```json -[ - {"text": "document"}, - {"text": "document"} -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "columns": { - "prompt": "text" - } -} -``` - -### Preference Dataset - -Preference datasets are used for reward modeling, DPO training, ORPO and SimPO training. - -It requires a better response in `chosen` column and a worse response in `rejected` column. - -```json -[ - { - "instruction": "user instruction (required)", - "input": "user input (optional)", - "chosen": "chosen answer (required)", - "rejected": "rejected answer (required)" - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "ranking": true, - "columns": { - "prompt": "instruction", - "query": "input", - "chosen": "chosen", - "rejected": "rejected" - } -} -``` - -### KTO Dataset - -An additional column `kto_tag` is required. Please refer to the [sharegpt](#sharegpt-format) format for details. - -### Multimodal Image Dataset - -An additional column `images` is required. Please refer to the [sharegpt](#sharegpt-format) format for details. - -### Multimodal Video Dataset - -An additional column `videos` is required. Please refer to the [sharegpt](#sharegpt-format) format for details. - -### Multimodal Audio Dataset - -An additional column `audios` is required. Please refer to the [sharegpt](#sharegpt-format) format for details. - -## Sharegpt Format - -### Supervised Fine-Tuning Dataset - -- [Example dataset](glaive_toolcall_en_demo.json) - -Compared to the alpaca format, the sharegpt format allows the datasets have **more roles**, such as human, gpt, observation and function. They are presented in a list of objects in the `conversations` column. - -Note that the human and observation should appear in odd positions, while gpt and function should appear in even positions. - -```json -[ - { - "conversations": [ - { - "from": "human", - "value": "user instruction" - }, - { - "from": "function_call", - "value": "tool arguments" - }, - { - "from": "observation", - "value": "tool result" - }, - { - "from": "gpt", - "value": "model response" - } - ], - "system": "system prompt (optional)", - "tools": "tool description (optional)" - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "formatting": "sharegpt", - "columns": { - "messages": "conversations", - "system": "system", - "tools": "tools" - } -} -``` - -### Pre-training Dataset - -Not yet supported, please use the [alpaca](#alpaca-format) format. - -### Preference Dataset - -- [Example dataset](dpo_en_demo.json) - -Preference datasets in sharegpt format also require a better message in `chosen` column and a worse message in `rejected` column. - -```json -[ - { - "conversations": [ - { - "from": "human", - "value": "user instruction" - }, - { - "from": "gpt", - "value": "model response" - }, - { - "from": "human", - "value": "user instruction" - } - ], - "chosen": { - "from": "gpt", - "value": "chosen answer (required)" - }, - "rejected": { - "from": "gpt", - "value": "rejected answer (required)" - } - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "formatting": "sharegpt", - "ranking": true, - "columns": { - "messages": "conversations", - "chosen": "chosen", - "rejected": "rejected" - } -} -``` - -### KTO Dataset - -- [Example dataset](kto_en_demo.json) - -KTO datasets require a extra `kto_tag` column containing the boolean human feedback. - -```json -[ - { - "conversations": [ - { - "from": "human", - "value": "user instruction" - }, - { - "from": "gpt", - "value": "model response" - } - ], - "kto_tag": "human feedback [true/false] (required)" - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "formatting": "sharegpt", - "columns": { - "messages": "conversations", - "kto_tag": "kto_tag" - } -} -``` - -### Multimodal Image Dataset - -- [Example dataset](mllm_demo.json) - -Multimodal image datasets require an `images` column containing the paths to the input images. - -The number of images should be identical to the `` tokens in the conversations. - -```json -[ - { - "conversations": [ - { - "from": "human", - "value": "user instruction" - }, - { - "from": "gpt", - "value": "model response" - } - ], - "images": [ - "image path (required)" - ] - } -] -``` - -Regarding the above dataset, the *dataset description* in `dataset_info.json` should be: - -```json -"dataset_name": { - "file_name": "data.json", - "formatting": "sharegpt", - "columns": { - "messages": "conversations", - "images": "images" - } -} -``` - -### Multimodal Video Dataset - -- [Example dataset](mllm_video_demo.json) - -Multimodal video datasets require a `videos` column containing the paths to the input videos. - -The number of videos should be identical to the `