In [1]:
import my_io
reload(my_io)
import glob
import os

import warnings
warnings.filterwarnings('ignore')

TEST_DIR = '/media/raid_arr/data/ndsb/test'
OUT_DIR = '/media/raid_arr/data/ndsb/test_final'

OUT_SHAPE = (64, 64)

In [2]:
im_files = glob.glob(os.path.join(TEST_DIR, '*.jpg'))

In [4]:
my_io.multi_extract(im_files, OUT_DIR,
                    backend='lmdb', perturb=False,
                    out_shape=OUT_SHAPE,
                    transfer_feats=True, transfer_lbls=False,
                    mode='test',
                    verbose=True)


Multiproc extraction: 1600.34047508
Transfering feats to another db
Feat transfer done: 25.8408498764

Train set redo


In [1]:
import my_io
reload(my_io)
import glob
import os
import numpy as np

import warnings
warnings.filterwarnings('ignore')

TRAIN_FOLD_PATH = '/media/raid_arr/tmp/train0_norm_lmdb'    # Output train
TEST_FOLD_PATH = '/media/raid_arr/tmp/test0_norm_lmdb'    # Output test

TRAIN_FOLD_TXT = '/media/raid_arr/data/ndsb/folds/train0.txt'
TEST_FOLD_TXT = '/media/raid_arr/data/ndsb/folds/test0.txt'

OUT_SHAPE = (64, 64)

In [3]:
# Grab the image paths from the folds that were already generated
train_fold_paths = np.loadtxt(TRAIN_FOLD_TXT, delimiter='\t', dtype=str)[:, 0]
test_fold_paths = np.loadtxt(TEST_FOLD_TXT, delimiter='\t', dtype=str)[:, 0]
np.random.shuffle(train_fold_paths)
np.random.shuffle(test_fold_paths)

In [4]:
my_io.multi_extract(test_fold_paths, TEST_FOLD_PATH,
                    backend='lmdb', perturb=False,
                    out_shape=OUT_SHAPE,
                    transfer_feats=True, transfer_lbls=True,
                    mode='train',
                    verbose=True)


Multiproc extraction: 18.285394907
Transfering feats to another db
Feat transfer done: 1.64316296577
Transfering parent labels to another db
Parent labels transfer done: 1.49681401253

In [ ]:
my_io.multi_extract(train_fold_paths, TRAIN_FOLD_PATH,
                    backend='lmdb', perturb=False,
                    out_shape=OUT_SHAPE,
                    transfer_feats=True, transfer_lbls=True,
                    mode='train',
                    verbose=True)


Multiproc extraction: 61.6839718819
Transfering feats to another db
Feat transfer done:

Make sure the images in db look sensible


In [44]:
import matplotlib.pyplot as plt
%matplotlib inline
imshow = lambda im: plt.imshow(im, cmap='gray', interpolation='none')


data = my_io.load_lmdb(TEST_FOLD_PATH)

In [45]:
(image_path, image, label) = zip(*data)

In [47]:
im = np.squeeze(image[10])
imshow(im)


Out[47]:
<matplotlib.image.AxesImage at 0x7f945c3aca50>

Make Specialists db


In [1]:
import my_io
reload(my_io)
import glob
import os
import numpy as np

import warnings
warnings.filterwarnings('ignore')

TRAIN_FOLD_PATH = '/media/raid_arr/tmp/train0_norm_lmdb'    # Output train
TEST_FOLD_PATH = '/media/raid_arr/tmp/test0_norm_lmdb'    # Output test

TRAIN_FOLD_TXT = '/media/raid_arr/data/ndsb/folds/train0.txt'
TEST_FOLD_TXT = '/media/raid_arr/data/ndsb/folds/test0.txt'

OUT_SHAPE = (64, 64)
# Grab the image paths from the folds that were already generated
train_fold_paths = np.loadtxt(TRAIN_FOLD_TXT, delimiter='\t', dtype=str)[:, 0]
test_fold_paths = np.loadtxt(TEST_FOLD_TXT, delimiter='\t', dtype=str)[:, 0]
np.random.shuffle(train_fold_paths)
np.random.shuffle(test_fold_paths)

In [5]:
my_io.multi_extract(train_fold_paths, TRAIN_FOLD_PATH, 
                    backend='lmdb',
                    transfer_feats=False,
                    transfer_plbls=False,
                    transfer_splbls=False,
                    create_specialists=True,
                    perturb=True, verbose=True)


Multiproc extraction: 59.4672830105
Creating specialist db...
Specialist db creation done: 21.5933980942
Transfering specialist labels to another db
Specialist labels transfer done: 4.85292410851

In [2]:
my_io.multi_extract(test_fold_paths, TEST_FOLD_PATH, 
                    backend='lmdb',
                    transfer_feats=False,
                    transfer_plbls=False,
                    transfer_splbls=False,
                    create_specialists=True,
                    perturb=True, verbose=True)


Multiproc extraction: 31.5430059433
Creating specialist db...
Specialist db creation done: 8.59890985489