Fast-rcnn training (2) - run demo

1. Prepare the pretrained model

Before running the author's demo, you first need to download the pre-trained model

cd $FRCN_ROOT
./data/scripts/fetch_fast_rcnn_models.sh

The fetch_fast_rcnn_models.sh file is to help you download the model.
The downloaded model will be placed under the
$FRCN_ROOT/data/fast_rcnn_models folder
and there is also a "fetch_imagenet_models.sh" file, which downloads an empty model that can be used for future training. This will be said later.

2.demo.py

Under the tools folder, there is a demo.py file, which can be run directly
and the running method given by the demo author is very simple

cd $FRCN_ROOT
./tools/demo.py

The effect is shown in the figure.
write picture description here
If you use a notebook or some general graphics card to run the demo, you need to add parameters.

./tools/demo.py --net caffenet

Now let's take a look at the inside of demo.py:

    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print 'Demo for data/demo/000004.jpg'
    demo(net, '000004', ('car',))

    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print 'Demo for data/demo/001551.jpg'
    demo(net, '001551', ('sofa', 'tvmonitor'))

First of all, in the main function, you can see that the function to test a specific image is the demo function
. The first parameter net has just been said, and it can be manually changed to caffenet when running, otherwise the default is VGG16.
The second parameter is the name of the image to be tested. , the third is the class to be tested
Below is the code that starts in the demo function

  box_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo',
                            image_name + '_boxes.mat')
  obj_proposals = sio.loadmat(box_file)['boxes']
  im_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo', image_name + '.jpg')

Then you can see that the test file is placed under the data/demo/ folder.
If the picture file is 000004.jpg, and the mat file is 000004_boxes.mat,
but when testing your own data later, you can directly change the data format required by the code to your own data format.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325951416&siteId=291194637