forked from georgepar/mmfeat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miner.py
38 lines (32 loc) · 1.35 KB
/
miner.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
'''
Tool for mining image/audio search engines and storing in data directory for further processing
'''
import argparse
from mmfeat.miner import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('engine', nargs=1, \
help='type of engine to use', choices=['bing', 'google', 'freesound', 'flickr', 'imagenet'])
parser.add_argument('query_file', nargs=1, \
help='file that contains the list of queries (every line is a query)')
parser.add_argument('data_dir', nargs=1, \
help='location of directories')
parser.add_argument('-n', '--num_files', type=int, action='store', \
help='number of files to mine per query (default 20)', default=20)
args = parser.parse_args()
args.engine = args.engine[0]
args.query_file = args.query_file[0]
args.data_dir = args.data_dir[0]
if args.engine == 'bing':
miner = BingMiner(args.data_dir)
elif args.engine == 'google':
miner = GoogleMiner(args.data_dir)
elif args.engine == 'freesound':
miner = FreeSoundMiner(args.data_dir)
elif args.engine == 'flickr':
miner = FlickrMiner(args.data_dir)
elif args.engine == 'imagenet':
miner = ImageNetMiner(args.data_dir)
queries = open(args.query_file).read().splitlines()
miner.getResults(queries, args.num_files)
miner.save()