示例#1
0
def load_data(output="label_bbox",
              batch_size=32,
              channels=1,
              tl_preprocess=False,
              model_type="resnet",
              seed=23):

    data = DataLoader('./data/cars_train',
                      './data/cars_test',
                      './data/devkit',
                      batch_size=batch_size)
    n_classes = len(data.df_train['label'].unique())
    labels = data.labels
    print(f'{n_classes} CLASSES, Random Chance: {1/n_classes}')

    train_gen = data.get_pipeline(type='train',
                                  output=output,
                                  apply_aug=True,
                                  channels=channels,
                                  tl_preprocess=tl_preprocess,
                                  model_type=model_type,
                                  seed=seed)
    steps_per_epoch = np.ceil(len(data.df_train) / data.batch_size)

    valid_gen = data.get_pipeline(type='validation',
                                  output=output,
                                  channels=channels,
                                  apply_aug=False,
                                  tl_preprocess=tl_preprocess,
                                  model_type=model_type,
                                  seed=seed)
    validation_steps = np.ceil(len(data.df_valid) / data.batch_size)

    return (labels, n_classes, train_gen, steps_per_epoch, valid_gen,
            validation_steps)
示例#2
0
def data():
    output = "label_bbox"
    channels = 3
    BATCH_SIZE = 32
    SEED = 23

    data = DataLoader('./data/cars_train',
                      './data/cars_test',
                      './data/devkit',
                      batch_size=BATCH_SIZE)

    train_gen = data.get_pipeline(type='train',
                                  output=output,
                                  apply_aug=True,
                                  channels=channels,
                                  seed=SEED)

    valid_gen = data.get_pipeline(type='validation',
                                  output=output,
                                  channels=channels,
                                  apply_aug=True,
                                  seed=SEED)

    return train_gen, valid_gen
示例#3
0
from models.one_hidden_layer import Simple_NN

clear_session()  # Clear models from previous sessions

# Constants
BATCH_SIZE = 32
SEED = 23

# Initialize Pipeline
data = DataLoader('./data/cars_train',
                  './data/cars_test',
                  './data/devkit',
                  batch_size=BATCH_SIZE)
n_classes = len(data.df_train['label'].unique())

train_gen_clf = data.get_pipeline(type='train', output='label', seed=SEED)
train_gen_localize = data.get_pipeline(type='train', output='bbox', seed=SEED)
train_gen_clf_localize = data.get_pipeline(type='train', seed=SEED)
steps_per_epoch = tf.math.ceil(len(data.df_train) / data.batch_size)
tf.cast(steps_per_epoch, tf.int16).numpy()

valid_gen_clf = data.get_pipeline(type='validation',
                                  output='label',
                                  apply_aug=False,
                                  seed=SEED)
valid_gen_localize = data.get_pipeline(type='validation',
                                       output='bbox',
                                       apply_aug=False,
                                       seed=SEED)
valid_gen_clf_localize = data.get_pipeline(type='validation',
                                           apply_aug=False,