forked from mahyarnajibi/SSH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.py
71 lines (61 loc) · 2.89 KB
/
main_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -----------------------------------------------------
# SSH: Single Stage Headless Face Detector
# Main module for evaluating the SSH on a given dataset
# Written by Mahyar Najibi
# -----------------------------------------------------
from SSH.test import test_net
import argparse
from datasets.factory import get_imdb
from utils.get_config import cfg, cfg_from_file, cfg_from_list,cfg_print
import caffe
def parser():
parser = argparse.ArgumentParser('SSH Evaluate Module!',
description='You can change other configs by providing a YAML config file!')
parser.add_argument('--db', dest='db_name', help='Path to the image',
default='wider_val', type=str)
parser.add_argument('--gpu', dest='gpu_id', help='The GPU ide to be used',
default=0, type=int)
parser.add_argument('--proto', dest='prototxt', help='SSH caffe test prototxt',
default='SSH/models/test_ssh.prototxt', type=str)
parser.add_argument('--out_path', dest='out_path', help='Output path for saving the figure',
default='output', type=str)
parser.add_argument('--model', dest='model', help='SSH trained caffemodel',
default='data/SSH_models/SSH.caffemodel', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
parser.add_argument('--cfg', dest='cfg', help='Config file to overwrite the default configs',
default='SSH/configs/wider.yml', type=str)
parser.add_argument('--vis', dest='visualize', help='visualize detections',
action='store_true')
parser.add_argument('--net_name', dest='net_name',
help='The name of the experiment',
default='SSH',type=str)
parser.add_argument('--no_cache', dest='no_cache', help='Do not cache detections',
action='store_true')
parser.add_argument('--debug', dest='debug', help='Debug mode',
action='store_true')
return parser.parse_args()
def main(args):
# Combine the default config with
# the external config file and the set command
if args.cfg is not None:
cfg_from_file(args.cfg)
if args.set_cfgs is not None:
cfg_from_list(args.set_cfgs)
cfg.DEBUG = args.debug
cfg.GPU_ID = args.gpu_id
cfg_print(cfg)
# Loading the network
caffe.set_mode_gpu()
caffe.set_device(args.gpu_id)
net = caffe.Net(args.prototxt, args.model, caffe.TEST)
# Create the imdb
imdb = get_imdb(args.db_name)
# Set the network name
net.name = args.net_name
# Evaluate the network
test_net(net, imdb, visualize=args.visualize, no_cache=args.no_cache, output_path=args.out_path)
if __name__ == '__main__':
args = parser()
main(args)