Skip to content

About

A ML model that uses MLP to perform pixel-wise segmentation. It makes use of low level libraries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Technical Report for EEEM005 Coursework

1. Overview of the Task and the Solution 
For this report, the objective was to design a model capable of image segmentation using low-level libraries such as NumPy and math. Out of the given selection of algorithms, the Multiple Layer Perceptron (MLP) was chosen.
The model will be used to classify image pixels into 5 labels: Building, Road, Tree, Vehicle, and Grass. For training, a 3000×4000 image and its mask will serve as the training data. Both the image and its mask have three channels (RGB). After training, the model’s generalisation capabilities will be tested using two test images, “testing_image1.jpg” and “testing_image2.jpg”. To assess the model's accuracy, balanced accuracy will be calculated. The corresponding mask of each Image will be generated as well.
After training and testing, both images achieved a balanced accuracy of 1. This means that, out of all the pixels in the image, the model correctly classified them all.

2. Detailed Description of the Technical Design 
The MLP consists of 3 input neurons, 32 hidden neurons, and 5 output neurons. The training image has 3 channels, namely RGB. Each of the 3 input neurons is fed a channel of the pixel. In the output layer, each neuron will produce the probability of a pixel belonging to one of the five labels. In the model, there are only two learnable layers, so only two weights and biases will be initialised.
The model consists of 9 functions: initialisation, image loading, mask loading, one-hot encoding, SoftMax, ReLU, ReLU derivative, model training, and model testing. 
The model training function, as the name implies, trains the model using the training image and training image mask. It consists of 6 steps. First, the training image and mask are loaded, then the input is prepared. The same is also done to the labels before one-hot encoding. After all this, the weights are initialised, then training begins.
In the training loop of step 6, training is performed over 50 epochs, as denoted by “self.num_epochs”. For each epoch, the dataset is shuffled, reordering the pixels to prevent the model from learning patterns. Mini-batch slicing is then employed to reduce memory load and improve generalisation. This is the second “for” loop in step 6. For each batch, forward propagation and backpropagation are performed to compute predictions, SoftMax gradients, and cross-entropy. Then, the gradient descent of each weight is updated.
The model testing function tests the model's generalisation capabilities using the testing image. It generates a test image mask and calculates the balanced accuracy of the model.

3. Justification of the Segmentation Model Design
Rivier et al. (2024) developed a weakly supervised segmentation algorithm that expands user-labelled points into super pixels, generates partial masks, and trains segmentation models with a weighted mask loss to achieve performance close to that of fully supervised models. In the paper, models like FCN, U-Net, and DeepLaBV3 are examined. An MLP classifier is used in all three models for pixel classification. The purpose of the MLP is aligned with the task given in this project. That is why an MLP was chosen. 

4. Limitations and Recommendations for Improvement
For the given task, the model performs very well. For both testing images, a balanced accuracy of 1 was obtained. On the surface, this seems great, but in reality, it is probably because both test images are variations of the training image. Using the model on images with significant variations from the training images will likely result in a lower balanced accuracy. The solution would be to train the model on a more diverse training dataset.
Although the testing images were variations of the training image, some anti-overfitting measures were needed. Measures such as shuffling, mini-batching, weight decay, and tuned learning rates. Before these measures were taken, balanced accuracy was 0.2.

Disclaimer of AI Use
Generative AI was used to pick the best algorithm for pixel-wise segmentation, with a reference, of course, and recommend anti-overfitting measures for the model.

References
Rivier, S., Hinojosa, C., Giancola, S. & Ghanem, B. (2024) Efficient Semantic Segmentation for Aerial Imagery Using Query Points and Superpixel Supervision. arXiv preprint arXiv:2309.05490v2.

About

A ML model that uses MLP to perform pixel-wise segmentation. It makes use of low level libraries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages