From 0c422cad39b4c02c06b32639918963b86410ed51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9B=A6?= Date: Fri, 26 Feb 2021 18:14:20 +0800 Subject: [PATCH 1/4] Reduce the open3d dependency --- mmdet3d/core/visualizer/open3d_vis.py | 9 +++++++-- requirements/optional.txt | 1 + requirements/tests.txt | 1 - setup.cfg | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mmdet3d/core/visualizer/open3d_vis.py b/mmdet3d/core/visualizer/open3d_vis.py index 08d1d31534..c4aa43204e 100644 --- a/mmdet3d/core/visualizer/open3d_vis.py +++ b/mmdet3d/core/visualizer/open3d_vis.py @@ -1,9 +1,14 @@ import cv2 import numpy as np -import open3d as o3d import torch from matplotlib import pyplot as plt -from open3d import geometry + +try: + import open3d as o3d + from open3d import geometry +except ImportError: + raise ImportError( + 'Please run "pip install open3d to install open3d first." ') def _draw_points(points, diff --git a/requirements/optional.txt b/requirements/optional.txt index a9b8ad8e25..d3434d5046 100644 --- a/requirements/optional.txt +++ b/requirements/optional.txt @@ -1 +1,2 @@ +open3d waymo-open-dataset-tf-2-1-0==1.2.0 diff --git a/requirements/tests.txt b/requirements/tests.txt index 1297a5a2da..303cc37d6f 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -5,7 +5,6 @@ interrogate isort # Note: used for kwarray.group_items, this may be ported to mmcv in the future. kwarray -open3d pytest pytest-cov pytest-runner diff --git a/setup.cfg b/setup.cfg index 5fd1a7aae9..b4c6c44fee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,6 @@ line_length = 79 multi_line_output = 0 known_standard_library = setuptools known_first_party = mmdet,mmdet3d -known_third_party = cv2,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,open3d,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset +known_third_party = cv2,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset no_lines_before = STDLIB,LOCALFOLDER default_section = THIRDPARTY From dd66232789784d6f6d3038569e725683b984de62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9B=A6?= Date: Sun, 28 Feb 2021 00:01:29 +0800 Subject: [PATCH 2/4] Reduce the open3d dependency --- mmdet3d/core/visualizer/open3d_vis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmdet3d/core/visualizer/open3d_vis.py b/mmdet3d/core/visualizer/open3d_vis.py index c4aa43204e..d0fc8a1a66 100644 --- a/mmdet3d/core/visualizer/open3d_vis.py +++ b/mmdet3d/core/visualizer/open3d_vis.py @@ -8,7 +8,7 @@ from open3d import geometry except ImportError: raise ImportError( - 'Please run "pip install open3d to install open3d first." ') + 'Please run "pip install open3d" to install open3d first.') def _draw_points(points, From 6aab053403bf5ca628091493c4553c81493d471c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9B=A6?= Date: Sun, 28 Feb 2021 00:44:03 +0800 Subject: [PATCH 3/4] Reduce dependency of open3d if open3d is not used --- mmdet3d/core/visualizer/show_result.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index 2b5f059198..e3ff25460f 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -3,8 +3,6 @@ import trimesh from os import path as osp -from .open3d_vis import Visualizer - def _write_ply(points, out_filename): """Write points into ``ply`` format for meshlab visualization. @@ -81,6 +79,12 @@ def show_result(points, gt_bboxes, pred_bboxes, out_dir, filename, show=True): filename (str): Filename of the current frame. show (bool): Visualize the results online. """ + try: + from .open3d_vis import Visualizer + except ImportError: + raise ImportError( + 'Please run "pip install open3d" to install open3d first.') + if show: vis = Visualizer(points) if pred_bboxes is not None: From 55b763bb5d28289b8e1185488b1dabc94f9334fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9B=A6?= Date: Mon, 1 Mar 2021 14:10:34 +0800 Subject: [PATCH 4/4] remove the warning in show_result --- mmdet3d/core/visualizer/show_result.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index e3ff25460f..522604ad79 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -79,11 +79,7 @@ def show_result(points, gt_bboxes, pred_bboxes, out_dir, filename, show=True): filename (str): Filename of the current frame. show (bool): Visualize the results online. """ - try: - from .open3d_vis import Visualizer - except ImportError: - raise ImportError( - 'Please run "pip install open3d" to install open3d first.') + from .open3d_vis import Visualizer if show: vis = Visualizer(points)