The goal of the project is to label the pixels of a road in images using a Fully Convolutional Network (FCN). Kitti Road dataset is used to train the neural network to identify road in an image at pixel level. And a fully convolutional version of a pre-trained vgg model is utilized.
- load_vgg - To load the pre-trained vgg model and weights. In the pre-trained vgg model, a fully connected layer is replaced with a 1x1 convolutional layer in order to preserve spatial information.
- layers - In this function, 1x1 convolution is used as the first layer to reduce the size of the filter to a number of classes. Subsequent transpose layers are added for upsampling the image along with skip layers.
- optimize - This function calculates cross entropy loss using labels and uses tensorflow Adam optimize to minimize the loss.
- train_nn - It takes images, labels, epochs, batch_size and other parameters to train the neural network.
- run - This function is responsible for creating the session, initializing the parameters and invoking all other functions as specified above.
Make sure you have the following is installed:
Download the Kitti Road dataset from here. Extract the dataset in the data
folder. This will create the folder data_road
with all the training a test images.
Implement the code in the main.py
module indicated by the "TODO" comments.
The comments indicated with "OPTIONAL" tag are not required to complete.
Run the following command to run the project:
python main.py
Note If running this in Jupyter Notebook system messages, such as those regarding test status, may appear in the terminal rather than the notebook.
- Ensure you've passed all the unit tests.
- Ensure you pass all points on the rubric.
- Submit the following in a zip file.
helper.py
main.py
project_tests.py
- Newest inference images from
runs
folder (all images from the most recent run)
- The link for the frozen
VGG16
model is hardcoded intohelper.py
. The model can be found here - The model is not vanilla
VGG16
, but a fully convolutional version, which already contains the 1x1 convolutions to replace the fully connected layers. Please see this forum post for more information. A summary of additional points, follow. - The original FCN-8s was trained in stages. The authors later uploaded a version that was trained all at once to their GitHub repo. The version in the GitHub repo has one important difference: The outputs of pooling layers 3 and 4 are scaled before they are fed into the 1x1 convolutions. As a result, some students have found that the model learns much better with the scaling layers included. The model may not converge substantially faster, but may reach a higher IoU and accuracy.
- When adding l2-regularization, setting a regularizer in the arguments of the
tf.layers
is not enough. Regularization loss terms must be manually added to your loss function. otherwise regularization is not implemented.