Skip to content

shrey-001/Image-Semantic-Segmentation-Using-U-net

Repository files navigation

Image-Semantic-Segmentation-Using-U-net

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:
Alt text Alt text Alt text

About the data

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

Getting Started

System Requirements

  • Numpy
  • tensorflow
  • keras
  • cv2
  • os
  • time
  • Datetime
  • tqdm

How to Replicate

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

Preprocessing Data

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)

Model

Alt text

Result/Analysis

Alt text Alt text We get maximun validation accuracy at 33th epoch.

On 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
Alt text F1 score on test Dataset : 78.017

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published