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
class MemeKeyworder(BaseKeyworder): def __init__(self): super(MemeKeyworder, self).__init__() self._classifier = MemeClassifier('templates') def add_keyword(self, gag_id, image_url): ret = os.system("bash download.sh '%s' '%s'" % (gag_id, image_url)) assert ret == 0 which = self._classifier.classify('images/%s.jpg' % gag_id) if which: print 'meme', which self._add_keyword(gag_id, which)
def __init__(self): super(MemeKeyworder, self).__init__() self._classifier = MemeClassifier('templates')
# -*- coding: utf-8 -*- import sys from memeclass import MemeClassifier if len(sys.argv) == 1: print 'usage:' print ' python %s image_filename' % sys.argv[0] exit() mc = MemeClassifier('templates') sys.argv.pop(0) for img_fname in sys.argv: meme_name = mc.classify(img_fname) print img_fname, meme_name