#images = glob.glob('./run_track1/*.jpg')
images = ['./examples/input_salient_track2_6.jpg']
total = len(images)

# Initial call to print 0% progress
printProgressBar(0, total, prefix='Progress:', suffix='Complete', length=50)

batch_print = 100

for i, path in enumerate(images):

    image_array = mpimg.imread(path)
    yuv = cv2.cvtColor(image_array, cv2.COLOR_BGR2YUV)
    y, u, v = cv2.split(yuv)
    y = y.reshape(160, 320, -1)

    filename = path.split('/')[-1]

    img_predicted = model.predict(y[None, :, :, :], batch_size=1)

    img_predicted = img_predicted.reshape(img_predicted.shape[1:])

    img = ((img_predicted - img_predicted.min()) * 255 /
           (img_predicted.max() - img_predicted.min())).astype(np.uint8)

    new = [[[j if j <= 80 else 0, j if j > 80 else 0, 0] for j in i]
           for i in img]
    dt = np.dtype('uint8')
    new = np.array(new, dtype=dt)
Ejemplo n.º 2
0
                                   cval=0.,
                                   horizontal_flip=True,
                                   vertical_flip=False,
                                   rescale=None)

test_datagen = ImageDataGenerator(featurewise_center=False,
                                  samplewise_center=True,
                                  featurewise_std_normalization=False,
                                  samplewise_std_normalization=True)

if preview_augmentation:
    # Preview resultant images:
    img = load_img(train_data_dir +
                   '/mountain/land132.jpg')  # this is a PIL image
    x = img_to_array(img)  # this is a Numpy array with shape (3, 150, 150)
    x = x.reshape(
        (1, ) + x.shape)  # this is a Numpy array with shape (1, 3, 150, 150)
    i = 0
    for batch in train_datagen.flow(x,
                                    batch_size=1,
                                    save_to_dir='preview',
                                    save_prefix='image',
                                    save_format='jpeg'):
        i += 1
        if i > 20:
            break  # otherwise the generator would loop indefinitely

train_generator = train_datagen.flow_from_directory(train_data_dir,
                                                    target_size=(img_width,
                                                                 img_height),
                                                    batch_size=batch_size,
                                                    class_mode='categorical')