Esempio n. 1
0
def main():
    arg_helper = CmdArgumentsHelper();
    arg_helper.add_argument('query', 'q', 'query', 1);
    arg_helper.add_argument('root_dir', 'r', 'root', 1);
    arg_helper.add_argument('top_tag_num', 't', 'top_tag_num', 1);    
    args = arg_helper.read_arguments();
    print (args);

    root = args['root_dir'];
    top_tag_num = int(args['top_tag_num']);
    query = args['query'];

    from PhotoDao import PhotoDao;
    from DBHelper import DBHelper;
    db_helper = DBHelper();
    db_helper.init(root);
    photo_dao = PhotoDao(db_helper);

    print('get photo ids.');
    tic();
    photo_ids = photo_dao.getClassPhotoIds(query, ''.join([query]));
    toc();

    print('get photos ...');
    tic();
    photos = photo_dao.getPhotos(query, photo_ids);
    toc();

    print('gen top tags via user...');
    from task_gen_top_tags import task_gen_top_tag_via_user;
    tic();
    top_word = task_gen_top_tag_via_user(photos, query, top_tag_num, root);
    toc();

    print('build tag features...');
    from task_gen_top_tags import task_build_tag_features;
    tic();
    task_build_tag_features(top_word, query, photos, 0, root);
    toc();
Esempio n. 2
0
    print("process_files_parallel()", time.time()-start);
    photos = [];
    for photo_info in photos_keep:
        if(photo_info['keep']):
            photos.append(photo_info['photo']);
    return photos;

if __name__ == '__main__':
    from PhotoDao import PhotoDao;
    from DBHelper import DBHelper;
    db_helper = DBHelper();
    root = '/nas02/home/h/o/hongtao/Iconic';
    db_helper.init(root);

    query = 'love';
    photo_dao = PhotoDao(db_helper);
    photo_ids = photo_dao.getClassPhotoIds(query, ''.join([query]));
#    photo_ids = photo_ids[0:100];
#    photos = photo_dao.getPhotos(query, photo_ids);

    photos = getPhotosMultiThread(root, query, photo_ids);
    print('obtain ' + str(len(photos)) + ' photos.'); 

    top_tagfile = '/nas02/home/h/o/hongtao/magiconic/FlickrDownloader/tmp_dir/data/tags/%s.txt' % query;
    fin = open(top_tagfile, 'r');
    for tag in fin:
        top_tags.append(tag.strip());
    photos = filter_photos_with_top_tags(photos);
    print('after filter image photos, ' + str(len(photos)) + ' images left.'); 
    new_photo_ids = [];
    for photo in photos: