Esempio n. 1
0
def load_data():
    """Load data."""
    data = gtsdb.load_data()
    X_train = data['x_train']
    y_train = data['y_train']
    X_val = None
    y_val = None

    # X_train, X_val, y_train, y_val = train_test_split(X_train, y_train,
    #                                                   test_size=0.10,
    #                                                   random_state=42)
    X_train = X_train.astype('float32')
    # X_val = X_val.astype('float32')
    # X_test = X_test.astype('float32')
    X_train /= 255
    # X_val /= 255
    return X_train, X_val, y_train, y_val
Esempio n. 2
0
import sequential_model

batch_size = 64
nb_classes = gtsdb.n_classes
nb_epoch = 200
data_augmentation = True
load_smoothed_labels = False
model_type = 'dense'

# input image dimensions
img_rows, img_cols = 32, 32
# The CIFAR10 images are RGB.
img_channels = 3

# The data, shuffled and split between train and test sets:
data = gtsdb.load_data()
X_train, y_train = data['x_train'], data['y_train']
X_val, y_val = X_train, y_train
# X_train, X_val, y_train, y_val = train_test_split(X_train, y_train,
#                                                   test_size=0.10,
#                                                   random_state=42)

# Convert class vectors to binary class matrices.
Y_train = np_utils.to_categorical(y_train, nb_classes)
print(Y_train.shape)
# Y_train = Y_train.reshape((-1, 1, 1, nb_classes))  - fully convolutional
print(Y_train.shape)

if load_smoothed_labels:
    Y_train = np.load('smoothed_lables.npy')
Y_val = np_utils.to_categorical(y_val, nb_classes)
Esempio n. 3
0
from keras.models import load_model
import gtsdb
import scipy.misc
import numpy as np
import logging
import sys

logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                    level=logging.DEBUG,
                    stream=sys.stdout)

logging.info("Load model...")
model = load_model("gtsdb-400-epoch.h5")

logging.info("Load data...")
data = gtsdb.load_data()

logging.info("Evaluate...")
x_test = np.array(data['x_test'], dtype=np.float32)
for img_orig in x_test:
    height, width, channels = img_orig.shape

    for scale in [16, 32, 64, 128]:
        pad_h = scale - (height % scale)
        pad_w = scale - (width % scale)
        if pad_h == scale:
            pad_h = 0
        if pad_w == scale:
            pad_w = 0
        pad_l = int(pad_w / 2)
        pad_r = pad_w - pad_l