From 68526b1619cd8225cbfef2f550378509e8858ab5 Mon Sep 17 00:00:00 2001 From: tpoisonooo Date: Tue, 13 Sep 2022 12:10:44 +0800 Subject: [PATCH 1/4] feat(local_visualizer.py): add check dir exist --- mmdet3d/visualization/local_visualizer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mmdet3d/visualization/local_visualizer.py b/mmdet3d/visualization/local_visualizer.py index ff4c873969..1eeb3eba88 100644 --- a/mmdet3d/visualization/local_visualizer.py +++ b/mmdet3d/visualization/local_visualizer.py @@ -1,5 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy +import os from os import path as osp from typing import Dict, List, Optional, Tuple, Union @@ -517,7 +518,6 @@ def add_datasample(self, pred_seg_data_3d = None gt_img_data = None pred_img_data = None - if draw_gt and data_sample is not None: if 'gt_instances_3d' in data_sample: gt_data_3d = self._draw_instances_3d( @@ -605,6 +605,9 @@ def add_datasample(self, win_name=name, wait_time=wait_time) + if not osp.exists(out_file): + os.mkdir(out_file) + if out_file is not None: if drawn_img_3d is not None: mmcv.imwrite(drawn_img_3d[..., ::-1], out_file + '.jpg') From b59d287f726fbed8173d8f68418e4821808447bb Mon Sep 17 00:00:00 2001 From: tpoisonooo Date: Wed, 14 Sep 2022 17:45:44 +0800 Subject: [PATCH 2/4] fix(local_visualizer.py): use mmengine API --- mmdet3d/visualization/local_visualizer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mmdet3d/visualization/local_visualizer.py b/mmdet3d/visualization/local_visualizer.py index 1eeb3eba88..0ad53a0aa9 100644 --- a/mmdet3d/visualization/local_visualizer.py +++ b/mmdet3d/visualization/local_visualizer.py @@ -1,12 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -import os from os import path as osp from typing import Dict, List, Optional, Tuple, Union import mmcv import numpy as np from mmengine.dist import master_only +from mmengine import mkdir_or_exist from torch import Tensor from mmdet.visualization import DetLocalVisualizer @@ -605,8 +605,7 @@ def add_datasample(self, win_name=name, wait_time=wait_time) - if not osp.exists(out_file): - os.mkdir(out_file) + mkdir_or_exist(out_file) if out_file is not None: if drawn_img_3d is not None: From 6ad2450ee2563f8988fcfc87fc779ce8bf8126da Mon Sep 17 00:00:00 2001 From: tpoisonooo Date: Wed, 14 Sep 2022 17:46:46 +0800 Subject: [PATCH 3/4] format(local_visualizer.py): remove useless --- mmdet3d/visualization/local_visualizer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mmdet3d/visualization/local_visualizer.py b/mmdet3d/visualization/local_visualizer.py index 0ad53a0aa9..2451990a70 100644 --- a/mmdet3d/visualization/local_visualizer.py +++ b/mmdet3d/visualization/local_visualizer.py @@ -518,6 +518,7 @@ def add_datasample(self, pred_seg_data_3d = None gt_img_data = None pred_img_data = None + if draw_gt and data_sample is not None: if 'gt_instances_3d' in data_sample: gt_data_3d = self._draw_instances_3d( From 6957cabac413b26dffba28703ae297662069138a Mon Sep 17 00:00:00 2001 From: tpoisonooo Date: Fri, 16 Sep 2022 10:11:13 +0800 Subject: [PATCH 4/4] style(local_visualizer.py): format --- mmdet3d/visualization/local_visualizer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmdet3d/visualization/local_visualizer.py b/mmdet3d/visualization/local_visualizer.py index 2451990a70..97362cd470 100644 --- a/mmdet3d/visualization/local_visualizer.py +++ b/mmdet3d/visualization/local_visualizer.py @@ -5,8 +5,8 @@ import mmcv import numpy as np -from mmengine.dist import master_only from mmengine import mkdir_or_exist +from mmengine.dist import master_only from torch import Tensor from mmdet.visualization import DetLocalVisualizer @@ -607,7 +607,7 @@ def add_datasample(self, wait_time=wait_time) mkdir_or_exist(out_file) - + if out_file is not None: if drawn_img_3d is not None: mmcv.imwrite(drawn_img_3d[..., ::-1], out_file + '.jpg')