Giter Club home page Giter Club logo

detectorch's Introduction

Detectorch - detectron for PyTorch

(Disclaimer: this is work in progress and does not feature all the functionalities of detectron. Currently only inference and evaluation are supported -- no training) (News: Now supporting FPN and ResNet-101!)

This code allows to use some of the Detectron models for object detection from Facebook AI Research with PyTorch.

It currently supports:

  • Fast R-CNN
  • Faster R-CNN
  • Mask R-CNN

It supports ResNet-50/101 models with or without FPN. The pre-trained models from caffe2 can be imported and used on PyTorch.

Example Mask R-CNN with ResNet-101 and FPN.

Evaluation

Both bounding box evaluation and instance segmentation evaluation where tested, yielding the same results as in the Detectron caffe2 models. These results below have been computed using the PyTorch code:

Model box AP mask AP model id
fast_rcnn_R-50-C4_2x 35.6 36224046
fast_rcnn_R-50-FPN_2x 36.8 36225249
e2e_faster_rcnn_R-50-C4_2x 36.5 35857281
e2e_faster_rcnn_R-50-FPN_2x 37.9 35857389
e2e_mask_rcnn_R-50-C4_2x 37.8 32.8 35858828
e2e_mask_rcnn_R-50-FPN_2x 38.6 34.5 35859007
e2e_mask_rcnn_R-101-FPN_2x 40.9 36.4 35861858

Training

Training code is experimental. See train_fast.py for training Fast R-CNN. It seems to work, but slow.

Installation

First, clone the repo with git clone --recursive https://github.com/ignacio-rocco/detectorch so that you also clone the Coco API.

The code can be used with PyTorch 0.3.1 or PyTorch 0.4 (master) under Python 3. Anaconda is recommended. Other required packages

  • torchvision (conda install torchvision -c soumith)
  • opencv (conda install -c conda-forge opencv )
  • cython (conda install cython)
  • matplotlib (conda install matplotlib)
  • scikit-image (conda install scikit-image)
  • ninja (conda install ninja) (required for Pytorch 0.4 only)

Additionally, you need to build the Coco API and RoIAlign layer. See below.

Compiling the Coco API

If you cloned this repo with git clone --recursive you should have also cloned the cocoapi in lib/cocoapi. Compile this with:

cd lib/cocoapi/PythonAPI
make install

Compiling RoIAlign

The RoIAlign layer was converted from the caffe2 version. There are two different implementations for each PyTorch version:

  • Pytorch 0.4: RoIAlign using ATen library (lib/cppcuda). Compiled JIT when loaded.
  • PyTorch 0.3.1: RoIAlign using TH/THC and cffi (lib/cppcuda_cffi). Needs to be compiled with:
cd lib/cppcuda_cffi
./make.sh 

Quick Start

Check the demo notebook.

detectorch's People

Contributors

ignacio-rocco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detectorch's Issues

Key-point detection

Hi,
I run this project and it results are great. Now I also want extract the keypoints of people, but cannot find it anywhere in the code. Is the keypoints detection already available in this project or I need to trained it by myself? did Anyone already try this please give me some suggestions.

Thank you!
Uyen

Get right result of bbox using eval_mask_FPN code but wrong result of segmentation?

Thanks for sharing your greate work.
I have tested your mask_rcnn_FPN code, and got the right result of bbox detecting, but wrong result of seg.
I have pasted the result of eval_mask_FPN AP as follows:

  1. bbox
    image
  2. seg

image

And the demo_mask_FPN also shows a wrong result as follows:

image

  1. Furthermore, I test the mask_rcnn_c4_2x-resnet50 model, and the result is same as yours.
    image

So is there something wrong with mask_rcnn_FPN ?

ModuleNotFoundError: No module named 'utils.preprocess_sample'

When I try to sub classes of the utils.preprocess_samples it says the following error has occured
ModuleNotFoundError: No module named 'utils.preprocess_sample'
BTW i can able to import utils module but not the sub modules inside it.
Can anyone help?

ninja: build stopped: subcommand failed.

I'm using pytorch 0.4.1, when i ran demo.py,

compiling/loading roi_align
/home/feiw/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py:118: UserWarning: 

                               !! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Your compiler (c++) may be ABI-incompatible with PyTorch!
Please use a compiler that is ABI-compatible with GCC 4.9 and above.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.

See https://gist.github.com/goldsborough/d466f43e8ffc948ff92de7486c5216d6
for instructions on how to install GCC 4.9 or higher.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                              !! WARNING !!

  warnings.warn(ABI_INCOMPATIBILITY_WARNING.format(compiler))
Detected CUDA files, patching ldflags
Emitting ninja build file /home/feiw/Detectron/detectorch/lib/cppcuda/build/build.ninja...
Building extension module roialign...
Traceback (most recent call last):
  File "/home/feiw/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 759, in _build_extension_module
    ['ninja', '-v'], stderr=subprocess.STDOUT, cwd=build_directory)
  File "/home/feiw/anaconda3/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/home/feiw/anaconda3/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "demo.py", line 25, in <module>
    from model.detector import detector
  File "lib/model/detector.py", line 5, in <module>
    from model.roi_align import RoIAlignFunction, preprocess_rois
  File "lib/model/roi_align.py", line 18, in <module>
    build_directory=build_path,verbose=True)
  File "/home/feiw/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 514, in load
    with_cuda=with_cuda)
  File "/home/feiw/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 682, in _jit_compile
    _build_extension_module(name, build_directory)
  File "/home/feiw/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 765, in _build_extension_module
    name, error.output.decode()))
RuntimeError: Error building extension 'roialign': [1/4] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 --compiler-options '-fPIC' -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu -o roi_align_forward_cuda.cuda.o
FAILED: roi_align_forward_cuda.cuda.o 
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 --compiler-options '-fPIC' -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu -o roi_align_forward_cuda.cuda.o
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:173:82: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(input.ndimension() == 4, "Input to RoI Align should be a NCHW Tensor");
                                                                                  ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:178:105: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.ndimension() == 2, "RoI Proposals should be a 2D Tensor, (batch_sz x proposals)");
                                                                                                         ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:179:109: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.size(1) == 5, "Proposals should be of the form [batch_index startW startH endW enH]");
                                                                                                             ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:189:62: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(input.is_contiguous(), "input must be contiguous");
                                                              ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:190:74: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.is_contiguous(), "bottom_rois must be contiguous");
                                                                          ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_forward_cuda.cu:209:81: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(cudaGetLastError() == cudaSuccess, "roi_align_forward_kernel failed");
                                                                                 ^
[2/4] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 --compiler-options '-fPIC' -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu -o roi_align_backward_cuda.cuda.o
FAILED: roi_align_backward_cuda.cuda.o 
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 --compiler-options '-fPIC' -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu -o roi_align_backward_cuda.cuda.o
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu:225:105: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.ndimension() == 2, "RoI Proposals should be a 2D Tensor, (batch_sz x proposals)");
                                                                                                         ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu:226:109: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.size(1) == 5, "Proposals should be of the form [batch_index startW startH endW enH]");
                                                                                                             ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu:231:87: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(roi_cols == 4 || roi_cols == 5, "RoI Proposals should have 4 or 5 columns");
                                                                                       ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu:236:74: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.is_contiguous(), "bottom_rois must be contiguous");
                                                                          ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cuda.cu:256:81: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(cudaGetLastError() == cudaSuccess, "roi_align_forward_kernel failed");
                                                                                 ^
[3/4] c++ -MMD -MF roi_align_binding.o.d -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp -o roi_align_binding.o
FAILED: roi_align_binding.o 
c++ -MMD -MF roi_align_binding.o.d -DTORCH_EXTENSION_NAME=roialign -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/home/feiw/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/feiw/anaconda3/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp -o roi_align_binding.o
In file included from /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp:2:0:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:237:84: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(input.ndimension() == 4, "Input to RoI Pooling should be a NCHW Tensor");
                                                                                    ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:242:105: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.ndimension() == 2, "RoI Proposals should be a 2D Tensor, (batch_sz x proposals)");
                                                                                                         ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:243:109: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.size(1) == 5, "Proposals should be of the form [batch_index startW startH endW enH]");
                                                                                                             ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:251:87: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(roi_cols == 4 || roi_cols == 5, "RoI Proposals should have 4 or 5 columns");
                                                                                       ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:257:62: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(input.is_contiguous(), "input must be contiguous");
                                                              ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:258:74: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.is_contiguous(), "bottom_rois must be contiguous");
                                                                          ^
In file included from /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp:3:0:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp:205:105: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.ndimension() == 2, "RoI Proposals should be a 2D Tensor, (batch_sz x proposals)");
                                                                                                         ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp:206:109: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.size(1) == 5, "Proposals should be of the form [batch_index startW startH endW enH]");
                                                                                                             ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp:211:87: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(roi_cols == 4 || roi_cols == 5, "RoI Proposals should have 4 or 5 columns");
                                                                                       ^
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp:216:74: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1
   AT_ASSERT(bottom_rois.is_contiguous(), "bottom_rois must be contiguous");
                                                                          ^
In file included from /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp:2:0:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp: In function ‘at::Tensor at::contrib::roi_align_forward_cpu(const at::Tensor&, const at::Tensor&, int64_t, int64_t, double, int64_t)’:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_cpu.cpp:237:3: error: ‘AT_ASSERT’ was not declared in this scope
   AT_ASSERT(input.ndimension() == 4, "Input to RoI Pooling should be a NCHW Tensor");
   ^
In file included from /home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_binding.cpp:3:0:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp: In function ‘at::Tensor at::contrib::roi_align_backward_cpu(const at::Tensor&, const at::Tensor&, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, double, int64_t)’:
/home/feiw/Detectron/detectorch/lib/cppcuda/roi_align_backward_cpu.cpp:205:3: error: ‘AT_ASSERT’ was not declared in this scope
   AT_ASSERT(bottom_rois.ndimension() == 2, "RoI Proposals should be a 2D Tensor, (batch_sz x proposals)");
   ^
ninja: build stopped: subcommand failed.

Windows support?

I was hoping to get this to run on Windows10 with GPU support (enabled by this repo.

I've modified bind.py a bit and am still getting this error :
C:...\Dev\detectorch\lib\cppcuda_cffi\src\cpp\roi_align_cpu_loop.o : fatal error LNK1107: invalid or corrupt file: cannot read at 0x3A8

Any clue what to look out for? Are you planning for Windows support?

Issue with installing COCO API

Hey,
I managed to clone the required repositories and all install the requirements but when I finally ran:

cd/lib/cocoapi/PythonAPI
make install

I ran into this error:

Traceback (most recent call last):
File "setup.py", line 13, in
include_dirs = [np.get_include(), '../common'],
AttributeError: module 'numpy' has no attribute 'get_include'

Would you have any suggestions to deal with this?

Error when JIT compilation

I got the following error:

[1/4] c++ -MMD -MF roi_align_binding.o.d -DTORCH_EXTENSION_NAME=roialign -I/opt/pytorch/torch/lib/include -I/opt/pytorch/torch/lib/include/TH -I/opt/pytorch/torch/lib/include/THC -I/share/data/vision-greg/rluo/local/cuda-8.0/include -I/opt/conda/include/python3.6m -fPIC -std=c++11 -c /share/data/vision-greg/rluo/detectorch/lib/cppcuda/roi_align_binding.cpp -o roi_align_binding.o
FAILED: roi_align_binding.o
c++ -MMD -MF roi_align_binding.o.d -DTORCH_EXTENSION_NAME=roialign -I/opt/pytorch/torch/lib/include -I/opt/pytorch/torch/lib/include/TH -I/opt/pytorch/torch/lib/include/THC -I/share/data/vision-greg/rluo/local/cuda-8.0/include -I/opt/conda/include/python3.6m -fPIC -std=c++11 -c /share/data/vision-greg/rluo/detectorch/lib/cppcuda/roi_align_binding.cpp -o roi_align_binding.o
/share/data/vision-greg/rluo/detectorch/lib/cppcuda/roi_align_binding.cpp:1:25: fatal error: torch/torch.h: No such file or directory
compilation terminated.

It seems that it can't find <torch.torch.h> which is supposed to be under /opt/pytorch. But it's not included in the -I options.

Do you have any idea how to solve this.

the error of Create detector model


KeyError Traceback (most recent call last)
in
2 detector_pkl_file=pretrained_model_file,
3 use_rpn_head = use_rpn_head,
----> 4 use_mask_head = use_mask_head)
5 model = model.cuda()

/mnt/wifiperson-master/dataprocessing/detectorch/lib/model/detector.py in init(self, train, arch, conv_body_layers, conv_head_layers, fpn_layers, fpn_extra_lvl, use_rpn_head, use_mask_head, mask_head_type, roi_feature_channels, N_classes, detector_pkl_file, base_cnn_pkl_file, output_prob, roi_height, roi_width, roi_spatial_scale, roi_sampling_ratio)
224 # load pretrained weights
225 if detector_pkl_file is not None:
--> 226 self.load_pretrained_weights(detector_pkl_file, model='detector')
227 elif base_cnn_pkl_file is not None:
228 self.load_pretrained_weights(base_cnn_pkl_file, model='base_cnn')

/mnt/wifiperson-master/dataprocessing/detectorch/lib/model/detector.py in load_pretrained_weights(self, caffe_pkl_file, model)
306 model_dict[k]=torch.FloatTensor(caffe_data[k_caffe][:,(2, 1, 0),:,:])
307 else:
--> 308 model_dict[k]=torch.FloatTensor(caffe_data[k_caffe])
309 # update model
310 self.model.load_state_dict(model_dict)

KeyError: 'res_conv1'

Any plan to update the training file to make it runnable?

I like this project in the way that it could let me learn pytorch from real implementation. However, The train_fast.py file seems really experimental when I ran it. From the beginning of import mismatches in utils.utils and loss.py files, to the detector initialization (mapping_file, return_rois, return_img_features those parameters are not in the original model definition). I assumed the focus of the project is on evaluations so training is not a priority. But is there any plan in future to update the training file?

How to build ROIAlign for pytorch 0.4

Do we have to do the same operations for both pytorch 0.3.1 and pytorch 0.4 to build ROIAlign? The demo file keeps restarting every time I pass a sample image to the model and this is the only thing I am doubtful about.
Thanks

How to run the project?

Hello.

Thank you so much for your work. Really appreciate it. Best mask-RCNN implementation.

I have completed Compiling the Coco API and RoIAlign.

I checked the demo notebook. But I was not able to understand how to run this project.
Could you please tell me which file I need to run to get the results pdf output.

Thanks!

mask head usage?

Hi!

Firstly, thank u a lot. It looks like the best mask-rcnn implementation. (cause it does not use this magic from config import cfg)

Nevertheless, something is a bit strange for me. In the model init you define self.mask_head (cause it needed for segmentation task), but in the forward pass you dont use it at all. How is that?

Thanks!

Error when loading pretrained weights

Dear @ignacio-rocco,
Thank you for your fantastic work. When I want to run your demo_FPN code, I get this error:

Loading pretrained weights:
Traceback (most recent call last):
  File "SampleRun1.py", line 102, in <module>
    mask_head_type='1up4convs')
  File ".../detectorch/lib/model/detector.py", line 226, in __init__
    self.load_pretrained_weights(detector_pkl_file, model='detector')
  File ".../detectorch/lib/model/detector.py", line 294, in load_pretrained_weights
    caffe_data = pickle.load(f, encoding='latin1')
ValueError: could not convert string to int

Would you please kindly help me to address this error?

error when running demo.ipynb, [Errno 2] No such file or directory: '/home/nguyen/detectorch/lib/cppcuda/build/lock'

Thank you for sharing your great work.
However, when i tried to run the demo.ipynb, I received the the following error because of this line of code in the first block [1]:
from model.detector import detector

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-1-87b548d7a38f> in <module>()
     12 from utils.utils import to_cuda_variable
     13 from utils.json_dataset_evaluator import evaluate_boxes,evaluate_masks
---> 14 from model.detector import detector
     15 import utils.result_utils as result_utils
     16 import utils.vis as vis_utils

/data/share/nguyen/detectorch/lib/model/detector.py in <module>()
      3 import numpy as np
      4 import torchvision.models as models
----> 5 from model.roi_align import RoIAlignFunction, preprocess_rois
      6 from model.generate_proposals import GenerateProposals
      7 from model.collect_and_distribute_fpn_rpn_proposals import CollectAndDistributeFpnRpnProposals

/data/share/nguyen/detectorch/lib/model/roi_align.py in <module>()
     16                                             'lib/cppcuda/roi_align_forward_cuda.cu',
     17                                             'lib/cppcuda/roi_align_backward_cuda.cu'],
---> 18                     build_directory=build_path,verbose=True)
     19 else:
     20     import cppcuda_cffi.roialign as roialign

~/.pyenv/versions/anaconda3-5.0.1/envs/pytorch/lib/python3.6/site-packages/torch/utils/cpp_extension.py in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose)
    474     baton = FileBaton(os.path.join(build_directory, 'lock'))
    475 
--> 476     if baton.try_acquire():
    477         try:
    478             with_cuda = any(map(_is_cuda_file, sources))

~/.pyenv/versions/anaconda3-5.0.1/envs/pytorch/lib/python3.6/site-packages/torch/utils/file_baton.py in try_acquire(self)
     27         '''
     28         try:
---> 29             self.fd = os.open(self.lock_file_path, os.O_CREAT | os.O_EXCL)
     30             return True
     31         except FileExistsError:

FileNotFoundError: [Errno 2] No such file or directory: '/data/share/nguyen/detectorch/lib/cppcuda/build/lock'

seem that the the folder cppcuda/build/lock was not generated. How should I fix this problem? I use:
python = 3.6. pytorch = 0.4.0
Thank you!

No such file or directory: 'detectorch/lib/cppcuda/build/build.ninja'

Hi,

firstly, thank you for your work. I have tried your code, but I cannot get it working. It looks like that the file build.ninja cannot be created. Don't you have please any idea why it is happening?

Using PyTorch 0.4, Ubuntu 16.4, Anaconda with all requirements installed.

Output of first cell from demo.ipynb
`
compiling/loading roi_align
Detected CUDA files, patching ldflags
Emitting ninja build file /home/lukas/dev/detectorch/lib/cppcuda/build/build.ninja...

FileNotFoundError Traceback (most recent call last)
in ()
12 from utils.utils import to_cuda_variable
13 from utils.json_dataset_evaluator import evaluate_boxes,evaluate_masks
---> 14 from model.detector import detector
15 import utils.result_utils as result_utils
16 import utils.vis as vis_utils

~/dev/detectorch/lib/model/detector.py in ()
3 import numpy as np
4 import torchvision.models as models
----> 5 from model.roi_align import RoIAlignFunction, preprocess_rois
6 from model.generate_proposals import GenerateProposals
7 from model.collect_and_distribute_fpn_rpn_proposals import CollectAndDistributeFpnRpnProposals

~/dev/detectorch/lib/model/roi_align.py in ()
16 'lib/cppcuda/roi_align_forward_cuda.cu',
17 'lib/cppcuda/roi_align_backward_cuda.cu'],
---> 18 build_directory=build_path,verbose=True)
19 else:
20 import cppcuda_cffi.roialign as roialign

~/anaconda3/envs/darknetTracking/lib/python3.6/site-packages/torch/utils/cpp_extension.py in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose)
493 extra_ldflags=extra_ldflags or [],
494 extra_include_paths=extra_include_paths or [],
--> 495 with_cuda=with_cuda)
496
497 if verbose:

~/anaconda3/envs/darknetTracking/lib/python3.6/site-packages/torch/utils/cpp_extension.py in _write_ninja_file(path, name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, with_cuda)
671 blocks.append(cuda_compile_rule)
672 blocks += [link_rule, build, link, default]
--> 673 with open(path, 'w') as build_file:
674 for block in blocks:
675 lines = '\n'.join(block)

FileNotFoundError: [Errno 2] No such file or directory: '/home/lukas/dev/detectorch/lib/cppcuda/build/build.ninja'`

Problem with build_cython.py

Hello,

First of all thank you for share this amazing code and repo.

I am having troubles with build_cython.py, when I compile I got the following error:

Traceback (most recent call last):
File "build_cython.py", line 20, in
from Cython.Build import cythonize
ImportError: No module named Cython.Build
Traceback (most recent call last):
File "/home/alupotto/PycharmProjects/c_mon/utils/boxes.py", line 54, in
import utils_cython.cython_bbox as cython_bbox
ImportError: No module named 'utils_cython.cython_bbox'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/alupotto/PycharmProjects/c_mon/cmon.py", line 10, in
from utils.preprocess_sample import preprocess_sample
File "/home/alupotto/PycharmProjects/c_mon/utils/preprocess_sample.py", line 5, in
from utils.multilevel_rois import add_multilevel_rois_for_test
File "/home/alupotto/PycharmProjects/c_mon/utils/multilevel_rois.py", line 16, in
import utils.boxes as box_utils
File "/home/alupotto/PycharmProjects/c_mon/utils/boxes.py", line 66, in
raise('--> utils_cython modules compilation failed')
TypeError: exceptions must derive from BaseException

I tried to dis comment other libraries of build_cython.py and it can't detect the others as well. It would be awesome if anybody can help me out.

Thank you,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.