def create_ecc_image_collection(depends_on = ROOT + 'images/', creates = get_cert_paths('images',None,None)): conn = connect_to_db() colroot = get_col_root(steptag = 'images') colfiles = colroot + '.files' colchunks = colroot + '.chunks' db = conn[DATA_DB_NAME] if colfiles in db.collection_names(): db.drop_collection(colfiles) db.drop_collection(colchunks) fs = gridfs.GridFS(db,collection = colroot) p = os.path.join(depends_on,'faces','caricature') L = filter(lambda x : x.endswith('.png'), os.listdir(p)) for l in L: contents = open(os.path.join(p,l)).read() metadata = {'filename' : l, 'type': 'face', 'mode' : 'cartoon','subject':'human'} fs.put(contents,**metadata) p = os.path.join(depends_on,'faces','cartoon') L = filter(lambda x : x.endswith('.png'), os.listdir(p)) for l in L: contents = open(os.path.join(p,l)).read() metadata = {'filename' : l, 'type': 'face', 'mode' : 'cartoon','subject':'monkey'} fs.put(contents,**metadata) p = os.path.join(depends_on,'faces','human') L = filter(lambda x : x.endswith('.png'), os.listdir(p)) for l in L: contents = open(os.path.join(p,l)).read() metadata = {'filename' : l, 'type': 'face', 'mode' : 'photo','subject':'human'} fs.put(contents,**metadata) p = os.path.join(depends_on,'faces','monkey') L = filter(lambda x : x.endswith('.png'), os.listdir(p)) for l in L: contents = open(os.path.join(p,l)).read() metadata = {'filename' : l, 'type': 'face', 'mode' : 'photo','subject':'monkey'} fs.put(contents,**metadata) attdict = {} attdict['bodies'] = {'mode':'photo','subject':'body'} attdict['cars'] = {'mode':'photo','subject':'car'} attdict['cats'] = {'mode':'photo','subject':'cat'} attdict['cubes'] = {'mode':'generated','subject':'cube'} attdict['familar'] = {'mode':'photo','subject':'familiar'} attdict['round'] = {'mode':'photo','subject':'round'} attdict['smooths'] = {'mode':'generated','subject':'smooth'} attdict['spikes'] = {'mode':'generated','subject':'spike'} p = os.path.join(depends_on,'objects') L = filter(lambda x : os.path.isdir(os.path.join(p,x)),os.listdir(p)) for l in L: p1 = os.path.join(p,l) L1 = filter(lambda x : x.endswith('.png'), os.listdir(p1)) for l1 in L1: contents = open(os.path.join(p1,l1)).read() metadata = {'filename' : l1, 'type': 'object', 'mode':attdict[l]['mode'] , 'subject' : attdict[l]['subject']} fs.put(contents,**metadata) createCertificateDict(creates[0],{'root':colroot,'steptag':'images'})
def test_v1like_a_results_on_faces_vs_humans(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../faces_vs_human_results/'): train_test('../v1/config/v1like_a.py',creates,[{'type':'face'},{'type':'object','subject':'human'}],30,80)
def test_v1like_a_results_on_photo_vs_cartoonfaces(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../photo_vs_cartoon_faces_results/'): train_test('../v1/config/v1like_a.py',creates,{'mode':'photo'},15,40,universe={'type':'face'})
def test_v1like_a_results_on_faces_vs_humans_cramer_singer(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../faces_vs_human_results_cs/'): train_test('../v1/config/v1like_a.py',creates,[{'type':'face'},{'type':'object','subject':'human'}],30,80,classifier = multi_classify, classifier_kwargs = {'multi_class':True})
def test_v1like_a_results_on_humans_vs_monkey_faces(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../humans_vs_monkey_faces_results/'): train_test('../v1/config/v1like_a.py',creates,{'subject':'human'},15,40,universe={'type':'face'})
def test_v1like_a_results_on_photo_vs_object(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../photo_vs_object/'): train_test('../v1/config/v1like_a.py',creates,{'mode':'photo'},40,20,ntrain_pos=20,N=15,universe={'$or':[{'mode':'photo'},{'type':'object'}]})
def test_v1like_a_results_on_human_faces_vs_familiar(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../human_faces_results_vs_familiar/'): train_test('../v1/config/v1like_a.py',creates,{'subject':'human','mode':'photo'},25,10,ntrain_pos=13,N=10,universe={'$or':[{'subject':'human','mode':'photo'},{'type':'object','subject':'familiar'}]})
def test_v1like_a_results_on_human_faces(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../human_faces_results/'): train_test('../v1/config/v1like_a.py','../human_faces_results/',{'type':'face','subject':'human','mode':'photo'},20,60,N=15,universe={'$or':[{'type':'face','subject':'human','mode':'photo'},{'type':'object'}]})
def test_v1like_a_results_on_faces(depends_on = get_cert_paths('add_features','../v1/config/v1like_a.py',None) + ('../v1/config/v1like_a.py',), creates = '../faces_results/'): train_test('../v1/config/v1like_a.py','../faces_results/',{'type':'face'},30,80,N=30)