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:

  1. #!/usr/bin/env bash
  2.  
  3. CUDA_PATH=/usr/local/cuda
  4.  
  5. echo "Compiling crop_and_resize kernels by nvcc..."
  6. cd roi_align/src/cuda
  7. $CUDA_PATH/bin/nvcc -c -o crop_and_resize_kernel.cu.o crop_and_resize_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_30 \
  8. -gencode=arch=compute_30,code=sm_30 \
  9. -gencode=arch=compute_50,code=sm_50 \
  10. -gencode=arch=compute_52,code=sm_52 \
  11. -gencode=arch=compute_60,code=sm_60 \
  12. -gencode=arch=compute_61,code=sm_61 \
  13. -gencode=arch=compute_62,code=sm_62 \
  14.  
  15. cd ../../../roi_align
  16. python3 build.py
  17.  
  18. cd ..
  19. python3 setup.py install
  20. #find $CONDA_PREFIX -name roi_align | awk '{mkdir $0 "/_ext" }' |bash
  21. #find $CONDA_PREFIX -name roi_align | awk '{print "cp -r roi_align/_ext/* " $0 "/_ext/" }' |bash
  1. python3 tests/test.py
  2. python3 tests/test2.py
  3. 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":

  1. export CUDA_PATH=/usr/local/cuda/
  2. export CXXFLAGS="-std=c++11"
  3. export CFLAGS="-std=c99"
  4. export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
  5. export CPATH=/usr/local/cuda-8.0/include${CPATH:+:${CPATH}}
  6. export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

then, it will shown you the followings:

  1. wangxiao@AHU:~/Documents/Detectron.pytorch/lib$ sh make.sh
  2. running build_ext
  3. building 'utils.cython_bbox' extension
  4. creating build
  5. creating build/temp.linux-x86_64-2.7
  6. creating build/temp.linux-x86_64-2.7/utils
  7. 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
  8. creating build/lib.linux-x86_64-2.7
  9. creating build/lib.linux-x86_64-2.7/utils
  10. 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
  11. building 'utils.cython_nms' extension
  12. 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
  13. 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
  14. copying build/lib.linux-x86_64-2.7/utils/cython_bbox.so -> utils
  15. copying build/lib.linux-x86_64-2.7/utils/cython_nms.so -> utils
  16. Compiling nms kernels by nvcc...
  17. Including CUDA code.
  18. /home/wangxiao/Documents/Detectron.pytorch/lib/model/nms
  19. ['/home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src/nms_cuda_kernel.cu.o']
  20. generating /tmp/tmp1cFjY6/_nms.c
  21. setting the current directory to '/tmp/tmp1cFjY6'
  22. running build_ext
  23. building '_nms' extension
  24. creating home
  25. creating home/wangxiao
  26. creating home/wangxiao/Documents
  27. creating home/wangxiao/Documents/Detectron.pytorch
  28. creating home/wangxiao/Documents/Detectron.pytorch/lib
  29. creating home/wangxiao/Documents/Detectron.pytorch/lib/model
  30. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/nms
  31. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/nms/src
  32. 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
  33. 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
  34. 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
  35. Compiling roi pooling kernels by nvcc...
  36. Including CUDA code.
  37. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling
  38. generating /tmp/tmpUUPhTw/_roi_pooling.c
  39. setting the current directory to '/tmp/tmpUUPhTw'
  40. running build_ext
  41. building '_roi_pooling' extension
  42. creating home
  43. creating home/wangxiao
  44. creating home/wangxiao/Documents
  45. creating home/wangxiao/Documents/Detectron.pytorch
  46. creating home/wangxiao/Documents/Detectron.pytorch/lib
  47. creating home/wangxiao/Documents/Detectron.pytorch/lib/model
  48. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling
  49. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_pooling/src
  50. 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
  51. 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
  52. 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
  53. 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
  54. Compiling roi crop kernels by nvcc...
  55. Including CUDA code.
  56. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop
  57. generating /tmp/tmp2NBTVb/_roi_crop.c
  58. setting the current directory to '/tmp/tmp2NBTVb'
  59. running build_ext
  60. building '_roi_crop' extension
  61. creating home
  62. creating home/wangxiao
  63. creating home/wangxiao/Documents
  64. creating home/wangxiao/Documents/Detectron.pytorch
  65. creating home/wangxiao/Documents/Detectron.pytorch/lib
  66. creating home/wangxiao/Documents/Detectron.pytorch/lib/model
  67. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop
  68. creating home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src
  69. 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
  70. 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
  71. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c: In function BilinearSamplerBHWD_updateGradInput’:
  72. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inBottomRight [-Wunused-variable]
  73. real inBottomRight=;
  74. ^
  75. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inBottomLeft [-Wunused-variable]
  76. real inBottomLeft=;
  77. ^
  78. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inTopRight [-Wunused-variable]
  79. real inTopRight=;
  80. ^
  81. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inTopLeft [-Wunused-variable]
  82. real inTopLeft=;
  83. ^
  84. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable v [-Wunused-variable]
  85. real v=;
  86. ^
  87. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c: In function BilinearSamplerBCHW_updateGradInput’:
  88. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inBottomRight [-Wunused-variable]
  89. real inBottomRight=;
  90. ^
  91. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inBottomLeft [-Wunused-variable]
  92. real inBottomLeft=;
  93. ^
  94. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inTopRight [-Wunused-variable]
  95. real inTopRight=;
  96. ^
  97. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable inTopLeft [-Wunused-variable]
  98. real inTopLeft=;
  99. ^
  100. /home/wangxiao/Documents/Detectron.pytorch/lib/model/roi_crop/src/roi_crop.c::: warning: unused variable v [-Wunused-variable]
  101. real v=;
  102. ^
  103. 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
  104. 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
  105. Compiling roi align kernels by nvcc...
  106. Including CUDA code.
  107. /home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align
  108. generating /tmp/tmptraHMG/_roi_align.c
  109. setting the current directory to '/tmp/tmptraHMG'
  110. running build_ext
  111. building '_roi_align' extension
  112. creating home
  113. creating home/wangxiao
  114. creating home/wangxiao/Documents
  115. creating home/wangxiao/Documents/Detectron.pytorch
  116. creating home/wangxiao/Documents/Detectron.pytorch/lib
  117. creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling
  118. creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom
  119. creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align
  120. creating home/wangxiao/Documents/Detectron.pytorch/lib/modeling/roi_xfrom/roi_align/src
  121. 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
  122. 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
  123. 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
  124. wangxiao@AHU:~/Documents/Detectron.pytorch/lib$

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

  1. Traceback (most recent call last):
  2. File "tools/train_net_step.py", line , in <module>
  3. import utils.net as net_utils
  4. File "/home/Detectron.pytorch/lib/utils/net.py", line , in <module>
  5. logger = logging.getLogger(__name__)
  6. 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: 

  1. #!/usr/bin/env bash
  2.  
  3. CUDA_PATH=/usr/local/cuda/
  4.  
  5. python3 setup.py build_ext --inplace
  6. rm -rf build
  7.  
  8. # Choose cuda arch as you need
  9. CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \
  10. -gencode arch=compute_35,code=sm_35 \
  11. -gencode arch=compute_50,code=sm_50 \
  12. -gencode arch=compute_52,code=sm_52 \
  13. -gencode arch=compute_60,code=sm_60 \
  14. -gencode arch=compute_61,code=sm_61 "
  15. # -gencode arch=compute_70,code=sm_70 "
  16.  
  17. # compile NMS
  18. cd model/nms/src
  19. echo "Compiling nms kernels by nvcc..."
  20. nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \
  21. -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
  22.  
  23. cd ../
  24. python3 build.py
  25.  
  26. # compile roi_pooling
  27. cd ../../
  28. cd model/roi_pooling/src
  29. echo "Compiling roi pooling kernels by nvcc..."
  30. nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \
  31. -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
  32. cd ../
  33. python3 build.py
  34.  
  35. # # compile roi_align
  36. # cd ../../
  37. # cd model/roi_align/src
  38. # echo "Compiling roi align kernels by nvcc..."
  39. # nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
  40. # -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
  41. # cd ../
  42. # python3 build.py
  43.  
  44. # compile roi_crop
  45. cd ../../
  46. cd model/roi_crop/src
  47. echo "Compiling roi crop kernels by nvcc..."
  48. nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \
  49. -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
  50. cd ../
  51. python3 build.py
  52.  
  53. # compile roi_align (based on Caffe2's implementation)
  54. cd ../../
  55. cd modeling/roi_xfrom/roi_align/src
  56. echo "Compiling roi align kernels by nvcc..."
  57. nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
  58. -D GOOGLE_CUDA= -x cu -Xcompiler -fPIC $CUDA_ARCH
  59. cd ../
  60. 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

  1. 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
  2. Called with args:
  3. 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)
  4. effective_batch_size = batch_size * iter_size = *
  5. Adaptive config changes:
  6. effective_batch_size: -->
  7. NUM_GPUS: -->
  8. IMS_PER_BATCH: -->
  9. Adjust BASE_LR linearly according to batch_size change:
  10. BASE_LR: 0.01 --> 0.00125
  11. Adjust SOLVER.STEPS and SOLVER.MAX_ITER linearly based on effective_batch_size change:
  12. SOLVER.STEPS: [, , ] --> [, , ]
  13. SOLVER.MAX_ITER: -->
  14. Number of data loading threads:
  15. loading annotations into memory...
  16. Done (t=.39s)
  17. creating index...
  18. index created!
  19. INFO json_dataset.py: : Loading cached gt_roidb from /home/wangxiao/Documents/Detectron.pytorch/data/cache/coco_2017_train_gt_roidb.pkl
  20. INFO roidb.py: : Appending horizontally-flipped training examples...
  21. INFO roidb.py: : Loaded dataset: coco_2017_train
  22. INFO roidb.py: : Filtered roidb entries: ->
  23. INFO roidb.py: : Computing image aspect ratios and ordering the ratios...
  24. INFO roidb.py: : done
  25. INFO roidb.py: : Computing bounding-box regression targets...
  26. INFO roidb.py: : done
  27. INFO train_net_step.py: : roidb entries
  28. INFO train_net_step.py: : Takes 93.39 sec(s) to construct roidb
  29. INFO train_net_step.py: : Training starts !
  30. INFO net.py: : Changing learning rate 0.000000 -> 0.000417
  31. /usr/local/lib/python3./site-packages/torch/nn/functional.py:: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  32. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
  33. /usr/local/lib/python3./site-packages/torch/nn/functional.py:: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
  34. warnings.warn(warning.format(ret))
  35. [Nov24---26_AHU_step][e2e_mask_rcnn_R--C4.yml][Step / ]
  36. loss: 6.916170, lr: 0.000417 time: 0.721983, eta: days, ::
  37. accuracy_cls: 0.001953
  38. loss_cls: 4.648660, loss_bbox: 0.030453, loss_mask: 0.858463
  39. 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. css文字上下居中,一行文字居中,两行或多行文字同样居中

    附图: 1. 利用Flex布局实现 demo.html <div class="demo demo-flex"><span>孤云将野鹤,岂向人间住.莫买沃洲 ...

  2. 查看oracle数据库是否为归档模式

    查看oracle数据库是否为归档模式   [1]   1.select name,log_mode from v$database;   NAME LOG_MODE   --------------- ...

  3. CF3A Shortest path of the king

    The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, becaus ...

  4. Spring boot Mybatis 整合(完整版)

    个人开源项目 springboot+mybatis+thymeleaf+docker构建的个人站点开源项目(集成了个人主页.个人作品.个人博客) 朋友自制的springboot接口文档组件swagge ...

  5. ERP项目实施记录10

    好久没有更新,因为进度一直拖着.已经实施了20个月了,很多东西没有开发出来.原因多方面的,虽然在此打算吐槽一下开发公司,但其实很大部分责任还是在我们自己. 不多说了,看图:

  6. python全栈开发 * 36知识点汇总 * 180721

    36 操作系统的发展史 进程一.手工操作--穿孔卡片 1.内容: 程序员将对应于程序和数据的已穿孔的纸带(或卡片)装入输入机,然后启动输入机把程序和数据输入计算机内存,接着通过控制 台开关启动程序针对 ...

  7. python2,python3同时安装时,python3可以安装并升级pip库,python2报错的解决办法

    最近在使用pip安装包的的时候出现下面错误 UnicodeEncodeError: 'ascii' codec can't encode character u'\u258f' 查询资料后发现原因是p ...

  8. ES6 数组

    数组创建 Array.of() 将参数中所有值作为元素形成数组. console.log(Array.of(1, 2, 3, 4)); // [1, 2, 3, 4] // 参数值可为不同类型 con ...

  9. windows 创建共享文件夹

    1.右键要共享的文件夹----“共享”------“指定特定用户”,出现如下对话框: 2.选择“Everyone”,点击“共享”按钮,如下: 3.打开“运行“(win+r),输入上图 双反斜杠后面的内 ...

  10. python框架之Django(5)-O/RM

    字段&参数 字段与db类型的对应关系 字段 DB Type AutoField integer AUTO_INCREMENT BigAutoField bigint AUTO_INCREMEN ...