This Project uses U-net architecture to build a model to output the segmentation map of the face given the input face image.
Our Model is getting 97.16 % accuracy on training set and 92.08 % on validation set.
Visualization of some test Result:
The Data contains 1999 train images and 100 test images. The labels of image contains different face components like eyebrows, lips, nose,left eye, right eye,etc.
The face components are listed in label_names.txt.
Original Link to the dataset: https://drive.google.com/file/d/1jweX1u0vltv-tYZhYp6mlyDZDy0aDyrw/view
- Numpy
- tensorflow
- keras
- cv2
- os
- time
- Datetime
- tqdm
Zip the train and test folder (from the dataset available in the link) to Unet.zip.
Upload the Unet.zip file to colab session.
!unzip "/content/drive/MyDrive/U-net/u-net.zip" -d "/content/Data"
If you want to train the model set, PRETRAINED=False in Colab Notebook else set,
PRETRAINED=True
Save the predicted result(in .png) in predict_image folder. Run the Python script F1_score.py to get the F1_score.
python f1_score.py
For every Image we need to do the following:
- Resize all the image to same dimension (256,256,3) using cv2.resize()
- Normalize all the image.
- Convert image to np.float32 numoy array
For every Mask/labels we need to do:
- Read Mask using opencv as a grayscale image (by using cv2.IMREAD_GRAYSCALE)
- Convert every label to binary mask (by using tf.keras.utils.to_categorical).
- Resize the image to dimension(256,256,1) and use INTER_NEAREST interpolation(to preserve the label during resizing)
We get maximun validation accuracy at 33th epoch.
Train Set Accuracy: 97.16%
Validation Set Accuracy: 92.08%
Train Set loss: 0.0127
Validation Set loss:0.0523
Test Set Accuracy: 90.34%
Test Set loss: 0.071
F1 score on test Dataset : 78.017
- U-Net: Convolutional Networks for Biomedical Image SegmentationOlaf Ronneberger, Philipp Fischer, and Thomas Brox
- https://cs230.stanford.edu/blog/tensorflow/