Segnet is a deep network of image semantic segmentation proposed by Cambridge to solve the problem of automatic driving or intelligent robot. It refers to FCN and uses the indexed maxpooling layer as the down sample, while taking the index as the parameter to the maxunpooling layer as the up sample.
The SegNet paper introduces a encoder similar to VGG16. But with an additional BatchNormalization layer after each convolution layer compared to VGG16. I couldn't load weights directly from Keras team. Therefore, I delete the BatchNormalization layer to match the VGG16.
Model name | Dataset | MIoU | Pixel accuracy |
---|---|---|---|
SegNet_VGG16 | VOC train dataset | 0.9077 | 0.9817 |
VOC validation dataset | 0.5708 | 0.9224 |
- Pull this repository.
git clone https://github.com/verages/SegNet.git
- You need to install some dependency package.
cd SegNet-keras
pip installl -r requirements.txt
- Download the VOC dataset(VOC SegmetationClassAug if you need).
- Getting SegNet weights.
wget https://github.com/verages/SegNet/releases/download/v0.1/segnet_weights.h5
- Run predict.py, you'll see the result of SegNet.
python predict.py
Input image:
Output image(resize to 320 x 320):
- You should rewrite your data pipeline, Dateset where in dataset.py is the base class, such as VOCdataset.py.
class VOCDataset(Dataset):
def __init__(self, annotation_path, batch_size=4, target_size=(320, 320), num_classes=21, aug=False):
super().__init__(target_size, num_classes)
self.batch_size = batch_size
self.target_size = target_size
self.num_classes = num_classes
self.annotation_path = annotation_path
self.aug = aug
self.read_voc_annotation()
self.set_image_info()
- Start training.
python train.py
- Running evaluate.py to get mean iou and pixel accuracy.
python evaluate.py