Skip to content

Commit 90d15e9

Browse files
committed
fix: refactor files
Signed-off-by: Kaan Çolak <kaancolak95@gmail.com>
1 parent 934d97f commit 90d15e9

File tree

9 files changed

+29
-33
lines changed

9 files changed

+29
-33
lines changed

projects/AutowareCenterPoint/centerpoint/pillar_encoder_autoware.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from typing import Optional, Tuple
22

33
import torch
4-
from mmcv.cnn import build_norm_layer
5-
from mmcv.ops import DynamicScatter
64
from torch import Tensor, nn
75

86
from mmdet3d.models.voxel_encoders.utils import (PFNLayer,

projects/AutowareCenterPoint/centerpoint_onnx_converter.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22
import os
3-
from typing import Any, Dict, List, Optional, Tuple
3+
from typing import Dict, List, Optional, Tuple
44

55
import torch
66
from mmengine import Config
@@ -17,8 +17,7 @@
1717

1818
def parse_args():
1919
parser = argparse.ArgumentParser(
20-
description=
21-
'Create autoware compitable onnx file from torch checkpoint ')
20+
'Create autoware compatible onnx file from torch checkpoint ')
2221
parser.add_argument('--cfg', help='train config file path')
2322
parser.add_argument('--ckpt', help='checkpoint weeight')
2423
parser.add_argument('--work-dir', help='the dir to save onnx files')
@@ -119,9 +118,8 @@ def save_onnx(self) -> None:
119118
verbose=False,
120119
opset_version=11,
121120
)
122-
print(
123-
f'Saved pts_backbone_neck_head onnx model: {pth_onnx_backbone_neck_head}'
124-
)
121+
print(f'Saved pts_backbone_neck_head onnx model:'
122+
f' {pth_onnx_backbone_neck_head}')
125123

126124

127125
@MODELS.register_module()
@@ -280,7 +278,8 @@ def forward(self, x: torch.Tensor) -> Tuple[List[Dict[str, torch.Tensor]]]:
280278
x (torch.Tensor): (B, C, H, W)
281279
Returns:
282280
tuple[list[dict[str, any]]]:
283-
(num_classes x [num_detect x {'reg', 'height', 'dim', 'rot', 'vel', 'heatmap'}])
281+
(num_classes x [num_detect x
282+
{'reg', 'height', 'dim', 'rot', 'vel', 'heatmap'}])
284283
"""
285284
x = self.backbone(x)
286285
if self.neck is not None:

projects/AutowareCenterPoint/configs/centerpoint_custom.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -845,4 +845,5 @@
845845
0.2,
846846
8,
847847
]
848-
work_dir = './work_dirs/centerpoint_pillar02_second_secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d-CUSTOM'
848+
work_dir = ('./work_dirs/centerpoint_pillar02_second_'
849+
'secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d-CUSTOM')

projects/AutowareCenterPoint/datasets/tier4_dataset.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import os
22
from os import path as osp
3-
from typing import Callable, List, Union
43

54
import numpy as np
65

7-
# from .det3d_dataset import Det3DDataset
86
from mmdet3d.datasets.nuscenes_dataset import NuScenesDataset
97
from mmdet3d.registry import DATASETS
10-
from mmdet3d.structures import LiDARInstance3DBoxes
11-
from mmdet3d.structures.bbox_3d.cam_box3d import CameraInstance3DBoxes
128

139

1410
@DATASETS.register_module()

projects/AutowareCenterPoint/evaluation/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flake8: noqa
12
from .functional.nuscenes_utils.eval import (DetectionConfig,
23
nuScenesDetectionEval)
34
from .functional.nuscenes_utils.utils import (
@@ -6,7 +7,7 @@
67
from .metrics.nuscenes_custom_metric import NuScenesCustomMetric
78

89
__all__ = [
9-
'NuScenesCustomMetric,'
10+
'NuScenesCustomMetric'
1011
'DetectionConfig'
1112
'nuScenesDetectionEval'
1213
'class_mapping_kitti2nuscenes'

projects/AutowareCenterPoint/evaluation/functional/nuscenes_utils/eval.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import json
21
import os
3-
from typing import Dict, List, Optional, Tuple
2+
from typing import Dict, List, Optional
43

54
import numpy as np
65
from nuscenes.eval.common.data_classes import EvalBox, EvalBoxes
7-
from nuscenes.eval.common.loaders import load_prediction
86
from nuscenes.eval.common.utils import center_distance
97
from nuscenes.eval.detection.data_classes import DetectionBox
108
from nuscenes.eval.detection.evaluate import DetectionEval as _DetectionEval
@@ -57,8 +55,8 @@ def __init__(
5755
mean_ap_weight: int,
5856
):
5957

60-
# assert set(class_range.keys()) == set(DETECTION_NAMES), "Class count mismatch."
61-
assert dist_th_tp in dist_ths, 'dist_th_tp must be in set of dist_ths.'
58+
assert dist_th_tp in dist_ths, \
59+
'dist_th_tp must be in set of dist_ths.'
6260

6361
self.class_range = class_range
6462
self.dist_fcn = dist_fcn
@@ -122,15 +120,19 @@ class nuScenesDetectionEval(_DetectionEval):
122120
written to the provided output_dir. nuScenes uses the following detection
123121
metrics:
124122
125-
- Mean Average Precision (mAP): Uses center-distance as matching criterion; averaged over distance thresholds.
126-
- True Positive (TP) metrics: Average of translation, velocity, scale, orientation and attribute errors.
123+
- Mean Average Precision (mAP): Uses center-distance as matching criterion;
124+
averaged over distance thresholds.
125+
- True Positive (TP) metrics: Average of translation, velocity, scale,
126+
orientation and attribute errors.
127127
- nuScenes Detection Score (NDS): The weighted sum of the above.
128128
Here is an overview of the functions in this method:
129-
- init: Loads GT annotations and predictions stored in JSON format and filters the boxes.
129+
- init: Loads GT annotations and predictions stored in
130+
JSON format and filters the boxes.
130131
- run: Performs evaluation and dumps the metric data to disk.
131132
- render: Renders various plots and dumps to disk.
132133
We assume that:
133-
- Every sample_token is given in the results, although there may be not predictions for that sample.
134+
- Every sample_token is given in the results, although there may be
135+
not predictions for that sample.
134136
Please see https://www.nuscenes.org/object-detection for more details.
135137
"""
136138

@@ -149,7 +151,8 @@ def __init__(
149151
:param config: A DetectionConfig object.
150152
:param result_boxes: result bounding boxes.
151153
:param gt_boxes: ground-truth bounding boxes.
152-
:param eval_set: The dataset split to evaluate on, e.g. train, val or test.
154+
:param eval_set: The dataset split to evaluate on,
155+
e.g. train, val or test.
153156
:param output_dir: Folder to save plots and results to.
154157
:param verbose: Whether to print to stdout.
155158
"""

projects/AutowareCenterPoint/evaluation/functional/nuscenes_utils/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def format_nuscenes_metrics(metrics: Dict,
234234
result_dict: Dict[str, Dict[str, float]] = defaultdict(dict)
235235
for name in class_names:
236236
result_dict[name].update({
237-
f'mAP':
237+
'mAP':
238238
sum([v for v in metrics['label_aps'][name].values()]) * 100 /
239239
len(metrics['label_aps'][name])
240240
})

projects/AutowareCenterPoint/evaluation/metrics/nuscenes_custom_metric.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from os import path as osp
44
from typing import Dict, List, Optional, Sequence, Tuple, Union
55

6-
import mmcv
76
import mmengine
87
import numpy as np
98
import pyquaternion
@@ -235,8 +234,6 @@ def _evaluate_single(
235234
Returns:
236235
Dict[str, float]: Dictionary of evaluation details.
237236
"""
238-
from nuscenes import NuScenes
239-
from nuscenes.eval.detection.evaluate import NuScenesEval
240237

241238
output_dir = osp.join(*osp.split(result_path)[:-1])
242239

tools/dataset_converters/tier4dataset_converter.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _fill_trainval_infos(nusc,
216216

217217
for cam in camera_types:
218218

219-
if not cam in sample['data']:
219+
if cam not in sample['data']:
220220
continue
221221

222222
cam_token = sample['data'][cam]
@@ -440,9 +440,10 @@ def get_2d_boxes(nusc,
440440
# Get the sample data and the sample corresponding to that sample data.
441441
sd_rec = nusc.get('sample_data', sample_data_token)
442442

443-
assert sd_rec[
444-
'sensor_modality'] == 'camera', 'Error: get_2d_boxes only works' \
445-
' for camera sample_data!'
443+
assert sd_rec['sensor_modality'] == 'camera', ('Error: get_2d_boxes only '
444+
'worksfor camera '
445+
'sample_data!')
446+
446447
if not sd_rec['is_key_frame']:
447448
raise ValueError(
448449
'The 2D re-projections are available only for keyframes.')

0 commit comments

Comments
 (0)