Something on RoIAlign --- basic introduction and implementation

2018-10-22 22:40:09

Paper: Mask RCNN

Codehttps://github.com/longcw/RoIAlign.pytorch

Blog:

1. https://www.cnblogs.com/wangyong/p/8523814.html

2. https://blog.csdn.net/JNingWei/article/details/78822159

3. https://blog.csdn.net/Julialove102123/article/details/80567827

===========  Introduction  ===========

see this blog: https://www.cnblogs.com/wangxiaocvpr/p/9840230.html

===========  Implementation  ===========

git clone https://github.com/longcw/RoIAlign.pytorch

cd RoIAlign.pytorch

modify the script install.sh and test.sh into the following way:

#!/usr/bin/env bash

CUDA_PATH=/usr/local/cuda

echo "Compiling crop_and_resize kernels by nvcc..."
cd roi_align/src/cuda
$CUDA_PATH/bin/nvcc -c -o crop_and_resize_kernel.cu.o crop_and_resize_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_30 \
-gencode=arch=compute_30,code=sm_30 \
-gencode=arch=compute_50,code=sm_50 \
-gencode=arch=compute_52,code=sm_52 \
-gencode=arch=compute_60,code=sm_60 \
-gencode=arch=compute_61,code=sm_61 \
-gencode=arch=compute_62,code=sm_62 \ cd ../../../roi_align
python3 build.py cd ..
python3 setup.py install
#find $CONDA_PREFIX -name roi_align | awk '{mkdir $0 "/_ext" }' |bash
#find $CONDA_PREFIX -name roi_align | awk '{print "cp -r roi_align/_ext/* " $0 "/_ext/" }' |bash
python3 tests/test.py
python3 tests/test2.py
python3 tests/crop_and_resize_example.py

then, run the test.sh, you can found this:

wangxiao@AHU:/media/wangxiao/b8efbc67-7ea5-476d-9631-70da75f84e2d/reference_code/RoIAlign.pytorch$ sh ./test.sh
/usr/local/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
return f(*args, **kwds)
pytorch forward and backward start
pytorch forward and backward end
2018-10-22 22:38:28.483699: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-22 22:38:28.492705: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-10-22 22:38:28.493019: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.898
pciBusID: 0000:02:00.0
totalMemory: 7.92GiB freeMemory: 6.29GiB
2018-10-22 22:38:28.493047: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:02:00.0, compute capability: 6.1)
2018-10-22 22:38:28.737003: E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7102 (compatibility version 7100) but source was compiled with 6021 (compatibility version 6000). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
2018-10-22 22:38:28.737107: F tensorflow/core/kernels/conv_ops.cc:667] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)
Aborted
tensor([[[[0., 1., 2.],
[0., 1., 2.],
[0., 1., 2.]]]], grad_fn=<CropAndResizeFunction>)
torch.Size([2, 3, 500, 500])


Some Bug you may meet:

1. cffi.error.VerificationError: LinkError: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

==>> run the followings in the terminal before you run "sh make.sh":

export CUDA_PATH=/usr/local/cuda/
export CXXFLAGS="-std=c++11"
export CFLAGS="-std=c99"
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export CPATH=/usr/local/cuda-8.0/include${CPATH:+:${CPATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

then, it will shown you the followings:

wangxiao@AHU:~/Documents/Detectron.pytorch/lib$ sh make.sh
running build_ext
building 'utils.cython_bbox' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/utils
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/usr/local/lib/python2./dist-packages/numpy/core/include -I/usr/include/python2. -c utils/cython_bbox.c -o build/temp.linux-x86_64-2.7/utils/cython_bbox.o -Wno-cpp
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/utils
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 build/temp.linux-x86_64-2.7/utils/cython_bbox.o -o build/lib.linux-x86_64-2.7/utils/cython_bbox.so
building 'utils.cython_nms' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/usr/local/lib/python2./dist-packages/numpy/core/include -I/usr/include/python2. -c utils/cython_nms.c -o build/temp.linux-x86_64-2.7/utils/cython_nms.o -Wno-cpp
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 build/temp.linux-x86_64-2.7/utils/cython_nms.o -o build/lib.linux-x86_64-2.7/utils/cython_nms.so
copying build/lib.linux-x86_64-2.7/utils/cython_bbox.so -> utils
copying build/lib.linux-x86_64-2.7/utils/cython_nms.so -> utils
Compiling nms kernels by nvcc...
Including CUDA code.
/home/wangxiao/Documents/Detectron.pytorch/lib/model/nms
['/home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda_kernel.cu.o']
generating /tmp/tmp1cFjY6/_nms.c
setting the current directory to '/tmp/tmp1cFjY6'
running build_ext
building '_nms' extension
creating home
creating home/wangxiao
creating home/wangxiao/Documents
creating home/wangxiao/Documents/Detectron.pytorch
creating home/wangxiao/Documents/Detectron.pytorch/lib
creating home/wangxiao/Documents/Detectron.pytorch/lib/model
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/nms
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c _nms.c -o ./_nms.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 ./_nms.o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda.o /home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda_kernel.cu.o -o ./_nms.so
Compiling roi pooling kernels by nvcc...
Including CUDA code.
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling
generating /tmp/tmpUUPhTw/_roi_pooling.c
setting the current directory to '/tmp/tmpUUPhTw'
running build_ext
building '_roi_pooling' extension
creating home
creating home/wangxiao
creating home/wangxiao/Documents
creating home/wangxiao/Documents/Detectron.pytorch
creating home/wangxiao/Documents/Detectron.pytorch/lib
creating home/wangxiao/Documents/Detectron.pytorch/lib/model
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c _roi_pooling.c -o ./_roi_pooling.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling_cuda.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling_cuda.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 ./_roi_pooling.o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling.o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling_cuda.o /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src/roi_pooling.cu.o -o ./_roi_pooling.so
Compiling roi crop kernels by nvcc...
Including CUDA code.
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop
generating /tmp/tmp2NBTVb/_roi_crop.c
setting the current directory to '/tmp/tmp2NBTVb'
running build_ext
building '_roi_crop' extension
creating home
creating home/wangxiao
creating home/wangxiao/Documents
creating home/wangxiao/Documents/Detectron.pytorch
creating home/wangxiao/Documents/Detectron.pytorch/lib
creating home/wangxiao/Documents/Detectron.pytorch/lib/model
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop
creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c _roi_crop.c -o ./_roi_crop.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.o
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c: In function ‘BilinearSamplerBHWD_updateGradInput’:
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inBottomRight’ [-Wunused-variable]
real inBottomRight=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inBottomLeft’ [-Wunused-variable]
real inBottomLeft=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inTopRight’ [-Wunused-variable]
real inTopRight=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inTopLeft’ [-Wunused-variable]
real inTopLeft=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘v’ [-Wunused-variable]
real v=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c: In function ‘BilinearSamplerBCHW_updateGradInput’:
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inBottomRight’ [-Wunused-variable]
real inBottomRight=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inBottomLeft’ [-Wunused-variable]
real inBottomLeft=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inTopRight’ [-Wunused-variable]
real inTopRight=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘inTopLeft’ [-Wunused-variable]
real inTopLeft=;
^
/home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable ‘v’ [-Wunused-variable]
real v=;
^
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop_cuda.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop_cuda.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 ./_roi_crop.o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.o ./home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop_cuda.o /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop_cuda_kernel.cu.o -o ./_roi_crop.so
Compiling roi align kernels by nvcc...
Including CUDA code.
/home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align
generating /tmp/tmptraHMG/_roi_align.c
setting the current directory to '/tmp/tmptraHMG'
running build_ext
building '_roi_align' extension
creating home
creating home/wangxiao
creating home/wangxiao/Documents
creating home/wangxiao/Documents/Detectron.pytorch
creating home/wangxiao/Documents/Detectron.pytorch/lib
creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling
creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom
creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align
creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c _roi_align.c -o ./_roi_align.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2./dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/usr/include/python2. -c /home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.c -o ./home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE= -g -fstack-protector --param=ssp-buffer-size= -Wformat -Werror=format-security -std=c99 ./_roi_align.o ./home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.o /home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu.o -o ./_roi_align.so
wangxiao@AHU:~/Documents/Detectron.pytorch/lib$

2. You may also meet the following issues: AttributeError: 'module' object has no attribute 'getLogger'

Traceback (most recent call last):
File "tools/train_net_step.py", line , in <module>
import utils.net as net_utils
File "/home/Detectron.pytorch/lib/utils/net.py", line , in <module>
logger = logging.getLogger(__name__)
AttributeError: 'module' object has no attribute 'getLogger'

you need to re-compile the lib with python3.6. i.e. change the make.sh into follows: 

#!/usr/bin/env bash

CUDA_PATH=/usr/local/cuda/

python3 setup.py build_ext --inplace
rm -rf build # Choose cuda arch as you need
CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 "
# -gencode arch=compute_70,code=sm_70 " # compile NMS
cd model/nms/src
echo "Compiling nms kernels by nvcc..."
nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \
-D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH cd ../
python3 build.py # compile roi_pooling
cd ../../
cd model/roi_pooling/src
echo "Compiling roi pooling kernels by nvcc..."
nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \
-D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py # # compile roi_align
# cd ../../
# cd model/roi_align/src
# echo "Compiling roi align kernels by nvcc..."
# nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
# -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
# cd ../
# python3 build.py # compile roi_crop
cd ../../
cd model/roi_crop/src
echo "Compiling roi crop kernels by nvcc..."
nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \
-D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py # compile roi_align (based on Caffe2's implementation)
cd ../../
cd modeling/roi_xfrom/roi_align/src
echo "Compiling roi align kernels by nvcc..."
nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
-D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py

you also need to copy the file: e2e_mask_rcnn_R-50-C4_1x.yaml and rename it as: e2e_mask_rcnn_R-50-C4.yml

then, you can run the script to train the model: 

$ python3 tools/train_net_step.py --dataset coco2017 --cfg configs/baselines/e2e_mask_rcnn_R-50-C4.yml --use_tfboard --bs 5 --nw 2

wangxiao@AHU:~/Documents/Detectron.pytorch$ python3 tools/train_net_step.py --dataset coco2017 --cfg configs/baselines/e2e_mask_rcnn_R--C4.yml --use_tfboard --bs  --nw 
Called with args:
Namespace(batch_size=, cfg_file='configs/baselines/e2e_mask_rcnn_R-50-C4.yml', cuda=True, dataset='coco2017', disp_interval=, iter_size=, load_ckpt=None, load_detectron=None, lr=None, lr_decay_gamma=None, no_save=False, num_workers=, optimizer=None, resume=False, set_cfgs=[], start_step=, use_tfboard=True)
effective_batch_size = batch_size * iter_size = *
Adaptive config changes:
effective_batch_size: -->
NUM_GPUS: -->
IMS_PER_BATCH: -->
Adjust BASE_LR linearly according to batch_size change:
BASE_LR: 0.01 --> 0.00125
Adjust SOLVER.STEPS and SOLVER.MAX_ITER linearly based on effective_batch_size change:
SOLVER.STEPS: [, , ] --> [, , ]
SOLVER.MAX_ITER: -->
Number of data loading threads:
loading annotations into memory...
Done (t=.39s)
creating index...
index created!
INFO json_dataset.py: : Loading cached gt_roidb from /home/wangxiao/Documents/Detectron.pytorch/data/cache/coco_2017_train_gt_roidb.pkl
INFO roidb.py: : Appending horizontally-flipped training examples...
INFO roidb.py: : Loaded dataset: coco_2017_train
INFO roidb.py: : Filtered roidb entries: ->
INFO roidb.py: : Computing image aspect ratios and ordering the ratios...
INFO roidb.py: : done
INFO roidb.py: : Computing bounding-box regression targets...
INFO roidb.py: : done
INFO train_net_step.py: : roidb entries
INFO train_net_step.py: : Takes 93.39 sec(s) to construct roidb
INFO train_net_step.py: : Training starts !
INFO net.py: : Changing learning rate 0.000000 -> 0.000417
/usr/local/lib/python3./site-packages/torch/nn/functional.py:: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
/usr/local/lib/python3./site-packages/torch/nn/functional.py:: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
warnings.warn(warning.format(ret))
[Nov24---26_AHU_step][e2e_mask_rcnn_R--C4.yml][Step / ]
loss: 6.916170, lr: 0.000417 time: 0.721983, eta: days, ::
accuracy_cls: 0.001953
loss_cls: 4.648660, loss_bbox: 0.030453, loss_mask: 0.858463
loss_rpn_cls: 0.676336, loss_rpn_bbox: 0.702258

==

Something on RoIAlign --- basic introduction and implementation的更多相关文章

  1. The basic introduction to MIX language and machine

    reference: The MIX Computer, The MIX Introduction sets, The basic info storage unit in MIX computer ...

  2. RESTFul basic introduction

    http://www.ruanyifeng.com/blog/2011/09/restful.html

  3. 可分离卷积详解及计算量 Basic Introduction to Separable Convolutions

    任何看过MobileNet架构的人都会遇到可分离卷积(separable convolutions)这个概念.但什么是“可分离卷积”,它与标准的卷积又有什么区别?可分离卷积主要有两种类型: 空间可分离 ...

  4. Cyber Security - Palo Alto Basic Introduction

    Preparation of the Lab Environment: Download and Install Pan-OS from the following website https://d ...

  5. 6.在MVC中使用泛型仓储模式和依赖注入实现增删查改

    原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository-pat ...

  6. 机器学习公开课笔记(4):神经网络(Neural Network)——表示

    动机(Motivation) 对于非线性分类问题,如果用多元线性回归进行分类,需要构造许多高次项,导致特征特多学习参数过多,从而复杂度太高. 神经网络(Neural Network) 一个简单的神经网 ...

  7. TensorFlow tutorial

    代码示例来自https://github.com/aymericdamien/TensorFlow-Examples tensorflow先定义运算图,在run的时候才会进行真正的运算. run之前需 ...

  8. CSC 172 (Data Structures and Algorithms)

    Project #3 (STREET MAPPING)CSC 172 (Data Structures and Algorithms), Spring 2019,University of Roche ...

  9. How do I learn machine learning?

    https://www.quora.com/How-do-I-learn-machine-learning-1?redirected_qid=6578644   How Can I Learn X? ...

随机推荐

  1. 19. vue的原理

    vue:原理1 => Object.defineProperty 当你把一个普通的 JavaScript 对象传给 Vue 实例的 data 选项,Vue 将遍历此对象所有的属性,并使用 Obj ...

  2. C# word 图片大小

    通过Office自带的类库word文档中插入图片,图片大小的单位为磅 而文档中,图片的大小已经固定,为CM. 实际工作中,首先将图片插入到word中,根据目前的大小,计算转换为目标大小的比率,将长宽按 ...

  3. js的简单介绍

    1.js的介绍 js全称叫javascript,但不是java,他是一门前台语言,而java是后台语言. js的作者是布兰登艾奇. 前台语言:运行在客户端的 后台语言:跟数据库有关的. 2.能干什么? ...

  4. 编写函数求整形数组a中存储的m个不重复的整数的第k大的整数(其中m>=1,1<=k<=m)很简单的一个思路是酱紫的:管他辣么多干啥,上来一把排序然后直接得答案

    /** * @author:(LiberHome) * @date:Created in 2019/2/28 20:38 * @description: * @version:$ *//*编写函数求整 ...

  5. div加链接 html给div加超链接实现点击div跳转的方法[申明:来源于网络]

    div加链接 html给div加超链接实现点击div跳转的方法[申明:来源于网络] 地址:http://www.cdxwcx.com/faq/htmldivLink.html

  6. 最短路径spfa

    #include <stdio.h> #include <string.h> #include <algorithm> #include <queue> ...

  7. Cesium调用 WMS 、WMTS 服务

    参考文章地址:Cesium调用 ArcGIS Sever 以及 GeoSever 发布的地图服务 cesium测试示例(包括官方的示例)中   arcgis服务都无法访问了 根据原文找到一个在线的可访 ...

  8. 面试题----入参两个Integer,无返回值,然后使这个两个值在调用函数后交换

    我最近看到过一个比较好玩的面试题. 写个方法,入参两个Integer,无返回值,然后使这个两个值在调用函数后交换 很有意思的一个题目,引发我的深思,根据一路的学习过来,下面把实现代码贴出来,方便学习. ...

  9. 【托业】toeic托业必背核心词汇_修正版

  10. java框架之SpringBoot(13)-检索及整合Elasticsearch

    ElasticSearch介绍 简介 我们的应用经常需要使用检索功能,开源的 Elasticsearch 是目前全文搜索引擎的首选.它可以快速的存储.搜索和分析海量数据.SpringBoot 通过整合 ...