kolkir / mlcpp Goto Github PK
View Code? Open in Web Editor NEWSet of examples of ML approaches implemented in C++
License: BSD 2-Clause "Simplified" License
Set of examples of ML approaches implemented in C++
License: BSD 2-Clause "Simplified" License
I successfully run the demo. When the program exit, I got
[1] 12790 segmentation fault (core dumped) ./mask-rcnn_demo ~/mask_rcnn_coco.dat test.jpg
I think it is caused by some problems during resource releasing or destruction?
Although it is not a big issue, it is a little annoying and hopefully be fixed.
Hello
I run mask-rcnn_demo. I found it use my gpu memory about 7-8 GB.
It is normal ?
I failed to load pre-trained file with latest version of pytorch, is there any scripts converting the file? thanks!
Now demo can load new pre-trained file in Pytorch 1.01 and Window 10 environment, thanks for upgrading!
But there is a error message as: "invalid argument 12: dilation should be greater than zero, but got dilationH: 508814473 dilationW: 0 at c:\a\w\1\s\windows\pytorch\aten\src\thcunn\generic/SpatialDilatedMaxPooling.cu:20"
The error is from:
auto [detections, mrcnn_mask] = model->Detect(molded_images, image_metas); => PredictInference(images, image_metas); => PredictRPN(images, config_->post_nms_rois_inference); => fpn_->forward(images); =>x = c1_->forward(x);
I use demo code as is, it seems model and weights are not matched, any clues?
I saw you converted the model pretrained weights to a suitable format to be imported into the C++ implementation. However, I could not find how you did it on the repo. I would like to export the weights of my own trained Mask R-CNN on the same format so as to use them in you implementation. Would it be possible to see an example of that, please? Thanks a lot and nice job!
Hi,
For mask rcnn, the output of cmake
is:
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "10.0")
-- Caffe2: CUDA detected: 10.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 10.0
-- Found CUDNN: /usr/include
-- Found cuDNN: v7.6.2 (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Autodetected CUDA architecture(s): 3.7
-- Added CUDA NVCC flags for: -gencode;arch=compute_37,code=sm_37
-- Found torch: /content/libtorch/lib/libtorch.so
-- Found OpenCV: /usr (found version "3.2.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /content/mlcpp/mask_rcnn_pytorch/build
While building the project using make
, the following error occurs:
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -H/content/mlcpp/mask_rcnn_pytorch -B/content/mlcpp/mask_rcnn_pytorch/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E cmake_progress_start /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/content/mlcpp/mask_rcnn_pytorch/build'
make -f CMakeFiles/mask-rcnn_lib.dir/build.make CMakeFiles/mask-rcnn_lib.dir/depend
make[2]: Entering directory '/content/mlcpp/mask_rcnn_pytorch/build'
[ 2%] Building NVCC (Device) object CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o
cd /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda && /usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E make_directory /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/.
cd /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda && /usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o -D generated_cubin_file:STRING=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o.cubin.txt -P /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.cmake
-- Removing /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E remove /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o
-- Generating dependency file: /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.NVCC-depend
/usr/local/cuda/bin/nvcc -M -D__CUDACC__ /content/mlcpp/mask_rcnn_pytorch/nms/cuda/nms_kernel.cu -o /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -D_THP_CORE -DAT_PARALLEL_OPENMP=1 -Xcompiler ,\"-g\" -std=c++14 --compiler-options -Wall --compiler-options -Wextra --compiler-options -Wno-unused-parameter --compiler-options -Wno-unknown-pragmas -g -G -O0 -DNVCC -I/usr/local/cuda/include -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -I/content/libtorch/include -I/content/libtorch/include/torch/csrc/api/include -I/usr/include -I/usr/include/opencv
-- Generating temporary cmake readable file: /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -D input_file:FILEPATH=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.NVCC-depend -D output_file:FILEPATH=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp -D verbose=1 -P /content/libtorch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake
-- Copy if different /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp to /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E copy_if_different /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend
-- Removing /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp and /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.NVCC-depend
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E remove /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.depend.tmp /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/mask-rcnn_lib_generated_nms_kernel.cu.o.NVCC-depend
-- Generating /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o
/usr/local/cuda/bin/nvcc /content/mlcpp/mask_rcnn_pytorch/nms/cuda/nms_kernel.cu -c -o /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o -ccbin /usr/bin/cc -m64 -D_THP_CORE -DAT_PARALLEL_OPENMP=1 -Xcompiler ,\"-g\" -std=c++14 --compiler-options -Wall --compiler-options -Wextra --compiler-options -Wno-unused-parameter --compiler-options -Wno-unknown-pragmas -g -G -O0 -DNVCC -I/usr/local/cuda/include -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -I/content/libtorch/include -I/content/libtorch/include/torch/csrc/api/include -I/usr/include -I/usr/include/opencv
Generated /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/nms/cuda/./mask-rcnn_lib_generated_nms_kernel.cu.o successfully.
[ 5%] Building NVCC (Device) object CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o
cd /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda && /usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E make_directory /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/.
cd /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda && /usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o -D generated_cubin_file:STRING=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.cubin.txt -P /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.cmake
-- Removing /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E remove /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o
-- Generating dependency file: /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.NVCC-depend
/usr/local/cuda/bin/nvcc -M -D__CUDACC__ /content/mlcpp/mask_rcnn_pytorch/roialign/cuda/crop_and_resize_kernel.cu -o /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -D_THP_CORE -DAT_PARALLEL_OPENMP=1 -Xcompiler ,\"-g\" -std=c++14 --compiler-options -Wall --compiler-options -Wextra --compiler-options -Wno-unused-parameter --compiler-options -Wno-unknown-pragmas -g -G -O0 -DNVCC -I/usr/local/cuda/include -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -I/content/libtorch/include -I/content/libtorch/include/torch/csrc/api/include -I/usr/include -I/usr/include/opencv
-- Generating temporary cmake readable file: /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -D input_file:FILEPATH=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.NVCC-depend -D output_file:FILEPATH=/content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp -D verbose=1 -P /content/libtorch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake
-- Copy if different /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp to /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E copy_if_different /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend
-- Removing /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp and /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.NVCC-depend
/usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E remove /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.depend.tmp /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o.NVCC-depend
-- Generating /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o
/usr/local/cuda/bin/nvcc /content/mlcpp/mask_rcnn_pytorch/roialign/cuda/crop_and_resize_kernel.cu -c -o /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o -ccbin /usr/bin/cc -m64 -D_THP_CORE -DAT_PARALLEL_OPENMP=1 -Xcompiler ,\"-g\" -std=c++14 --compiler-options -Wall --compiler-options -Wextra --compiler-options -Wno-unused-parameter --compiler-options -Wno-unknown-pragmas -g -G -O0 -DNVCC -I/usr/local/cuda/include -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -I/content/libtorch/include -I/content/libtorch/include/torch/csrc/api/include -I/usr/include -I/usr/include/opencv
Generated /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/roialign/cuda/./mask-rcnn_lib_generated_crop_and_resize_kernel.cu.o successfully.
cd /content/mlcpp/mask_rcnn_pytorch/build && /usr/local/lib/python2.7/dist-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /content/mlcpp/mask_rcnn_pytorch /content/mlcpp/mask_rcnn_pytorch /content/mlcpp/mask_rcnn_pytorch/build /content/mlcpp/mask_rcnn_pytorch/build /content/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/mask-rcnn_lib.dir/DependInfo.cmake --color=
Scanning dependencies of target mask-rcnn_lib
make[2]: Leaving directory '/content/mlcpp/mask_rcnn_pytorch/build'
make -f CMakeFiles/mask-rcnn_lib.dir/build.make CMakeFiles/mask-rcnn_lib.dir/build
make[2]: Entering directory '/content/mlcpp/mask_rcnn_pytorch/build'
[ 7%] Building CXX object CMakeFiles/mask-rcnn_lib.dir/debug.cpp.o
/usr/bin/c++ -DAT_PARALLEL_OPENMP=1 -D_THP_CORE -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -isystem /content/libtorch/include -isystem /content/libtorch/include/torch/csrc/api/include -isystem /usr/local/cuda/include -isystem /usr/include/opencv -fopenmp -pthread -msse3 -Wall -Wextra -Wno-unused-parameter -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++1z -o CMakeFiles/mask-rcnn_lib.dir/debug.cpp.o -c /content/mlcpp/mask_rcnn_pytorch/debug.cpp
[ 10%] Building CXX object CMakeFiles/mask-rcnn_lib.dir/config.cpp.o
/usr/bin/c++ -DAT_PARALLEL_OPENMP=1 -D_THP_CORE -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -isystem /content/libtorch/include -isystem /content/libtorch/include/torch/csrc/api/include -isystem /usr/local/cuda/include -isystem /usr/include/opencv -fopenmp -pthread -msse3 -Wall -Wextra -Wno-unused-parameter -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++1z -o CMakeFiles/mask-rcnn_lib.dir/config.cpp.o -c /content/mlcpp/mask_rcnn_pytorch/config.cpp
[ 12%] Building CXX object CMakeFiles/mask-rcnn_lib.dir/maskrcnn.cpp.o
/usr/bin/c++ -DAT_PARALLEL_OPENMP=1 -D_THP_CORE -I/content/mlcpp/mask_rcnn_pytorch/../third_party/json/include -isystem /content/libtorch/include -isystem /content/libtorch/include/torch/csrc/api/include -isystem /usr/local/cuda/include -isystem /usr/include/opencv -fopenmp -pthread -msse3 -Wall -Wextra -Wno-unused-parameter -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++1z -o CMakeFiles/mask-rcnn_lib.dir/maskrcnn.cpp.o -c /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:0:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:63:7: error: ‘torch::data::DataLoader’ has not been declared
torch::data::DataLoader<CocoDataset,
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:63:30: error: expected ‘,’ or ‘...’ before ‘<’ token
torch::data::DataLoader<CocoDataset,
^
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:71:7: error: ‘torch::data::DataLoader’ has not been declared
torch::data::DataLoader<CocoDataset,
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:71:30: error: expected ‘,’ or ‘...’ before ‘<’ token
torch::data::DataLoader<CocoDataset,
^
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: In member function ‘void MaskRCNNImpl::Train(CocoDataset, CocoDataset, double, uint32_t, std::string)’:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:118:44: error: no matching function for call to ‘MaskRCNNImpl::TrainEpoch(StatReporter&, torch::data::StatelessDataLoader<CocoDataset, torch::data::samplers::RandomSampler>&, torch::optim::SGD&, torch::optim::SGD&, const uint32_t&)’
config_->steps_per_epoch);
^
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:0:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:61:56: note: candidate: std::tuple<float, float, float, float, float, float> MaskRCNNImpl::TrainEpoch(StatReporter&, int)
std::tuple<float, float, float, float, float, float> TrainEpoch(
^~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:61:56: note: candidate expects 2 arguments, 5 provided
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:123:68: error: no matching function for call to ‘MaskRCNNImpl::ValidEpoch(StatReporter&, torch::data::StatelessDataLoader<CocoDataset, torch::data::samplers::RandomSampler>&, const uint32_t&)’
ValidEpoch(reporter, *val_loader, config_->validation_steps);
^
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:0:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:69:56: note: candidate: std::tuple<float, float, float, float, float, float> MaskRCNNImpl::ValidEpoch(StatReporter&, int)
std::tuple<float, float, float, float, float, float> ValidEpoch(
^~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:69:56: note: candidate expects 2 arguments, 3 provided
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:130:51: error: no matching function for call to ‘StatReporter::ReportEpoch(<brace-enclosed initializer list>, <brace-enclosed initializer list>)’
val_loss_mrcnn_bbox, val_loss_mrcnn_mask});
^
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:11:0,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:41:8: note: candidate: void StatReporter::ReportEpoch(const LossStat&, const LossStat&)
void ReportEpoch(const LossStat& train_stat, const LossStat& valid_stat);
^~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:41:8: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const LossStat&’
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: At global scope:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:148:5: error: ‘torch::data::DataLoader’ has not been declared
torch::data::DataLoader<CocoDataset, torch::data::samplers::RandomSampler>&
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:148:28: error: expected ‘,’ or ‘...’ before ‘<’ token
torch::data::DataLoader<CocoDataset, torch::data::samplers::RandomSampler>&
^
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: In member function ‘std::tuple<float, float, float, float, float, float> MaskRCNNImpl::ValidEpoch(StatReporter&, int)’:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:159:21: error: ‘datagenerator’ was not declared in this scope
for (auto input : datagenerator) {
^~~~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:159:21: note: suggested alternative: ‘CvLineIterator’
for (auto input : datagenerator) {
^~~~~~~~~~~~~
CvLineIterator
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:195:34: error: expected primary-expression before ‘float’
auto loss_ = loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:196:53: error: expected primary-expression before ‘float’
auto loss_rpn_class = rpn_class_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:197:51: error: expected primary-expression before ‘float’
auto loss_rpn_bbox = rpn_bbox_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:198:57: error: expected primary-expression before ‘float’
auto loss_mrcnn_class = mrcnn_class_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:199:55: error: expected primary-expression before ‘float’
auto loss_mrcnn_bbox = mrcnn_bbox_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:200:55: error: expected primary-expression before ‘float’
auto loss_mrcnn_mask = mrcnn_mask_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:203:49: error: no matching function for call to ‘StatReporter::ReportValidationStep(uint32_t&, <brace-enclosed initializer list>)’
loss_mrcnn_bbox, loss_mrcnn_mask});
^
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:11:0,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:40:8: note: candidate: void StatReporter::ReportValidationStep(uint32_t, const LossStat&)
void ReportValidationStep(uint32_t i, const LossStat& stat);
^~~~~~~~~~~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:40:8: note: no known conversion for argument 2 from ‘<brace-enclosed initializer list>’ to ‘const LossStat&’
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:206:25: error: ‘steps’ was not declared in this scope
loss_sum += loss_ / steps;
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:206:25: note: suggested alternatives:
In file included from /content/libtorch/include/ATen/core/ivalue_inl.h:7:0,
from /content/libtorch/include/ATen/core/ivalue.h:601,
from /content/libtorch/include/ATen/core/stack.h:3,
from /content/libtorch/include/torch/csrc/jit/tracer.h:3,
from /content/libtorch/include/torch/csrc/autograd/generated/variable_factories.h:9,
from /content/libtorch/include/torch/csrc/api/include/torch/types.h:7,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/all.h:4,
from /content/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
from /content/mlcpp/mask_rcnn_pytorch/classifier.h:6,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:4,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:
/content/libtorch/include/ATen/core/interned_strings.h:364:1: note: ‘c10::attr::steps’
FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
^
/content/libtorch/include/ATen/core/interned_strings.h:364:1: note: ‘c10::attr::steps’
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: At global scope:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:229:5: error: ‘torch::data::DataLoader’ has not been declared
torch::data::DataLoader<CocoDataset, torch::data::samplers::RandomSampler>&
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:229:28: error: expected ‘,’ or ‘...’ before ‘<’ token
torch::data::DataLoader<CocoDataset, torch::data::samplers::RandomSampler>&
^
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: In member function ‘std::tuple<float, float, float, float, float, float> MaskRCNNImpl::TrainEpoch(StatReporter&, int)’:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:243:3: error: ‘optimizer’ was not declared in this scope
optimizer.zero_grad();
^~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:244:3: error: ‘optimizer_bn’ was not declared in this scope
optimizer_bn.zero_grad();
^~~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:244:3: note: suggested alternative: ‘timer_t’
optimizer_bn.zero_grad();
^~~~~~~~~~~~
timer_t
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:246:21: error: ‘datagenerator’ was not declared in this scope
for (auto input : datagenerator) {
^~~~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:246:21: note: suggested alternative: ‘CvLineIterator’
for (auto input : datagenerator) {
^~~~~~~~~~~~~
CvLineIterator
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:296:34: error: expected primary-expression before ‘float’
auto loss_ = loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:297:53: error: expected primary-expression before ‘float’
auto loss_rpn_class = rpn_class_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:298:51: error: expected primary-expression before ‘float’
auto loss_rpn_bbox = rpn_bbox_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:299:57: error: expected primary-expression before ‘float’
auto loss_mrcnn_class = mrcnn_class_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:300:55: error: expected primary-expression before ‘float’
auto loss_mrcnn_bbox = mrcnn_bbox_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:301:55: error: expected primary-expression before ‘float’
auto loss_mrcnn_mask = mrcnn_mask_loss.cpu().data<float>()[0];
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:304:49: error: no matching function for call to ‘StatReporter::ReportTrainStep(uint32_t&, <brace-enclosed initializer list>)’
loss_mrcnn_bbox, loss_mrcnn_mask});
^
In file included from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:11:0,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:39:8: note: candidate: void StatReporter::ReportTrainStep(uint32_t, const LossStat&)
void ReportTrainStep(uint32_t i, const LossStat& stat);
^~~~~~~~~~~~~~~
/content/mlcpp/mask_rcnn_pytorch/statreporter.h:39:8: note: no known conversion for argument 2 from ‘<brace-enclosed initializer list>’ to ‘const LossStat&’
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:307:25: error: ‘steps’ was not declared in this scope
loss_sum += loss_ / steps;
^~~~~
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:307:25: note: suggested alternatives:
In file included from /content/libtorch/include/ATen/core/ivalue_inl.h:7:0,
from /content/libtorch/include/ATen/core/ivalue.h:601,
from /content/libtorch/include/ATen/core/stack.h:3,
from /content/libtorch/include/torch/csrc/jit/tracer.h:3,
from /content/libtorch/include/torch/csrc/autograd/generated/variable_factories.h:9,
from /content/libtorch/include/torch/csrc/api/include/torch/types.h:7,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/data.h:3,
from /content/libtorch/include/torch/csrc/api/include/torch/all.h:4,
from /content/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
from /content/mlcpp/mask_rcnn_pytorch/classifier.h:6,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.h:4,
from /content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:1:
/content/libtorch/include/ATen/core/interned_strings.h:364:1: note: ‘c10::attr::steps’
FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
^
/content/libtorch/include/ATen/core/interned_strings.h:364:1: note: ‘c10::attr::steps’
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp: In member function ‘std::tuple<at::Tensor, at::Tensor> MaskRCNNImpl::PredictInference(at::Tensor, const std::vector<ImageMeta>&)’:
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:475:65: warning: unused variable ‘rpn_class_logits’ [-Wunused-variable]
auto [mrcnn_feature_maps, rpn_rois, rpn_class_logits, rpn_bbox] =
^
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:475:65: warning: unused variable ‘rpn_bbox’ [-Wunused-variable]
/content/mlcpp/mask_rcnn_pytorch/maskrcnn.cpp:480:52: warning: unused variable ‘mrcnn_class_logits’ [-Wunused-variable]
auto [mrcnn_class_logits, mrcnn_class, mrcnn_bbox] =
^
CMakeFiles/mask-rcnn_lib.dir/build.make:105: recipe for target 'CMakeFiles/mask-rcnn_lib.dir/maskrcnn.cpp.o' failed
make[2]: *** [CMakeFiles/mask-rcnn_lib.dir/maskrcnn.cpp.o] Error 1
make[2]: Leaving directory '/content/mlcpp/mask_rcnn_pytorch/build'
CMakeFiles/Makefile2:186: recipe for target 'CMakeFiles/mask-rcnn_lib.dir/all' failed
make[1]: *** [CMakeFiles/mask-rcnn_lib.dir/all] Error 2
make[1]: Leaving directory '/content/mlcpp/mask_rcnn_pytorch/build'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2
The complete code is avaiable at colab: mlcpp.ipynb. Can you help me with that?
Hello, thank you for creating this project.
I see that demo.cpp has been designed for single-image inference, however can it be modified for inference of multi-images, let's say that images in a particular folder? I'd like to see if there is an improvement or any changes in FPS rate to compare with Detectron and matterport's Mask R-CNN.
Thank you.
mlcpp/mask_rcnn_pytorch/anchors.cpp
Line 63 in afb08c0
this function should change to below , because should iterator on feature map not the anchor scale size;
torch::Tensor GeneratePyramidAnchors(
std::vector<float> scales_vec,
std::vector<float> ratios_vec,
const std::vector<std::pair<float, float> >& feature_shapes,
const std::vector<float>& feature_strides,
float anchor_stride) {
std::vector<at::Tensor> anchors;
auto ratios = torch::tensor(ratios_vec);
auto scales = torch::tensor(scales_vec);
for (size_t i = 0; i < feature_strides.size(); ++i) {
anchors.push_back(GenerateAnchors(scales, ratios, feature_shapes[i],
feature_strides[i], anchor_stride));
}
return torch::cat(anchors, /*dim*/ 0);
While using cmake
PyTorch C++ Frontend Compilation for mask rcnn, I encountered the following error,
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at /nfs/interns/kharshit/libtorch/share/cmake/Caffe2/public/utils.cmake:17 (add_dependencies):
add_dependencies Cannot add target-level dependencies to INTERFACE library
target "torch_library".
Call Stack (most recent call first):
/nfs/interns/kharshit/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:121 (caffe2_interface_library)
/nfs/interns/kharshit/libtorch/share/cmake/Torch/TorchConfig.cmake:40 (find_package)
CMakeLists.txt:4 (find_package)
-- Found torch: /nfs/interns/kharshit/libtorch/lib/libtorch.so
-- Found CUDA: /usr/local/cuda (found version "8.0")
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GOMP_LIBRARY
linked by target "mask-rcnn_demo" in directory /nfs/interns/kharshit/mlcpp/mask_rcnn_pytorch
linked by target "mask-rcnn_train" in directory /nfs/interns/kharshit/mlcpp/mask_rcnn_pytorch
-- Configuring incomplete, errors occurred!
See also "/nfs/interns/kharshit/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/CMakeOutput.log".
See also "/nfs/interns/kharshit/mlcpp/mask_rcnn_pytorch/build/CMakeFiles/CMakeError.log".
The error seems to be related to Eigen
library, though I've already updated the submodules using git submodule update
.
The procedure I followed to build is:
mkdir build
cd build
cmake -D CMAKE_PREFIX_PATH=~/libtorch/ ..
Hey Kolkir, I'm trying to reproduce your demo of Mask RCNN. After i downloaded the latest Pytorch from GitHub, and built its library from source. I found the mask rcnn demo can be compiled and built successfully, but can not run. It seems that the latest Pytorch is now incompatible with your mask rcnn implementation. Could you provide me the exact Pytorch commit number when you build it from source? So I can use the exact same Pytorch with you.
Hi, Thanks for your code. I got a problem on the utils.cpp when i build the "Machine Learning with C++ - Polynomial regression with Eigen" in vscode + cmake. It reports "cannt open source file curl/curl.h ". I guess the curl-lib maybe one of your personal lib, or is that a open-source lib:https://github.com/curl/curl?
Regarding to my previous issue #19 , I find it is a bug in libtorch 1.0.1 and the bug disappears when using libtorch 1.2.0 in my little demo.
Do you have any plan to migrate the code to libtorch 1.2.0? Currently the code can't compile using libtorch-1.2.0 due to the API changes.
I'll work on this anyway, and I'm willing to submit a PR in the future. Just wonder do you have any work in progress so we can prevent some redundant work.
Hi.
Thank you so much for the C++ frontend example.
I'm in process of converting the python module to C++ for performance improvements.
Any clue how can i write the below code in C++.
`
class CBN(nn.Module):
def __init__(self, num_features):
super(CBN, self).__init__()
self.bn = BatchNorm2d(num_features)
def forward(self, x):
bn = self.bn(x)
return bn
def __call__(self, x):
return self.forward(x)`
`class BCN(nn.Module):
def __init__(self):
super(BCN, self).__init__()
self.layer = nn.Sequential()
self.layer.add_module('bn',CBN(in_channels))
self.layer.add_module('conv',nn.Conv2d(1,1,1, stride=1,
padding=1, bias=True))
self.layer.add_module('ReLU', nn.ReLU(inplace=True))
def forward(self, x):
return self.layer(x.contiguous())
def __call__(self, x):
return self.forward(x)`
@Kolkir
Any help would be great.
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.