Tensorflow / TFLearn Image I / O Issues

To learn more about deep learning and computer vision, I am working on a project to determine lanes on the roads. I use TFLearn as a wrapper around Tensorflow.

Background

The training inputs are images of roads (each image is represented as a 2D array of 50 × 50 pixels in size, with each element having a brightness value from 0.0 to 1.0).

The training outputs have the same shape (50x50 array), but represent the marked area of ​​the strip. In fact, pixels without a road are 0, and road pixels are 1.

This is not a problem of classifying images with a fixed size, but instead a problem of detecting road and off-road pixels from an image.

Problem

I have not been able to successfully configure my inputs / outputs in such a way that TFLearn / Tensorflow accepts, and I'm not sure why. Here is my sample code:

# X = An array of training inputs (of shape (50 x 50)).
# Y = An array of training outputs (of shape (50 x 50)).

# "None" equals the number of samples in my training set, 50 represents
# the size of the 2D image array, and 1 represents the single channel
# (grayscale) of the image.
network = input_data(shape=[None, 50, 50, 1])

network = conv_2d(network, 50, 50, activation='relu')

# Does the 50 argument represent the output shape? Should this be 2500?
network = fully_connected(network, 50, activation='softmax')

network = regression(network, optimizer='adam', loss='categorical_crossentropy', learning_rate=0.001)

model = tflearn.DNN(network, tensorboard_verbose=1)

model.fit(X, Y, n_epoch=10, shuffle=True, validation_set=(X, Y), show_metric=True, batch_size=1)

The error I get causes an model.fiterror call :

ValueError: Cannot feed value of shape (1, 50, 50) for Tensor u'InputData/X:0', which has shape '(?, 50, 50, 1)'

I tried to reduce the sample I / O arrays to a 1D vector (2500 in length), but this leads to other errors.

I lost a little how to do it all, any help would be greatly appreciated!

+4
source share
2 answers

imageflow tensorflow, numpy, , .tfrecords, shadoworflow https://github.com/HamedMP/ImageFlow.

$ pip install imageflow

, numpy, "k", k_images, k ( ) k_labels, .tfrecords "tfr_file.tfrecords" ,

imageflow.convert_images(k_images, k_labels, 'tfr_file')

, Google Inception , , https://github.com/tensorflow/models/blob/master/inception/inception/data/build_image_data.py

+1

, , 4- 3. , (X) [-1,50,50,1]. , , - X .

# X = An array of training inputs (of shape (50 x 50)).
# Y = An array of training outputs (of shape (50 x 50)).
# "None" equals the number of samples in my training set, 50 represents
# the size of the 2D image array, and 1 represents the single channel
# (grayscale) of the image.

X = tensorflow.reshape(X, shape[-1, 50, 50, 1])
network = input_data(shape=[None, 50, 50, 1])

network = conv_2d(network, 50, 50, activation='relu')

# Does the 50 argument represent the output shape? Should this be 2500?
network = fully_connected(network, 50, activation='softmax')

network = regression(network, optimizer='adam', loss='categorical_crossentropy', learning_rate=0.001)

model = tflearn.DNN(network, tensorboard_verbose=1)

model.fit(X, Y, n_epoch=10, shuffle=True, validation_set=(X, Y), show_metric=True, batch_size=1)
+1

Source: https://habr.com/ru/post/1657879/


All Articles