Commit 4d437609 authored by zhangwenwei's avatar zhangwenwei
Browse files

Switch ops from mmdet to mmcv

parent ce4f66b6
......@@ -28,7 +28,7 @@ linting:
script:
- echo "Start building..."
- pip install -q "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
- pip install -q git+https://github.com/open-mmlab/mmcv.git@v0.6.2
- pip install -q pip install mmcv==1.0rc0+torch1.3.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
- pip install -q git+https://github.com/open-mmlab/mmdetection.git
- python -c "import mmdet; print(mmdet.__version__)"
- pip install -e .[all]
......
from mmdet.ops import (RoIAlign, SigmoidFocalLoss, get_compiler_version,
get_compiling_cuda_version, nms, roi_align,
from mmcv.ops import (RoIAlign, SigmoidFocalLoss, nms, roi_align,
sigmoid_focal_loss)
from .ball_query import ball_query
from .furthest_point_sample import furthest_point_sample
from .gather_points import gather_points
......@@ -13,6 +13,7 @@ from .roiaware_pool3d import (RoIAwarePool3d, points_in_boxes_batch,
points_in_boxes_cpu, points_in_boxes_gpu)
from .sparse_block import (SparseBasicBlock, SparseBottleneck,
make_sparse_convmodule)
from .utils import get_compiler_version, get_compiling_cuda_version
from .voxel import DynamicScatter, Voxelization, dynamic_scatter, voxelization
__all__ = [
......@@ -25,5 +26,6 @@ __all__ = [
'make_sparse_convmodule', 'ball_query', 'furthest_point_sample',
'three_interpolate', 'three_nn', 'gather_points', 'grouping_operation',
'group_points', 'GroupAll', 'QueryAndGroup', 'PointSAModule',
'PointSAModuleMSG', 'PointFPModule', 'points_in_boxes_batch'
'PointSAModuleMSG', 'PointFPModule', 'points_in_boxes_batch',
'get_compiler_version', 'get_compiling_cuda_version'
]
# from . import compiling_info
from .compiling_info import get_compiler_version, get_compiling_cuda_version
__all__ = ['get_compiler_version', 'get_compiling_cuda_version']
// modified from
// https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/vision.cpp
#include <torch/extension.h>
#ifdef WITH_CUDA
#include <cuda_runtime_api.h>
int get_cudart_version() { return CUDART_VERSION; }
#endif
std::string get_compiling_cuda_version() {
#ifdef WITH_CUDA
std::ostringstream oss;
// copied from
// https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/cuda/detail/CUDAHooks.cpp#L231
auto printCudaStyleVersion = [&](int v) {
oss << (v / 1000) << "." << (v / 10 % 100);
if (v % 10 != 0) {
oss << "." << (v % 10);
}
};
printCudaStyleVersion(get_cudart_version());
return oss.str();
#else
return std::string("not available");
#endif
}
// similar to
// https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/Version.cpp
std::string get_compiler_version() {
std::ostringstream ss;
#if defined(__GNUC__)
#ifndef __clang__
{ ss << "GCC " << __GNUC__ << "." << __GNUC_MINOR__; }
#endif
#endif
#if defined(__clang_major__)
{
ss << "clang " << __clang_major__ << "." << __clang_minor__ << "."
<< __clang_patchlevel__;
}
#endif
#if defined(_MSC_VER)
{ ss << "MSVC " << _MSC_FULL_VER; }
#endif
return ss.str();
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("get_compiler_version", &get_compiler_version, "get_compiler_version");
m.def("get_compiling_cuda_version", &get_compiling_cuda_version,
"get_compiling_cuda_version");
}
......@@ -54,7 +54,7 @@ def collect_env():
env_info['MMCV'] = mmcv.__version__
env_info['MMDetection'] = mmdet.__version__
env_info['MMDetection3D'] = mmdet3d.__version__
from mmdet.ops import get_compiler_version, get_compiling_cuda_version
from mmdet3d.ops import get_compiler_version, get_compiling_cuda_version
env_info['MMDetection3D Compiler'] = get_compiler_version()
env_info['MMDetection3D CUDA Compiler'] = get_compiling_cuda_version()
return env_info
......
......@@ -225,6 +225,10 @@ if __name__ == '__main__':
'optional': parse_requirements('requirements/optional.txt'),
},
ext_modules=[
make_cuda_ext(
name='compiling_info',
module='mmdet.ops.utils',
sources=['src/compiling_info.cpp']),
make_cuda_ext(
name='sparse_conv_ext',
module='mmdet3d.ops.spconv',
......
......@@ -2,6 +2,7 @@ import mmcv
import numpy as np
import pickle
from mmcv import track_iter_progress
from mmcv.ops import roi_align
from os import path as osp
from pycocotools import mask as maskUtils
from pycocotools.coco import COCO
......@@ -9,7 +10,6 @@ from pycocotools.coco import COCO
from mmdet3d.core.bbox import box_np_ops as box_np_ops
from mmdet3d.datasets import build_dataset
from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps
from mmdet.ops import roi_align
def _poly2mask(mask_ann, img_h, img_w):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment