Esempio n. 1
0
def create_single_lmdb(seed_image_id,
                       filedata,
                       test_id,
                       multi_image_training=False,
                       images_per_angle=500,
                       retraining=False):
    start_time = time.time()
    print 'create_single_lmdb for ' + str(seed_image_id)

    if retraining:
        weight_filename = 'snapshot_iter_16880.caffemodel'
        shutil.copyfile(train_dir + str(seed_image_id) + '/' + weight_filename,
                        train_dir + weight_filename)
    else:
        weight_filename = 'starting-weights.caffemodel'
        shutil.copyfile(weight_filename, train_dir + weight_filename)

    lmdb_dir = train_dir + str(seed_image_id) + '/'

    create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir,
                                                images_per_angle, -1, True,
                                                False)
    copy_train_files(lmdb_dir, multi_image_training)
    create_train_script(lmdb_dir, train_dir + weight_filename,
                        multi_image_training)
    print 'Done in %s seconds' % (time.time() - start_time, )
Esempio n. 2
0
def create_test_lmdb_batches(test_image_ids,seed_image_ids,images_per_angle):
    #todo:This needs to create the lmdbs files in order
    start_time = time.time()
    print 'Starting create_test_lmdb_batches'
    #Create test lmdbs by 10 coin_ids  (10 x 57 = 570 images)
    test_batch_filedata = {}

    for test_image_id in test_image_ids:
        test_batch_id = test_image_id / 1000
        if test_batch_id not in test_batch_filedata.iterkeys():
            test_batch_filedata[test_batch_id] = []
            lmdb_dir = test_dir + str(test_batch_id) + '/'
           r
        test_batch_filedata[test_batch_id].append([test_image_id, get_filename_from(test_image_id), 0])

    shell_filenames = []
    calling_args = []
    for test_batch_id,filedata in test_batch_filedata.iteritems():
        lmdb_dir = test_dir + str(test_batch_id) + '/'
        calling_args.append([filedata, lmdb_dir, images_per_angle])
        create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir, images_per_angle, False, False)
        for image_id in seed_image_ids:
            shell_filenames.append(create_test_script(image_id,test_batch_id))

    create_script_calling_script(test_dir + 'test_all.sh', shell_filenames)

    pool = Pool(8)
    pool.map(create_lmdb_rotate_whole_image.create_all_lmdbs, calling_args)
    pool.close()
    pool.join()
    print 'create_test_lmdb_batches', 'Done after %s seconds' % (time.time() - start_time,)
Esempio n. 3
0
def create_single_lmdbs(seed_image_ids):
    weight_filename = 'starting-weights.caffemodel'
    shutil.copyfile(weight_filename, train_dir + weight_filename)
    shell_filenames = []
    for image_id in seed_image_ids:
        print 'Creating single lmdb for ' + str(image_id)
        filedata = [[image_id, crop_dir + str(image_id) + '.png', 0]]
        lmdb_dir = train_dir + str(image_id) + '/'
        create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir, 100, -1, True, False)
        copy_train_files(lmdb_dir)
        shell_filename = create_train_script(lmdb_dir, train_dir + weight_filename, False)
        shell_filenames.append(shell_filename)
    create_script_calling_script(train_dir + 'train_all.sh', shell_filenames)
Esempio n. 4
0
def create_test_lmdbs(test_id, images_per_angle):
    print "Create_test_lmdbs for testID:" + str(test_id)
    test_image_ids = get_test_image_ids()
    filedata = []
    lmdb_dir = test_dir + str(test_id) + '/'
    for image_id in test_image_ids:
        coin_id =
        filedata.append([image_id, get_filename(image_id), 0])

    create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir, images_per_angle, test_id, False, False)

    shell_filenames = []
    seed_image_ids = get_seed_image_ids()

    for image_id in seed_image_ids:
        shell_filenames.append( create_test_script(image_id,test_id))
    create_script_calling_script(test_dir + 'test_all.sh', shell_filenames)
Esempio n. 5
0
def create_test_lmdbs(test_id):
    # test_image_ids = [x for x in range(13927)]
    test_image_ids = get_test_image_ids()
    filedata = []
    lmdb_dir = test_dir + str(test_id) + '/'
    for image_id in test_image_ids:
        filedata.append([image_id, crop_dir + str(image_id) + '.jpg', 0])

    create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir, 3, test_id,
                                                False, False)

    shell_filenames = []
    seed_image_ids = get_seed_image_ids()

    for image_id in seed_image_ids:
        shell_filenames.append(create_test_script(image_id, test_id))
    create_script_calling_script(test_dir + 'test_all.sh', shell_filenames)
Esempio n. 6
0
def create_single_lmdb(seed_image_id,
                       filedata,
                       test_id=0,
                       multi_image_training=False):
    start_time = time.time()
    print 'create_single_lmdb for ' + str(seed_image_id)

    weight_filename = train_dir + str(
        seed_image_id) + '/' + 'starting-weights.caffemodel'
    weight_filename_copy = train_dir + 'starting-weights.caffemodel'
    shutil.copyfile(weight_filename_copy, weight_filename)

    lmdb_dir = train_dir + str(seed_image_id) + '/'

    #create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir, int(100 + (0.5 * test_id)), -1, True, False)
    create_lmdb_rotate_whole_image.create_lmdbs(filedata, lmdb_dir,
                                                int(200 + (2 * test_id)), -1,
                                                True, False)
    copy_train_files(lmdb_dir, multi_image_training)
    create_train_script(lmdb_dir, weight_filename_copy, multi_image_training)
    print 'Done in %s seconds' % (time.time() - start_time, )