A computer-implemented method for generating a machine learning, ML, model for semantic image segmentation, the method comprising: providing a backbone feature extraction convolutional neural network of the ML model with a plurality of early exits in the backbone network, to generate an overprovisioned network comprising a plurality of candidate early exit segmentation network architectures, wherein each early exit comprises a tailored network architecture; obtaining a training dataset comprising a plurality of images; and training the backbone network of the ML model, a final exit and the early exits to output feature maps for the plurality of images input into the backbone network, by: training, during a first training stage, the backbone network, the final exit and the early exits end-to-end; and freezing weights of the backbone network and the final exit, after the end-to-end training is complete, and training, during a second training stage, the early exits individually using the final exit as a teacher for the early exits, characterised in that the second training stage comprises: determining, using a segmentation prediction made for an image by the final exit, a difficulty of each pixel in the image based on whether the prediction for each pixel is correct; and training the early exits using only the pixels for which the prediction is correct. providing a backbone feature extraction convolutional neural network of the ML model with a plurality of early exits in the backbone network, to generate an overprovisioned network comprising a plurality of candidate early exit segmentation network architectures, wherein each early exit comprises a tailored network architecture; obtaining a training dataset comprising a plurality of images; and training the backbone network of the ML model, a final exit and the early exits to output feature maps for the plurality of images input into the backbone network, by: training, during a first training stage, the backbone network, the final exit and the early exits end-to-end; and freezing weights of the backbone network and the final exit, after the end-to-end training is complete, and training, during a second training stage, the early exits individually using the final exit as a teacher for the early exits, characterised in that the second training stage comprises: determining, using a segmentation prediction made for an image by the final exit, a difficulty of each pixel in the image based on whether the prediction for each pixel is correct; and training the early exits using only the pixels for which the prediction is correct. training, during a first training stage, the backbone network, the final exit and the early exits end-to-end; and freezing weights of the backbone network and the final exit, after the end-to-end training is complete, and training, during a second training stage, the early exits individually using the final exit as a teacher for the early exits, characterised in that the second training stage comprises: determining, using a segmentation prediction made for an image by the final exit, a difficulty of each pixel in the image based on whether the prediction for each pixel is correct; and training the early exits using only the pixels for which the prediction is correct. determining, using a segmentation prediction made for an image by the final exit, a difficulty of each pixel in the image based on whether the prediction for each pixel is correct; and training the early exits using only the pixels for which the prediction is correct.