import tagger, helper import os, Image, sys, json from time import time, sleep HTTP_DIR = "http://www.ics.uci.edu/~arjun/mm12/train/" LOC_DIR = '/home/arjun/Desktop' pics = ['g3.jpg'] for pic in pics: url = os.path.join(HTTP_DIR, pic) detection = tagger.detect_faces(url) print detection['photos'][0]['tags'][0]['tid'] image = Image.open( os.path.join(LOC_DIR, pic) ); helper.draw_tags(image, detection['photos'][0]) tagrsp = tagger.save_tag('fb_1666306302@wicknicks', detection['photos'][0]['tags'][0]['tid'], url) print tagrsp, '\n\n\n' # Ramesh: fb_6028816@wicknicks # Gerald: fb_1666306302@wicknicks
if len(sys.argv) < 2: sys.exit() links = open(sys.argv[1], 'r') count = 0 for img in links.readlines(): img = img.strip(); detection = detector.detect_faces(img) if 'tags' not in detection: print detection sys.exit() if len(detection['tags']) != 1: print "# of tags != ", img, len(detection['tags']) print json.dumps(detection, sort_keys = True, indent = 2) print sys.exit() tag = detection['tags'][0]['tid'] rsp = tagger.save_tag(uid, tag, img) count += 1 tagger.train_uid(uid) f=open('/data/mugshots/trained.ix', 'a') f.seek(0,2) f.write(uid + ' ' + str(count)) f.write('\n') f.close()