-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.py
71 lines (46 loc) · 2.07 KB
/
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
from extract_features import features
import caffe
import argparse
caffe.set_mode_gpu()
caffe.set_device(0)
def parse_args():
"""
parse input argument
"""
parser = argparse.ArgumentParser()
parser.add_argument('--filename',
help='the file saves testing images',
default='testImages.txt',
type=str)
parser.add_argument('--model_def_a',
help='the caffe prototxt for aesthetics and attributes model',
default='attNaesS1.prototxt',
type=str)
parser.add_argument('--model_weights_a',
help='the weights for aesthetics and attributes model',
default='attNaesSmall.caffemodel',
type=str)
parser.add_argument('--model_def_content',
help='the caffe prototxt for content model',
default='content.prototxt',
type=str)
parser.add_argument('--model_weights_content',
help='the weights for content model',
default='content.caffemodel',
type=str)
args = parser.parse_args()
return args
def main(filename, model_def_a, model_weights_a, model_def_content, model_weights_content):
allLines = open(filename, 'r').readlines()
album = []
for item in allLines:
album.append(item.rstrip())
attributesFeature, predictScoreAll, contentFeature = features(album, model_def_a, model_weights_a, model_def_content, model_weights_content)
return attributesFeature, predictScoreAll, contentFeature
if __name__ == '__main__':
args = parse_args()
attributesFeature, predictScoreAll, contentFeature = main(args.filename, args.model_def_a, args.model_weights_a,
args.model_def_content, args.model_weights_content)
print 'aesthetics attributes: ', attributesFeature
print 'aestheitcs score: ', predictScoreAll
print 'content feature: ', contentFeature