Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dcnv3
Commits
41b18fd8
Commit
41b18fd8
authored
Jan 06, 2025
by
zhe chen
Browse files
Use pre-commit to reformat code
Use pre-commit to reformat code
parent
ff20ea39
Changes
390
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
126 additions
and
127 deletions
+126
-127
autonomous_driving/openlane-v2/tools/data_converter/nuscenes_converter.py
...ng/openlane-v2/tools/data_converter/nuscenes_converter.py
+7
-8
autonomous_driving/openlane-v2/tools/data_converter/s3dis_data_utils.py
...ving/openlane-v2/tools/data_converter/s3dis_data_utils.py
+2
-2
autonomous_driving/openlane-v2/tools/data_converter/scannet_data_utils.py
...ng/openlane-v2/tools/data_converter/scannet_data_utils.py
+2
-2
autonomous_driving/openlane-v2/tools/data_converter/sunrgbd_data_utils.py
...ng/openlane-v2/tools/data_converter/sunrgbd_data_utils.py
+3
-3
autonomous_driving/openlane-v2/tools/data_converter/waymo_converter.py
...iving/openlane-v2/tools/data_converter/waymo_converter.py
+14
-14
autonomous_driving/openlane-v2/tools/deployment/mmdet3d2torchserve.py
...riving/openlane-v2/tools/deployment/mmdet3d2torchserve.py
+8
-8
autonomous_driving/openlane-v2/tools/deployment/mmdet3d_handler.py
...s_driving/openlane-v2/tools/deployment/mmdet3d_handler.py
+1
-2
autonomous_driving/openlane-v2/tools/deployment/test_torchserver.py
..._driving/openlane-v2/tools/deployment/test_torchserver.py
+0
-1
autonomous_driving/openlane-v2/tools/misc/browse_dataset.py
autonomous_driving/openlane-v2/tools/misc/browse_dataset.py
+6
-7
autonomous_driving/openlane-v2/tools/misc/fuse_conv_bn.py
autonomous_driving/openlane-v2/tools/misc/fuse_conv_bn.py
+1
-2
autonomous_driving/openlane-v2/tools/misc/visualize_results.py
...omous_driving/openlane-v2/tools/misc/visualize_results.py
+0
-1
autonomous_driving/openlane-v2/tools/model_converters/convert_h3dnet_checkpoints.py
...e-v2/tools/model_converters/convert_h3dnet_checkpoints.py
+4
-5
autonomous_driving/openlane-v2/tools/model_converters/convert_votenet_checkpoints.py
...-v2/tools/model_converters/convert_votenet_checkpoints.py
+4
-5
autonomous_driving/openlane-v2/tools/test.py
autonomous_driving/openlane-v2/tools/test.py
+19
-20
autonomous_driving/openlane-v2/tools/train.py
autonomous_driving/openlane-v2/tools/train.py
+11
-11
autonomous_driving/openlane-v2/tools/update_data_coords.py
autonomous_driving/openlane-v2/tools/update_data_coords.py
+1
-3
classification/README.md
classification/README.md
+40
-30
classification/config.py
classification/config.py
+1
-1
classification/configs/accelerate/deepspeed/ds_config_zero1.json
...ication/configs/accelerate/deepspeed/ds_config_zero1.json
+1
-1
classification/configs/accelerate/deepspeed/ds_config_zero1_wo_loss_scale.json
...s/accelerate/deepspeed/ds_config_zero1_wo_loss_scale.json
+1
-1
No files found.
autonomous_driving/openlane-v2/tools/data_converter/nuscenes_converter.py
View file @
41b18fd8
...
...
@@ -6,14 +6,13 @@ from typing import List, Tuple, Union
import
mmcv
import
numpy
as
np
from
mmdet3d.core.bbox
import
points_cam2img
from
mmdet3d.datasets
import
NuScenesDataset
from
nuscenes.nuscenes
import
NuScenes
from
nuscenes.utils.geometry_utils
import
view_points
from
pyquaternion
import
Quaternion
from
shapely.geometry
import
MultiPoint
,
box
from
mmdet3d.core.bbox
import
points_cam2img
from
mmdet3d.datasets
import
NuScenesDataset
nus_categories
=
(
'car'
,
'truck'
,
'trailer'
,
'bus'
,
'construction_vehicle'
,
'bicycle'
,
'motorcycle'
,
'pedestrian'
,
'traffic_cone'
,
'barrier'
)
...
...
autonomous_driving/openlane-v2/tools/data_converter/s3dis_data_utils.py
View file @
41b18fd8
...
...
@@ -221,7 +221,7 @@ class S3DISSegData(object):
"""
num_classes
=
len
(
self
.
cat_ids
)
num_point_all
=
[]
label_weight
=
np
.
zeros
((
num_classes
+
1
,
))
# ignore_index
label_weight
=
np
.
zeros
((
num_classes
+
1
,))
# ignore_index
for
data_info
in
self
.
data_infos
:
label
=
self
.
_convert_to_label
(
osp
.
join
(
self
.
data_root
,
data_info
[
'pts_semantic_mask_path'
]))
...
...
autonomous_driving/openlane-v2/tools/data_converter/scannet_data_utils.py
View file @
41b18fd8
...
...
@@ -273,7 +273,7 @@ class ScanNetSegData(object):
"""
num_classes
=
len
(
self
.
cat_ids
)
num_point_all
=
[]
label_weight
=
np
.
zeros
((
num_classes
+
1
,
))
# ignore_index
label_weight
=
np
.
zeros
((
num_classes
+
1
,))
# ignore_index
for
data_info
in
self
.
data_infos
:
label
=
self
.
_convert_to_label
(
osp
.
join
(
self
.
data_root
,
data_info
[
'pts_semantic_mask_path'
]))
...
...
autonomous_driving/openlane-v2/tools/data_converter/sunrgbd_data_utils.py
View file @
41b18fd8
...
...
@@ -47,7 +47,7 @@ class SUNRGBDInstance(object):
# z_size (height) in our depth coordinate system,
# l corresponds to the size along the x axis
self
.
size
=
np
.
array
([
data
[
9
],
data
[
8
],
data
[
10
]])
*
2
self
.
orientation
=
np
.
zeros
((
3
,
))
self
.
orientation
=
np
.
zeros
((
3
,))
self
.
orientation
[
0
]
=
data
[
11
]
self
.
orientation
[
1
]
=
data
[
12
]
self
.
heading_angle
=
np
.
arctan2
(
self
.
orientation
[
1
],
...
...
autonomous_driving/openlane-v2/tools/data_converter/waymo_converter.py
View file @
41b18fd8
...
...
@@ -171,7 +171,7 @@ class Waymo2KITTI(object):
self
.
cart_to_homo
(
T_front_cam_to_ref
)
@
T_vehicle_to_cam
if
camera
.
name
==
1
:
# FRONT = 1, see dataset.proto for details
self
.
T_velo_to_front_cam
=
Tr_velo_to_cam
.
copy
()
Tr_velo_to_cam
=
Tr_velo_to_cam
[:
3
,
:].
reshape
((
12
,
))
Tr_velo_to_cam
=
Tr_velo_to_cam
[:
3
,
:].
reshape
((
12
,))
Tr_velo_to_cams
.
append
([
f
'
{
i
:
e
}
'
for
i
in
Tr_velo_to_cam
])
# intrinsic parameters
...
...
autonomous_driving/openlane-v2/tools/deployment/mmdet3d2torchserve.py
View file @
41b18fd8
autonomous_driving/openlane-v2/tools/deployment/mmdet3d_handler.py
View file @
41b18fd8
...
...
@@ -4,10 +4,9 @@ import os
import
numpy
as
np
import
torch
from
ts.torch_handler.base_handler
import
BaseHandler
from
mmdet3d.apis
import
inference_detector
,
init_model
from
mmdet3d.core.points
import
get_points_type
from
ts.torch_handler.base_handler
import
BaseHandler
class
MMdet3dHandler
(
BaseHandler
):
...
...
autonomous_driving/openlane-v2/tools/deployment/test_torchserver.py
View file @
41b18fd8
...
...
@@ -2,7 +2,6 @@ from argparse import ArgumentParser
import
numpy
as
np
import
requests
from
mmdet3d.apis
import
inference_detector
,
init_model
...
...
autonomous_driving/openlane-v2/tools/misc/browse_dataset.py
View file @
41b18fd8
...
...
@@ -7,7 +7,6 @@ from pathlib import Path
import
mmcv
import
numpy
as
np
from
mmcv
import
Config
,
DictAction
,
mkdir_or_exist
from
mmdet3d.core.bbox
import
(
Box3DMode
,
CameraInstance3DBoxes
,
Coord3DMode
,
DepthInstance3DBoxes
,
LiDARInstance3DBoxes
)
from
mmdet3d.core.visualizer
import
(
show_multi_modality_result
,
show_result
,
...
...
autonomous_driving/openlane-v2/tools/misc/fuse_conv_bn.py
View file @
41b18fd8
...
...
@@ -3,9 +3,8 @@ import argparse
import
torch
from
mmcv.runner
import
save_checkpoint
from
torch
import
nn
as
nn
from
mmdet3d.apis
import
init_model
from
torch
import
nn
as
nn
def
fuse_conv_bn
(
conv
,
bn
):
...
...
autonomous_driving/openlane-v2/tools/misc/visualize_results.py
View file @
41b18fd8
...
...
@@ -3,7 +3,6 @@ import argparse
import
mmcv
from
mmcv
import
Config
from
mmdet3d.datasets
import
build_dataset
...
...
autonomous_driving/openlane-v2/tools/model_converters/convert_h3dnet_checkpoints.py
View file @
41b18fd8
...
...
@@ -5,7 +5,6 @@ import tempfile
import
torch
from
mmcv
import
Config
from
mmcv.runner
import
load_state_dict
from
mmdet3d.models
import
build_detector
...
...
autonomous_driving/openlane-v2/tools/model_converters/convert_votenet_checkpoints.py
View file @
41b18fd8
...
...
@@ -5,7 +5,6 @@ import tempfile
import
torch
from
mmcv
import
Config
from
mmcv.runner
import
load_state_dict
from
mmdet3d.models
import
build_detector
...
...
autonomous_driving/openlane-v2/tools/test.py
View file @
41b18fd8
...
...
@@ -4,14 +4,13 @@ import os
import
warnings
import
mmcv
import
mmdet
import
torch
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
)
import
mmdet
from
mmdet3d.apis
import
single_gpu_test
from
mmdet3d.datasets
import
build_dataloader
,
build_dataset
from
mmdet3d.models
import
build_model
...
...
autonomous_driving/openlane-v2/tools/train.py
View file @
41b18fd8
# Copyright (c) OpenMMLab. All rights reserved.
from
__future__
import
division
import
argparse
import
copy
import
os
...
...
@@ -12,7 +13,6 @@ import torch
import
torch.distributed
as
dist
from
mmcv
import
Config
,
DictAction
from
mmcv.runner
import
get_dist_info
,
init_dist
from
mmdet
import
__version__
as
mmdet_version
from
mmdet3d
import
__version__
as
mmdet3d_version
from
mmdet3d.apis
import
init_random_seed
,
train_model
...
...
autonomous_driving/openlane-v2/tools/update_data_coords.py
View file @
41b18fd8
...
...
@@ -4,7 +4,6 @@ from os import path as osp
import
mmcv
import
numpy
as
np
from
mmdet3d.core.bbox
import
limit_period
...
...
@@ -61,7 +60,6 @@ def update_outdoor_dbinfos(root_dir, out_dir, pkl_files):
def
update_nuscenes_or_lyft_infos
(
root_dir
,
out_dir
,
pkl_files
):
print
(
f
'
{
pkl_files
}
will be modified because '
f
'of the refactor of the LIDAR coordinate system.'
)
if
root_dir
==
out_dir
:
...
...
classification/README.md
View file @
41b18fd8
...
...
@@ -3,14 +3,16 @@
This folder contains the implementation of the InternImage for image classification.
<!-- TOC -->
*
[
Install
](
#install
)
*
[
Data Preparation
](
#data-preparation
)
*
[
Evaluation
](
#evaluation
)
*
[
Training from Scratch on ImageNet-1K
](
#training-from-scratch-on-imagenet-1k
)
*
[
Manage Jobs with Slurm
](
#manage-jobs-with-slurm
)
*
[
Training with Deepspeed
](
#training-with-deepspeed
)
*
[
Extracting Intermediate Features
](
#extracting-intermediate-features
)
*
[
Export
](
#export
)
-
[
Install
](
#install
)
-
[
Data Preparation
](
#data-preparation
)
-
[
Evaluation
](
#evaluation
)
-
[
Training from Scratch on ImageNet-1K
](
#training-from-scratch-on-imagenet-1k
)
-
[
Manage Jobs with Slurm
](
#manage-jobs-with-slurm
)
-
[
Training with Deepspeed
](
#training-with-deepspeed
)
-
[
Extracting Intermediate Features
](
#extracting-intermediate-features
)
-
[
Export
](
#export
)
<!-- TOC -->
## Usage
...
...
@@ -36,6 +38,7 @@ conda activate internimage
-
Install
`PyTorch>=1.10.0`
and
`torchvision>=0.9.0`
with
`CUDA>=10.2`
:
For examples, to install torch==1.11 with CUDA==11.3:
```
bash
pip
install
torch
==
1.11.0+cu113
torchvision
==
0.12.0+cu113
-f
https://download.pytorch.org/whl/torch_stable.html
```
...
...
@@ -55,20 +58,24 @@ pip install opencv-python termcolor yacs pyyaml scipy
```
-
Compiling CUDA operators
```
bash
cd
./ops_dcnv3
sh ./make.sh
# unit test (should see all checking is True)
python test.py
```
-
You can also install the operator using .whl files
[
DCNv3-1.0-whl
](
https://github.com/OpenGVLab/InternImage/releases/tag/whl_files
)
[
DCNv3-1.0-whl
](
https://github.com/OpenGVLab/InternImage/releases/tag/whl_files
)
### Data Preparation
We use standard ImageNet dataset, you can download it from http://image-net.org/. We provide the following two ways to
load data:
-
For standard folder dataset, move validation images to labeled sub-folders. The file structure should look like:
```
bash
$
tree data
imagenet
...
...
@@ -92,8 +99,10 @@ load data:
└── ...
```
-
To boost the slow speed when reading images from massive small files, we also support zipped ImageNet, which includes
four files:
-
`train.zip`
,
`val.zip`
: which store the zipped folder for train and validate splits.
-
`train.txt`
,
`val.txt`
: which store the relative path in the corresponding zip file and ground truth
label. Make sure the data folder looks like this:
...
...
@@ -121,6 +130,7 @@ load data:
n01440764/n01440764_10040.JPEG 0
n01440764/n01440764_10042.JPEG 0
```
-
For ImageNet-22K dataset, make a folder named
`fall11_whole`
and move all images to labeled sub-folders in this
folder. Then download the train-val split
file (
[
ILSVRC2011fall_whole_map_train.txt
](
https://github.com/SwinTransformer/storage/releases/download/v2.0.1/ILSVRC2011fall_whole_map_train.txt
)
...
...
@@ -220,6 +230,7 @@ pip install deepspeed==0.8.3
Then you could launch the training in a slurm system with 8 GPUs as follows (tiny and huge as examples).
The default zero stage is 1 and it could config via command line args
`--zero-stage`
.
```
GPUS=8 GPUS_PER_NODE=8 sh train_in1k_deepspeed.sh vc_research_4 train configs/internimage_t_1k_224.yaml --batch-size 128 --accumulation-steps 4
GPUS=8 GPUS_PER_NODE=8 sh train_in1k_deepspeed.sh vc_research_4 train configs/internimage_t_1k_224.yaml --batch-size 128 --accumulation-steps 4 --eval --resume ckpt.pth
...
...
@@ -228,7 +239,6 @@ GPUS=8 GPUS_PER_NODE=8 sh train_in1k_deepspeed.sh vc_research_4 train configs/in
GPUS=8 GPUS_PER_NODE=8 sh train_in1k_deepspeed.sh vc_research_4 train configs/internimage_h_22kto1k_640.yaml --batch-size 16 --accumulation-steps 4 --pretrained ckpt/internimage_h_jointto22k_384.pth --zero-stage 3
```
🤗
**Huggingface Accelerate Integration of Deepspeed**
Optionally, you could use our
[
Huggingface accelerate
](
https://github.com/huggingface/accelerate
)
integration to use deepspeed.
...
...
@@ -250,7 +260,7 @@ Here is the reference GPU memory cost for InternImage-H with 8 GPUs.
-
total batch size = 512, 16 batch size for each GPU, gradient accumulation steps = 4.
| Resolution | Deepspeed | Cpu offloading | Memory |
| ---
| --- |
--- | --- |
| ---
------- | --------- | -----------
--- | ---
---
|
| 640 | zero1 | False | 22572 |
| 640 | zero3 | False | 20000 |
| 640 | zero3 | True | 19144 |
...
...
@@ -280,16 +290,16 @@ For example, extract features of `b.png` from layers `patch_embed` and `levels.0
python extract_feature.py
--cfg
configs/internimage_t_1k_224.yaml
--img
b.png
--keys
patch_embed levels.0.downsample
--save
--resume
internimage_t_1k_224.pth
```
### Export
To export
`InternImage-T`
from PyTorch to ONNX, run:
```
shell
python export.py
--model_name
internimage_t_1k_224
--ckpt_dir
/path/to/ckpt/dir
--onnx
```
To export
`InternImage-T`
from PyTorch to TensorRT, run:
```
shell
python export.py
--model_name
internimage_t_1k_224
--ckpt_dir
/path/to/ckpt/dir
--trt
```
classification/config.py
View file @
41b18fd8
...
...
@@ -5,6 +5,7 @@
# --------------------------------------------------------
import
os
import
yaml
from
yacs.config
import
CfgNode
as
CN
...
...
@@ -82,7 +83,6 @@ _C.MODEL.INTERN_IMAGE.CENTER_FEATURE_SCALE = False
_C
.
MODEL
.
INTERN_IMAGE
.
REMOVE_CENTER
=
False
# -----------------------------------------------------------------------------
# Training settings
# -----------------------------------------------------------------------------
...
...
classification/configs/accelerate/deepspeed/ds_config_zero1.json
View file @
41b18fd8
classification/configs/accelerate/deepspeed/ds_config_zero1_wo_loss_scale.json
View file @
41b18fd8
Prev
1
…
9
10
11
12
13
14
15
16
17
…
20
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment