Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppor demo by cpu and save detection result. #48

Merged
merged 2 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ Please cite our paper in your publications if it helps your research:
```Shell
python test/refinedet_demo.py
```

For CPU users,
```Shell
python test/refinedet_demo.py --args.gpu_id -1
```

5. Evaluate the trained models via [`test/refinedet_test.py`](https://github.com/sfzhang15/RefineDet/blob/master/test/refinedet_test.py).
```Shell
Expand Down
15 changes: 11 additions & 4 deletions test/refinedet_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
In this example, we will load a RefineDet model and use it to detect objects.
'''

import argparse
import os
import sys
import numpy as np
Expand Down Expand Up @@ -61,13 +62,19 @@ def ShowResults(img, image_file, results, labelmap, threshold=0.6, save_fig=Fals
ax.text(xmin, ymin, display_text, bbox={'facecolor':color, 'alpha':0.5})
if save_fig:
plt.savefig(image_file[:-4] + '_dets.jpg', bbox_inches="tight")
print('Saved: ' + image_file[:-4] + '_dets.jpg')
plt.show()

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--gpu_id', type=int, default=0)
parser.add_argument('--save_fig', action='store_true')
args = parser.parse_args()

# gpu preparation
gpu_id = 0
caffe.set_device(gpu_id)
caffe.set_mode_gpu()
if args.gpu_id >= 0:
caffe.set_device(args.gpu_id)
caffe.set_mode_gpu()

# load labelmap
labelmap_file = 'data/VOC0712/labelmap_voc.prototxt'
Expand Down Expand Up @@ -110,4 +117,4 @@ def ShowResults(img, image_file, results, labelmap, threshold=0.6, save_fig=Fals
result = np.column_stack([det_xmin, det_ymin, det_xmax, det_ymax, det_conf, det_label])

# show result
ShowResults(image, image_file, result, labelmap, 0.6, save_fig=False)
ShowResults(image, image_file, result, labelmap, 0.6, save_fig=args.save_fig)