GithubHelp home page GithubHelp logo

xiaolonw / adversarial-frcnn Goto Github PK

View Code? Open in Web Editor NEW
481.0 33.0 168.0 606 KB

A-Fast-RCNN (CVPR 2017)

License: Other

C 3.61% Shell 2.55% Makefile 0.02% MATLAB 0.66% Python 91.26% C++ 0.05% Cuda 1.85%
adversarial-networks fast-rcnn object-detection caffe

adversarial-frcnn's Introduction

A-Fast-RCNN: Hard Positive Generation via Adversary for Object Detection

By Xiaolong Wang, Abhinav Shrivastava, and Abhinav Gupta

Introduction

This is a Caffe based version of A-Fast-RCNN (arxiv_link). Although we originally implement it on torch, this Caffe re-implementation is much simpler, faster and easier to use.

We release the code for training A-Fast-RCNN with Adversarial Spatial Dropout Network.

License

This code is released under the MIT License (refer to the LICENSE file for details).

Citing

If you find this useful in your research, please consider citing:

@inproceedings{WangCVPR17afrcnn,
    Author = {Xiaolong Wang and Abhinav Shrivastava and Abhinav Gupta},
    Title = {A-Fast-RCNN: Hard Positive Generation via Adversary for Object Detection},
    Booktitle = {Conference on Computer Vision and Pattern Recognition ({CVPR})},
    Year = {2017}
}

Disclaimer

This implementation is built on a fork of the OHEM code (here), which in turn builds on the Faster R-CNN Python code (here) and Fast R-CNN (here). Please cite the appropriate papers depending on which part of the code and/or model you are using.

Results

| Approach                       | training data           | test data         | mAP
| Fast R-CNN  (FRCN)             | VOC 07 trainval         | VOC 07 test       | 67.6
| FRCN with adversary            | VOC 07 trainval         | VOC 07 test       | 70.8

Note: The reported results are based on the VGG16 network.

Installation

Please follow the exact installation and download the VOC data as the Faster R-CNN Python code (here).

Usage

To run the code, one can simply do,

./train.sh

It includes 3-stage of training:

./experiments/scripts/fast_rcnn_std.sh  [GPU_ID]  VGG16 pascal_voc

which is used for training a standard Fast-RCNN for 10K iterations, you can download my model and logs for this step.

./experiments/scripts/fast_rcnn_adv_pretrain.sh  [GPU_ID]  VGG16 pascal_voc

which is a pre-training stage for the adversarial network, you can download my model and logs for this step.

./copy_model.h

which is used to copy the weights of the above two models to initialize the joint model.

./experiments/scripts/fast_rcnn_adv.sh  [GPU_ID]  VGG16 pascal_voc

which is joint training of the detector and the adversarial network, you can download my model and logs for this step.

adversarial-frcnn's People

Contributors

xiaolonw 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  avatar  avatar  avatar  avatar  avatar

adversarial-frcnn's Issues

AssertionError: Selective search data not found

Hello, bro. Xiaolong:
I run the code for basic training of fast rcnn. However, it shown the error like this:
AssertionError: Selective search data not found at:
/home/wangxiao/Downloads/adversarial-frcnn-master/data/selective_search_data/voc_2007_trainval.mat

So, where to download this file ?

AttributeError: 'module' object has no attribute 'ASDNPretrainLabelLayer'

when i was implement ASDN on faster rcnn,there comes errors
Normalizing targets
done
RoiDataLayer: name_to_top: {'gt_boxes': 2, 'data': 0, 'im_info': 1}
AttributeError: 'module' object has no attribute 'ASDNPretrainLabelLayer'
Traceback (most recent call last):
File "tools/train_net.py", line 112, in
max_iters=args.max_iters)
File "/home/keysen/lingck/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 157, in train_net
pretrained_model=pretrained_model)
File "/home/keysen/lingck/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 43, in init
self.solver = caffe.SGDSolver(solver_prototxt)
SystemError: NULL result without error in PyObject_Call
Can you help me?
my e-mail is [email protected]

Where is ASTN?

It's an amazing work, I have read your paper and it impresses me a lot.
But when I read your adversarial-frcnn/models/pascal_voc/VGG16/fast_rcnn_adv/train.prototxt , I can only find ASDN, and where is ASTN mentioned in your paper?

about training

@xiaolonw
@abhi2610

When I perform the training, encount the following error

Traceback (most recent call last):
  File "./tools/train_net.py", line 114, in <module>
    max_iters=args.max_iters)
  File "/home/jmx/adversarial-frcnn/tools/../lib/fast_rcnn/train.py", line 161, in train_net
    model_paths = sw.train_model(max_iters)
  File "/home/jmx/adversarial-frcnn/tools/../lib/fast_rcnn/train.py", line 102, in train_model
    self.solver.step(1)
  File "/home/jmx/adversarial-frcnn/tools/../lib/roi_data_layer/layer.py", line 383, in forward
    if min_prop > prop[j * N + i][nowlbl]: 
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

The same error also occurred in OHEM
How do I modify it

many many thanks!!!

about training

@xiaolonw
When I perform the training, encount the following error

Traceback (most recent call last):
  File "./tools/train_net.py", line 114, in <module>
    max_iters=args.max_iters)
  File "/home/jmx/adversarial-frcnn/tools/../lib/fast_rcnn/train.py", line 161, in train_net
    model_paths = sw.train_model(max_iters)
  File "/home/jmx/adversarial-frcnn/tools/../lib/fast_rcnn/train.py", line 102, in train_model
    self.solver.step(1)
  File "/home/jmx/adversarial-frcnn/tools/../lib/roi_data_layer/layer.py", line 383, in forward
    if min_prop > prop[j * N + i][nowlbl]: 
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

The same error also occurred in OHEM
How do I modify it

many many thanks!!!

received signal SIGFPE, Arithmetic exception

I benefited from your article.
I ran into this problem while running my own data. I found the problem mainly comes from:
ASDNPretrainLabelLayer->forward()
top[0].reshape(*(conv_feat_pos.shape))
top[0].data[...] = conv_feat_pos.astype(np.float32, copy=False)
Since all the labels in rois are background (label = 0), the size of top0 is 0 when reshape top is reached.

So, how should I deal with this problem?

Thanks!

apply on faster rcnn

Hi, Xiaolong, your code interest me much. Could the idea apply on the faster rcnn code? since rpn is better to apply than selective search.

How to get the model and log?

I benefited from your article.
So I have tried a lot of ways to get the model and log. But it does not work.
Could tell me how to get the model and log in Chain?
Thanks!

TypeError: 'numpy.float64' object cannot be interpreted as an index

As i run the train.sh
i met this issue:

File "/home/cui/adversarial-frcnn/tools/../lib/roi_data_layer/minibatch.py", line 343, in _sample_rois
fg_inds, size=fg_rois_per_this_image, replace=False)
File "mtrand.pyx", line 1187, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:18864)
TypeError: 'numpy.float64' object cannot be interpreted as an index

And when i follow some answers to set the numpy to 1.11.0 it solved but appearance another issue.
image

And some answers tell me to upgrade the numpy .
SO, what should i do ?
Thanks very much !!!

Code on pytorch

Hello, I'm interested in your work very much, and really want to see the effect of ASTN network, so will you publish the whole code which contains ASTN & ASDN in pytorch? Thanks a lot~

loss_asdn=0

when i was implement ASDN on faster rcnn,in the third stage,training faster_rcnn_adv,the loss of asdn was 0,could you tell me what should i change except the prototxt file?

About the whole code

Dear author:
I'm really interested in your work. Have you finished your whole code? Could you please share? Thank you very much.

copy_model.h

when i implement asdn on faster-rcnn,when i run ./copy_model.h,there comes this error:
I0529 16:29:34.017501 8882 layer_factory.hpp:77] Creating layer data
I0529 16:29:34.022382 8882 net.cpp:106] Creating Layer data
I0529 16:29:34.022393 8882 net.cpp:411] data -> data
I0529 16:29:34.022400 8882 net.cpp:411] data -> im_info
I0529 16:29:34.022405 8882 net.cpp:411] data -> gt_boxes
Traceback (most recent call last):
File "python_utils/do_net_surgery.py", line 29, in
net = caffe.Net(args.out_net_def, caffe.TEST)
File "/home/keysen/lingck/py-faster-rcnn/python_utils/../lib/roi_data_layer/layer.py", line 134, in setup
top[idx].reshape(1, self._num_classes * 4)
IndexError: Index out of range

what should i do?

How to train this net using my own dataset?

I want to train this net using my own dataset.

I have successfully set the data, however, the number of class need to be modified and some model layers cannot be restored accordingly.

For example, when I run the code, it raised the following error:

Cannot copy param 0 weights from layer 'cls_score_readonly'; shape mismatch. Source param shape is 21 4096 (86016); target param shape is 146 4096 (598016). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

Cannot copy param 0 weights from layer 'cls_score'; shape mismatch. Source param shape is 21 4096 (86016); target param shape is 146 4096 (598016). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

So could anybody give me some advice on how to fix it?
Thank you!

pytorch code

hi would you be able to release your code in pytorch instead of caffe please?

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.