forked from PiJoules/meme-classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (28 loc) · 1.07 KB
/
main.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
from memeclass import MemeClassifier
def get_args():
from argparse import ArgumentParser
parser = ArgumentParser("Meme classifier")
parser.add_argument("memes", nargs="+",
help="Memes to classify.")
parser.add_argument("--templates_dir", default="templates",
help="Directory to search for meme templates to "
"compare against.")
parser.add_argument("-v", "--verbose", default=False, action="store_true",
help="Verbose output. (default: %(default)s).")
return parser.parse_args()
def main():
args = get_args()
mc = MemeClassifier(args.templates_dir)
for img_fname in args.memes:
meme_name = mc.classify(img_fname, debug=args.verbose)
if meme_name is None:
print("Could not find meme match for {}.".format(img_fname))
else:
print(img_fname, meme_name)
return 0
if __name__ == "__main__":
sys.exit(main())