Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] Pretty log about MinkowskiEngine and running rightly on env without open3d #2027

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mmdet3d/models/backbones/mink_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import MinkowskiEngine as ME
from MinkowskiEngine.modules.resnet_block import BasicBlock, Bottleneck
except ImportError:
import warnings
warnings.warn(
'Please follow `getting_started.md` to install MinkowskiEngine.`')
# blocks are used in the static part of MinkResNet
BasicBlock, Bottleneck = None, None
ME = BasicBlock = Bottleneck = None

import torch.nn as nn

Expand Down Expand Up @@ -38,6 +35,10 @@ class MinkResNet(nn.Module):

def __init__(self, depth, in_channels, num_stages=4, pool=True):
super(MinkResNet, self).__init__()
if ME is None:
raise ImportError(
'Please follow `getting_started.md` to install MinkowskiEngine.`' # noqa: E501
)
if depth not in self.arch_settings:
raise KeyError(f'invalid depth {depth} for resnet')
assert 4 >= num_stages >= 1
Expand Down
6 changes: 5 additions & 1 deletion mmdet3d/models/dense_heads/fcaf3d_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from MinkowskiEngine import SparseTensor
except ImportError:
# Please follow getting_started.md to install MinkowskiEngine.
SparseTensor = None
ME = SparseTensor = None
pass

import torch
Expand Down Expand Up @@ -69,6 +69,10 @@ def __init__(self,
test_cfg: Optional[dict] = None,
init_cfg: Optional[dict] = None):
super(FCAF3DHead, self).__init__(init_cfg)
if ME is None:
raise ImportError(
'Please follow `getting_started.md` to install MinkowskiEngine.`' # noqa: E501
)
self.voxel_size = voxel_size
self.pts_prune_threshold = pts_prune_threshold
self.pts_assign_threshold = pts_assign_threshold
Expand Down
7 changes: 5 additions & 2 deletions mmdet3d/models/detectors/mink_single_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import MinkowskiEngine as ME
except ImportError:
# Please follow getting_started.md to install MinkowskiEngine.
ME = None
pass

from mmdet3d.registry import MODELS
Expand Down Expand Up @@ -56,9 +57,11 @@ def __init__(self,
test_cfg=test_cfg,
data_preprocessor=data_preprocessor,
init_cfg=init_cfg)
if ME is None:
raise ImportError(
'Please follow `getting_started.md` to install MinkowskiEngine.`' # noqa: E501
)
self.voxel_size = bbox_head['voxel_size']
# # TODO: unify the keys
# self.head = self.bbox_head

def extract_feat(
self, batch_inputs_dict: Dict[str, Tensor]
Expand Down
9 changes: 6 additions & 3 deletions mmdet3d/visualization/local_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
try:
import open3d as o3d
from open3d import geometry
from open3d.visualization import Visualizer
except ImportError:
raise ImportError(
'Please run "pip install open3d" to install open3d first.')
o3d = geometry = Visualizer = None


@VISUALIZERS.register_module()
Expand Down Expand Up @@ -126,7 +126,7 @@ def _clear_o3d_vis(self) -> None:
del self.pcd
del self.points_colors

def _initialize_o3d_vis(self, frame_cfg) -> o3d.visualization.Visualizer:
def _initialize_o3d_vis(self, frame_cfg) -> Visualizer:
"""Initialize open3d vis according to frame_cfg.

Args:
Expand All @@ -136,6 +136,9 @@ def _initialize_o3d_vis(self, frame_cfg) -> o3d.visualization.Visualizer:
Returns:
:obj:`o3d.visualization.Visualizer`: Created open3d vis.
"""
if o3d is None or geometry is None:
raise ImportError(
'Please run "pip install open3d" to install open3d first.')
o3d_vis = o3d.visualization.Visualizer()
o3d_vis.create_window()
# create coordinate frame
Expand Down