Skip to content

Commit bf1fbd7

Browse files
committed
fix label error, bbox error
1 parent 6e2fc5e commit bf1fbd7

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ work_dirs/
127127

128128
*.png
129129
*.jpg
130+
131+
/work_dirs/

custom_configs/DELIVER/deliver_dataset.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
# Dataset basic info
1010
dataset_type = 'DELIVERDetectionDataset'
11-
data_root = '/media/jemo/HDD1/Workspace/dset/DELIVER/' # Added trailing slash
11+
data_root = '/SSDb/jemo_maeng/dset/DELIVER/' # Added trailing slash
1212
backend_args = None
13-
classes = ('Vehicle', 'Human')
13+
classes = ('Human', 'Vehicle')
1414

1515
# Data preprocessor
1616
data_preprocessor = dict(
@@ -44,7 +44,11 @@
4444
prob=0.5,
4545
bbox_format='xywh' # 🔥 xywh format 명시
4646
),
47-
dict(type='PackDELIVERDetInputs')
47+
# dict(type='PackDELIVERDetInputs')
48+
dict(
49+
type='PackDELIVERDetInputs',
50+
meta_keys=('img_path', 'img_id', 'ori_shape', 'img_shape', 'scale_factor', 'flip', 'flip_direction')
51+
)
4852
]
4953

5054
test_pipeline = [
@@ -55,7 +59,11 @@
5559
keep_ratio=True,
5660
bbox_format='xywh' # 🔥 xywh format 명시
5761
),
58-
dict(type='PackDELIVERDetInputs')
62+
# dict(type='PackDELIVERDetInputs')
63+
dict(
64+
type='PackDELIVERDetInputs',
65+
meta_keys=('img_path', 'img_id', 'ori_shape', 'img_shape', 'scale_factor', 'flip', 'flip_direction', 'depth_path', 'lidar_path', 'thermal_path')
66+
)
5967
]
6068

6169
# Dataset configs
@@ -133,7 +141,7 @@
133141
]
134142

135143
# Training settings
136-
train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=24, val_interval=1) # Updated for 2x
144+
train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=100, val_interval=1) # Updated for 2x
137145
val_cfg = dict(type='ValLoop')
138146
test_cfg = dict(type='TestLoop')
139147

@@ -144,7 +152,14 @@
144152
param_scheduler=dict(type='ParamSchedulerHook'),
145153
checkpoint=dict(type='CheckpointHook', interval=1, save_best='coco/bbox_mAP'),
146154
sampler_seed=dict(type='DistSamplerSeedHook'),
147-
visualization=dict(type='DetVisualizationHook')
155+
visualization=dict(
156+
type='MultiModalVisualizationHook',
157+
draw=True,
158+
interval=1,
159+
score_thr=0.3,
160+
show=False,
161+
test_out_dir='vis_results'
162+
)
148163
)
149164

150165
# Visualization settings

mmdet/engine/hooks/visualization_hook.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,18 @@ def after_test_iter(self, runner: Runner, batch_idx: int, data_batch: dict,
556556
for data_sample in outputs:
557557
self._test_index += 1
558558
data_sample = data_sample.cpu()
559-
559+
print("data_sample:", data_sample)
560560
rgb_path = str(data_sample.img_path).strip()
561-
depth_path = str(data_sample.metainfo.get('depth_path', '')).strip()
562-
lidar_path = str(data_sample.metainfo.get('lidar_path', '')).strip()
563-
thermal_path = str(data_sample.metainfo.get('thermal_path', '')).strip()
561+
depth_path = str(data_sample.metainfo.get('depth_path') or
562+
data_sample.metainfo.get('modality_paths', {}).get('depth', '')).strip()
563+
564+
lidar_path = str(data_sample.metainfo.get('lidar_path') or
565+
data_sample.metainfo.get('modality_paths', {}).get('lidar', '')).strip()
566+
567+
thermal_path = str(data_sample.metainfo.get('thermal_path') or
568+
data_sample.metainfo.get('modality_paths', {}).get('event', '')).strip()
564569

570+
print(rgb_path, depth_path, lidar_path, thermal_path)
565571
img_rgb = self._load_image(rgb_path)
566572
h, w, _ = img_rgb.shape
567573

@@ -627,7 +633,10 @@ def draw_split(img, modality_shape):
627633
pred_scaled = scale_bboxes(pred_bboxes, modality_shape, (h, w))
628634
if pred_scaled is not None and pred_labels is not None:
629635
self._visualizer.draw_bboxes(pred_scaled, edge_colors='red', alpha=0.8)
630-
label_texts = [classes[l] for l in pred_labels]
636+
label_texts = [
637+
f"{classes[l]} {round(s.item(), 2)}"
638+
for l, s in zip(pred_labels, pred_scores[keep])
639+
]
631640
self._visualizer.draw_texts(
632641
label_texts,
633642
pred_scaled[:, :2].int().numpy(),
@@ -639,6 +648,7 @@ def draw_split(img, modality_shape):
639648
'pad': 0.7,
640649
'edgecolor': 'none'
641650
}] * len(pred_scaled))
651+
642652
img_pred = self._visualizer.get_image()
643653

644654
return np.concatenate([img_gt, img_pred], axis=1)
@@ -653,7 +663,13 @@ def draw_split(img, modality_shape):
653663

654664
out_file = None
655665
if self.test_out_dir is not None:
656-
out_file = osp.join(self.test_out_dir, f"{self._test_index:06d}.jpg")
666+
basename = osp.basename(rgb_path)
667+
basename = (basename
668+
.replace('_rgb_', '_')
669+
.replace('_depth_', '_')
670+
.replace('_event_', '_')
671+
.replace('_lidar_', '_'))
672+
out_file = osp.join(self.test_out_dir, basename)
657673
if self.show:
658674
self._visualizer.show(final_vis, win_name='multi_modal_split', wait_time=self.wait_time)
659675
if out_file is not None:

0 commit comments

Comments
 (0)