├── .gitignore ├── LICENSE ├── SegNet-Basic.py ├── Segnet-Evaluation-Visualization.ipynb ├── camvid_data_loader.py ├── helper.py ├── imgs_results ├── real_road_scene.png └── segmented_road_scene.png ├── model-basic.py ├── model-full.py ├── readme.md ├── segNet_basic_model.json └── weights └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *,cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # dotenv 80 | .env 81 | 82 | # virtualenv 83 | .venv/ 84 | venv/ 85 | ENV/ 86 | 87 | # Spyder project settings 88 | .spyderproject 89 | 90 | # Rope project settings 91 | .ropeproject 92 | 93 | 94 | .DS_Store 95 | 96 | CamVid/ 97 | data/ 98 | 99 | *.hdf5 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2016] [Yad Faeq] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SegNet-Basic.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import print_function 3 | import os 4 | 5 | os.environ['KERAS_BACKEND'] = 'theano' 6 | os.environ['THEANO_FLAGS']='mode=FAST_RUN,device=gpu0,floatX=float32,optimizer=None' 7 | 8 | 9 | 10 | 11 | 12 | import keras.models as models 13 | from keras.layers.core import Layer, Dense, Dropout, Activation, Flatten, Reshape, Merge, Permute 14 | from keras.layers.convolutional import Convolution2D, MaxPooling2D, UpSampling2D, ZeroPadding2D 15 | from keras.layers.normalization import BatchNormalization 16 | from keras.callbacks import ModelCheckpoint 17 | 18 | from keras import backend as K 19 | 20 | import cv2 21 | import numpy as np 22 | import json 23 | np.random.seed(07) # 0bserver07 for reproducibility 24 | 25 | 26 | data_shape = 360*480 27 | 28 | class_weighting= [0.2595, 0.1826, 4.5640, 0.1417, 0.5051, 0.3826, 9.6446, 1.8418, 6.6823, 6.2478, 3.0, 7.3614] 29 | 30 | 31 | # load the data 32 | train_data = np.load('./data/train_data.npy') 33 | train_label = np.load('./data/train_label.npy') 34 | 35 | test_data = np.load('./data/test_data.npy') 36 | test_label = np.load('./data/test_label.npy') 37 | 38 | # load the model: 39 | with open('segNet_basic_model.json') as model_file: 40 | segnet_basic = models.model_from_json(model_file.read()) 41 | 42 | 43 | segnet_basic.compile(loss="categorical_crossentropy", optimizer='adadelta', metrics=["accuracy"]) 44 | 45 | # checkpoint 46 | filepath="weights.best.hdf5" 47 | checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max') 48 | callbacks_list = [checkpoint] 49 | 50 | nb_epoch = 100 51 | batch_size = 6 52 | 53 | # Fit the model 54 | history = segnet_basic.fit(train_data, train_label, callbacks=callbacks_list, batch_size=batch_size, nb_epoch=nb_epoch, 55 | verbose=1, class_weight=class_weighting , validation_data=(test_data, test_label), shuffle=True) # validation_split=0.33 56 | 57 | # This save the trained model weights to this file with number of epochs 58 | segnet_basic.save_weights('weights/model_weight_{}.hdf5'.format(nb_epoch)) 59 | 60 | -------------------------------------------------------------------------------- /camvid_data_loader.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import print_function 3 | 4 | import cv2 5 | import numpy as np 6 | import itertools 7 | 8 | from helper import * 9 | import os 10 | 11 | # Copy the data to this dir here in the SegNet project /CamVid from here: 12 | # https://github.com/alexgkendall/SegNet-Tutorial 13 | DataPath = './CamVid/' 14 | data_shape = 360*480 15 | 16 | 17 | def load_data(mode): 18 | data = [] 19 | label = [] 20 | with open(DataPath + mode +'.txt') as f: 21 | txt = f.readlines() 22 | txt = [line.split(' ') for line in txt] 23 | for i in range(len(txt)): 24 | data.append(np.rollaxis(normalized(cv2.imread(os.getcwd() + txt[i][0][7:])),2)) 25 | label.append(one_hot_it(cv2.imread(os.getcwd() + txt[i][1][7:][:-1])[:,:,0])) 26 | print('.',end='') 27 | return np.array(data), np.array(label) 28 | 29 | 30 | 31 | train_data, train_label = load_data("train") 32 | train_label = np.reshape(train_label,(367,data_shape,12)) 33 | 34 | test_data, test_label = load_data("test") 35 | test_label = np.reshape(test_label,(233,data_shape,12)) 36 | 37 | val_data, val_label = load_data("val") 38 | val_label = np.reshape(val_label,(101,data_shape,12)) 39 | 40 | 41 | np.save("data/train_data", train_data) 42 | np.save("data/train_label", train_label) 43 | 44 | np.save("data/test_data", test_data) 45 | np.save("data/test_label", test_label) 46 | 47 | np.save("data/val_data", val_data) 48 | np.save("data/val_label", val_label) 49 | 50 | # FYI they are: 51 | # Sky = [128,128,128] 52 | # Building = [128,0,0] 53 | # Pole = [192,192,128] 54 | # Road_marking = [255,69,0] 55 | # Road = [128,64,128] 56 | # Pavement = [60,40,222] 57 | # Tree = [128,128,0] 58 | # SignSymbol = [192,128,128] 59 | # Fence = [64,64,128] 60 | # Car = [64,0,128] 61 | # Pedestrian = [64,64,0] 62 | # Bicyclist = [0,128,192] 63 | # Unlabelled = [0,0,0] -------------------------------------------------------------------------------- /helper.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import print_function 3 | 4 | import cv2 5 | import numpy as np 6 | import itertools 7 | 8 | from helper import * 9 | import os 10 | 11 | def normalized(rgb): 12 | #return rgb/255.0 13 | norm=np.zeros((rgb.shape[0], rgb.shape[1], 3),np.float32) 14 | 15 | b=rgb[:,:,0] 16 | g=rgb[:,:,1] 17 | r=rgb[:,:,2] 18 | 19 | norm[:,:,0]=cv2.equalizeHist(b) 20 | norm[:,:,1]=cv2.equalizeHist(g) 21 | norm[:,:,2]=cv2.equalizeHist(r) 22 | 23 | return norm 24 | 25 | def one_hot_it(labels): 26 | x = np.zeros([360,480,12]) 27 | for i in range(360): 28 | for j in range(480): 29 | x[i,j,labels[i][j]]=1 30 | return x 31 | -------------------------------------------------------------------------------- /imgs_results/real_road_scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Keras-SegNet-Basic/41746f3f53aea0881b6489b958c9fd3873759b6b/imgs_results/real_road_scene.png -------------------------------------------------------------------------------- /imgs_results/segmented_road_scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Keras-SegNet-Basic/41746f3f53aea0881b6489b958c9fd3873759b6b/imgs_results/segmented_road_scene.png -------------------------------------------------------------------------------- /model-basic.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import print_function 3 | import os 4 | 5 | 6 | import keras.models as models 7 | from keras.layers.core import Layer, Dense, Dropout, Activation, Flatten, Reshape, Merge, Permute 8 | from keras.layers.convolutional import Convolution2D, MaxPooling2D, UpSampling2D, ZeroPadding2D 9 | from keras.layers.normalization import BatchNormalization 10 | 11 | 12 | from keras import backend as K 13 | 14 | import cv2 15 | import numpy as np 16 | import json 17 | np.random.seed(07) # 0bserver07 for reproducibility 18 | 19 | data_shape = 360*480 20 | 21 | 22 | 23 | def create_encoding_layers(): 24 | kernel = 3 25 | filter_size = 64 26 | pad = 1 27 | pool_size = 2 28 | return [ 29 | ZeroPadding2D(padding=(pad,pad)), 30 | Convolution2D(filter_size, kernel, kernel, border_mode='valid'), 31 | BatchNormalization(), 32 | Activation('relu'), 33 | MaxPooling2D(pool_size=(pool_size, pool_size)), 34 | 35 | ZeroPadding2D(padding=(pad,pad)), 36 | Convolution2D(128, kernel, kernel, border_mode='valid'), 37 | BatchNormalization(), 38 | Activation('relu'), 39 | MaxPooling2D(pool_size=(pool_size, pool_size)), 40 | 41 | ZeroPadding2D(padding=(pad,pad)), 42 | Convolution2D(256, kernel, kernel, border_mode='valid'), 43 | BatchNormalization(), 44 | Activation('relu'), 45 | MaxPooling2D(pool_size=(pool_size, pool_size)), 46 | 47 | ZeroPadding2D(padding=(pad,pad)), 48 | Convolution2D(512, kernel, kernel, border_mode='valid'), 49 | BatchNormalization(), 50 | Activation('relu'), 51 | ] 52 | 53 | def create_decoding_layers(): 54 | kernel = 3 55 | filter_size = 64 56 | pad = 1 57 | pool_size = 2 58 | return[ 59 | ZeroPadding2D(padding=(pad,pad)), 60 | Convolution2D(512, kernel, kernel, border_mode='valid'), 61 | BatchNormalization(), 62 | 63 | UpSampling2D(size=(pool_size,pool_size)), 64 | ZeroPadding2D(padding=(pad,pad)), 65 | Convolution2D(256, kernel, kernel, border_mode='valid'), 66 | BatchNormalization(), 67 | 68 | UpSampling2D(size=(pool_size,pool_size)), 69 | ZeroPadding2D(padding=(pad,pad)), 70 | Convolution2D(128, kernel, kernel, border_mode='valid'), 71 | BatchNormalization(), 72 | 73 | UpSampling2D(size=(pool_size,pool_size)), 74 | ZeroPadding2D(padding=(pad,pad)), 75 | Convolution2D(filter_size, kernel, kernel, border_mode='valid'), 76 | BatchNormalization(), 77 | ] 78 | 79 | 80 | 81 | 82 | segnet_basic = models.Sequential() 83 | 84 | segnet_basic.add(Layer(input_shape=(3, 360, 480))) 85 | 86 | 87 | 88 | segnet_basic.encoding_layers = create_encoding_layers() 89 | for l in segnet_basic.encoding_layers: 90 | segnet_basic.add(l) 91 | 92 | # Note: it this looks weird, that is because of adding Each Layer using that for loop 93 | # instead of re-writting mode.add(somelayer+params) everytime. 94 | 95 | segnet_basic.decoding_layers = create_decoding_layers() 96 | for l in segnet_basic.decoding_layers: 97 | segnet_basic.add(l) 98 | 99 | segnet_basic.add(Convolution2D(12, 1, 1, border_mode='valid',)) 100 | 101 | segnet_basic.add(Reshape((12,data_shape), input_shape=(12,360,480))) 102 | segnet_basic.add(Permute((2, 1))) 103 | segnet_basic.add(Activation('softmax')) 104 | 105 | 106 | 107 | # Save model to JSON 108 | 109 | with open('segNet_basic_model.json', 'w') as outfile: 110 | outfile.write(json.dumps(json.loads(segnet_basic.to_json()), indent=2)) -------------------------------------------------------------------------------- /model-full.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import print_function 3 | import os 4 | 5 | 6 | import keras.models as models 7 | from keras.layers.core import Layer, Dense, Dropout, Activation, Flatten, Reshape, Merge, Permute 8 | from keras.layers.convolutional import Convolution2D, MaxPooling2D, UpSampling2D, ZeroPadding2D 9 | from keras.layers.normalization import BatchNormalization 10 | 11 | 12 | from keras import backend as K 13 | 14 | import cv2 15 | import numpy as np 16 | import json 17 | np.random.seed(07) # 0bserver07 for reproducibility 18 | 19 | 20 | img_w = 480 21 | img_h = 360 22 | n_labels = 12 23 | 24 | kernel = 3 25 | pad = 1 26 | pool_size = 2 27 | 28 | encoding_layers = [ 29 | Convolution2D(64, kernel, kernel, border_mode='same'), 30 | BatchNormalization(), 31 | Activation('relu'), 32 | Convolution2D(64, kernel, kernel, border_mode='same'), 33 | BatchNormalization(), 34 | Activation('relu'), 35 | MaxPooling2D(pool_size=(pool_size, pool_size)), 36 | 37 | Convolution2D(128, kernel, kernel, border_mode='same'), 38 | BatchNormalization(), 39 | Activation('relu'), 40 | Convolution2D(128, kernel, kernel, border_mode='same'), 41 | BatchNormalization(), 42 | Activation('relu'), 43 | MaxPooling2D(pool_size=(pool_size, pool_size)), 44 | 45 | Convolution2D(256, kernel, kernel, border_mode='same'), 46 | BatchNormalization(), 47 | Activation('relu'), 48 | Convolution2D(256, kernel, kernel, border_mode='same'), 49 | BatchNormalization(), 50 | Activation('relu'), 51 | Convolution2D(256, kernel, kernel, border_mode='same'), 52 | BatchNormalization(), 53 | Activation('relu'), 54 | MaxPooling2D(pool_size=(pool_size, pool_size)), 55 | 56 | Convolution2D(512, kernel, kernel, border_mode='same'), 57 | BatchNormalization(), 58 | Activation('relu'), 59 | Convolution2D(512, kernel, kernel, border_mode='same'), 60 | BatchNormalization(), 61 | Activation('relu'), 62 | Convolution2D(512, kernel, kernel, border_mode='same'), 63 | BatchNormalization(), 64 | Activation('relu'), 65 | MaxPooling2D(pool_size=(pool_size, pool_size)), 66 | 67 | Convolution2D(512, kernel, kernel, border_mode='same'), 68 | BatchNormalization(), 69 | Activation('relu'), 70 | Convolution2D(512, kernel, kernel, border_mode='same'), 71 | BatchNormalization(), 72 | Activation('relu'), 73 | Convolution2D(512, kernel, kernel, border_mode='same'), 74 | BatchNormalization(), 75 | Activation('relu'), 76 | MaxPooling2D(pool_size=(pool_size, pool_size)), 77 | ] 78 | 79 | decoding_layers = [ 80 | UpSampling2D(size=(pool_size,pool_size)), 81 | Convolution2D(512, kernel, kernel, border_mode='same'), 82 | BatchNormalization(), 83 | Activation('relu'), 84 | Convolution2D(512, kernel, kernel, border_mode='same'), 85 | BatchNormalization(), 86 | Activation('relu'), 87 | Convolution2D(512, kernel, kernel, border_mode='same'), 88 | BatchNormalization(), 89 | Activation('relu'), 90 | 91 | UpSampling2D(size=(pool_size,pool_size)), 92 | Convolution2D(512, kernel, kernel, border_mode='same'), 93 | BatchNormalization(), 94 | Activation('relu'), 95 | Convolution2D(512, kernel, kernel, border_mode='same'), 96 | BatchNormalization(), 97 | Activation('relu'), 98 | Convolution2D(256, kernel, kernel, border_mode='same'), 99 | BatchNormalization(), 100 | Activation('relu'), 101 | 102 | UpSampling2D(size=(pool_size,pool_size)), 103 | Convolution2D(256, kernel, kernel, border_mode='same'), 104 | BatchNormalization(), 105 | Activation('relu'), 106 | Convolution2D(256, kernel, kernel, border_mode='same'), 107 | BatchNormalization(), 108 | Activation('relu'), 109 | Convolution2D(128, kernel, kernel, border_mode='same'), 110 | BatchNormalization(), 111 | Activation('relu'), 112 | 113 | UpSampling2D(size=(pool_size,pool_size)), 114 | Convolution2D(128, kernel, kernel, border_mode='same'), 115 | BatchNormalization(), 116 | Activation('relu'), 117 | Convolution2D(64, kernel, kernel, border_mode='same'), 118 | BatchNormalization(), 119 | Activation('relu'), 120 | 121 | UpSampling2D(size=(pool_size,pool_size)), 122 | Convolution2D(64, kernel, kernel, border_mode='same'), 123 | BatchNormalization(), 124 | Activation('relu'), 125 | Convolution2D(n_labels, 1, 1, border_mode='valid'), 126 | BatchNormalization(), 127 | ] 128 | 129 | 130 | segnet_basic = models.Sequential() 131 | 132 | segnet_basic.add(Layer(input_shape=(3, 360, 480))) 133 | 134 | 135 | segnet_basic.encoding_layers = encoding_layers 136 | for l in segnet_basic.encoding_layers: 137 | segnet_basic.add(l) 138 | 139 | 140 | segnet_basic.decoding_layers = decoding_layers 141 | for l in segnet_basic.decoding_layers: 142 | segnet_basic.add(l) 143 | 144 | 145 | segnet_basic.add(Reshape((n_labels, img_h * img_w), input_shape=(12,img_h, img_w))) 146 | segnet_basic.add(Permute((2, 1))) 147 | segnet_basic.add(Activation('softmax')) 148 | 149 | with open('segNet_full_model.json', 'w') as outfile: 150 | outfile.write(json.dumps(json.loads(segnet_basic.to_json()), indent=2)) 151 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ### SegNet-Basic: 2 | --- 3 | 4 | What is Segnet? 5 | 6 | * Deep Convolutional Encoder-Decoder Architecture for Semantic Pixel-wise Image Segmentation 7 | 8 | **Segnet** = **(Encoder + Decoder)** + **Pixel-Wise Classification** layer 9 | 10 | ##### *[SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation (Vijay Badrinarayanan, Alex Kendall, Roberto Cipolla, Senior Member, IEEE) arXiv:1511.00561v3](https://arxiv.org/abs/1511.00561)* 11 | 12 | 13 | What is SegNet-Basic? 14 | 15 | * *"In order to analyse SegNet and compare its performance with FCN (decoder variants) we use a smaller version of SegNet, termed SegNet-Basic , which ha 4 encoders and 4 decoders. All the encoders in SegNet-Basic perform max-pooling and subsampling and the corresponding decoders upsample its input using the received max-pooling indices."* 16 | 17 | Basically it's a mini-segnet to experiment / test the architecure with convnets, such as FCN. 18 | 19 | 20 | ----- 21 | 22 | ### Steps To Run The Model: 23 | --- 24 | 25 | 1. Run `python model-basic.py` to create `segNet_basic_model` for keras to use. 26 | 27 | * `model-basic.py` contains the architecure. 28 | 29 | 2. 30 | 31 | 32 | 33 | ### Dataset: 34 | --- 35 | 36 | 1. In a different directory run this to download the [dataset from original Implementation](https://github.com/alexgkendall/SegNet-Tutorial). 37 | * `git clone git@github.com:alexgkendall/SegNet-Tutorial.git` 38 | * copy the `/CamVid` to here, or change the `DataPath` in `data_loader.py` to the above directory 39 | 2. The run `python data_loader.py` to generate these two files: 40 | 41 | * `/data/train_data.npz/` and `/data/train_label.npz` 42 | * This will make it easy to process the model over and over, rather than waiting the data to be loaded into memory. 43 | 44 | 45 | 46 | ---- 47 | 48 | 49 | ### To Do: 50 | ---- 51 | 52 | [x] SegNet-Basic 53 | [ ] SegNet 54 | [x] Test Accuracy 55 | [ ] Requirements 56 | 57 | 58 | ### Segnet-Basic Road Scene Results: 59 | -------- 60 | 61 | * Train / Test: 62 | 63 | ``` 64 | Train on 367 samples, validate on 233 samples 65 | Epoch 101/102 66 | 366/367 [============================>.] 67 | - ETA: 0s - loss: 0.3835 - acc: 0.8737Epoch 00000: val_acc improved from -inf to 0.76367, saving model to weights.best.hdf5 68 | 367/367 [==============================] 69 | - 231s - loss: 0.3832 - acc: 0.8738 - val_loss: 0.7655 - val_acc: 0.7637 70 | Epoch 102/102 71 | 366/367 [============================>.] 72 | - ETA: 0s - loss: 0.3589 - acc: 0.8809Epoch 00001: val_acc did not improve 73 | 367/367 [==============================] 74 | - 231s - loss: 0.3586 - acc: 0.8810 - val_loss: 2.4447 - val_acc: 0.4478 75 | ``` 76 | 77 | 78 | * Evaluation: 79 | 80 | 81 | `acc: 85.47%` 82 | 83 | 84 | ![img1](./imgs_results/segmented_road_scene.png) 85 | 86 | 87 | ![img2](./imgs_results/real_road_scene.png) 88 | -------------------------------------------------------------------------------- /segNet_basic_model.json: -------------------------------------------------------------------------------- 1 | { 2 | "class_name": "Sequential", 3 | "keras_version": "1.1.1", 4 | "config": [ 5 | { 6 | "class_name": "Layer", 7 | "config": { 8 | "batch_input_shape": [ 9 | null, 10 | 3, 11 | 360, 12 | 480 13 | ], 14 | "trainable": true, 15 | "name": "layer_1", 16 | "input_dtype": "float32" 17 | } 18 | }, 19 | { 20 | "class_name": "ZeroPadding2D", 21 | "config": { 22 | "padding": [ 23 | 1, 24 | 1 25 | ], 26 | "trainable": true, 27 | "name": "zeropadding2d_1" 28 | } 29 | }, 30 | { 31 | "class_name": "Convolution2D", 32 | "config": { 33 | "W_constraint": null, 34 | "b_constraint": null, 35 | "name": "convolution2d_1", 36 | "activity_regularizer": null, 37 | "trainable": true, 38 | "dim_ordering": "th", 39 | "nb_col": 3, 40 | "subsample": [ 41 | 1, 42 | 1 43 | ], 44 | "init": "glorot_uniform", 45 | "bias": true, 46 | "nb_filter": 64, 47 | "b_regularizer": null, 48 | "W_regularizer": null, 49 | "nb_row": 3, 50 | "activation": "linear", 51 | "border_mode": "valid" 52 | } 53 | }, 54 | { 55 | "class_name": "BatchNormalization", 56 | "config": { 57 | "gamma_regularizer": null, 58 | "name": "batchnormalization_1", 59 | "epsilon": 1e-05, 60 | "trainable": true, 61 | "mode": 0, 62 | "beta_regularizer": null, 63 | "momentum": 0.99, 64 | "axis": -1 65 | } 66 | }, 67 | { 68 | "class_name": "Activation", 69 | "config": { 70 | "activation": "relu", 71 | "trainable": true, 72 | "name": "activation_1" 73 | } 74 | }, 75 | { 76 | "class_name": "MaxPooling2D", 77 | "config": { 78 | "name": "maxpooling2d_1", 79 | "trainable": true, 80 | "dim_ordering": "th", 81 | "pool_size": [ 82 | 2, 83 | 2 84 | ], 85 | "strides": [ 86 | 2, 87 | 2 88 | ], 89 | "border_mode": "valid" 90 | } 91 | }, 92 | { 93 | "class_name": "ZeroPadding2D", 94 | "config": { 95 | "padding": [ 96 | 1, 97 | 1 98 | ], 99 | "trainable": true, 100 | "name": "zeropadding2d_2" 101 | } 102 | }, 103 | { 104 | "class_name": "Convolution2D", 105 | "config": { 106 | "W_constraint": null, 107 | "b_constraint": null, 108 | "name": "convolution2d_2", 109 | "activity_regularizer": null, 110 | "trainable": true, 111 | "dim_ordering": "th", 112 | "nb_col": 3, 113 | "subsample": [ 114 | 1, 115 | 1 116 | ], 117 | "init": "glorot_uniform", 118 | "bias": true, 119 | "nb_filter": 128, 120 | "b_regularizer": null, 121 | "W_regularizer": null, 122 | "nb_row": 3, 123 | "activation": "linear", 124 | "border_mode": "valid" 125 | } 126 | }, 127 | { 128 | "class_name": "BatchNormalization", 129 | "config": { 130 | "gamma_regularizer": null, 131 | "name": "batchnormalization_2", 132 | "epsilon": 1e-05, 133 | "trainable": true, 134 | "mode": 0, 135 | "beta_regularizer": null, 136 | "momentum": 0.99, 137 | "axis": -1 138 | } 139 | }, 140 | { 141 | "class_name": "Activation", 142 | "config": { 143 | "activation": "relu", 144 | "trainable": true, 145 | "name": "activation_2" 146 | } 147 | }, 148 | { 149 | "class_name": "MaxPooling2D", 150 | "config": { 151 | "name": "maxpooling2d_2", 152 | "trainable": true, 153 | "dim_ordering": "th", 154 | "pool_size": [ 155 | 2, 156 | 2 157 | ], 158 | "strides": [ 159 | 2, 160 | 2 161 | ], 162 | "border_mode": "valid" 163 | } 164 | }, 165 | { 166 | "class_name": "ZeroPadding2D", 167 | "config": { 168 | "padding": [ 169 | 1, 170 | 1 171 | ], 172 | "trainable": true, 173 | "name": "zeropadding2d_3" 174 | } 175 | }, 176 | { 177 | "class_name": "Convolution2D", 178 | "config": { 179 | "W_constraint": null, 180 | "b_constraint": null, 181 | "name": "convolution2d_3", 182 | "activity_regularizer": null, 183 | "trainable": true, 184 | "dim_ordering": "th", 185 | "nb_col": 3, 186 | "subsample": [ 187 | 1, 188 | 1 189 | ], 190 | "init": "glorot_uniform", 191 | "bias": true, 192 | "nb_filter": 256, 193 | "b_regularizer": null, 194 | "W_regularizer": null, 195 | "nb_row": 3, 196 | "activation": "linear", 197 | "border_mode": "valid" 198 | } 199 | }, 200 | { 201 | "class_name": "BatchNormalization", 202 | "config": { 203 | "gamma_regularizer": null, 204 | "name": "batchnormalization_3", 205 | "epsilon": 1e-05, 206 | "trainable": true, 207 | "mode": 0, 208 | "beta_regularizer": null, 209 | "momentum": 0.99, 210 | "axis": -1 211 | } 212 | }, 213 | { 214 | "class_name": "Activation", 215 | "config": { 216 | "activation": "relu", 217 | "trainable": true, 218 | "name": "activation_3" 219 | } 220 | }, 221 | { 222 | "class_name": "MaxPooling2D", 223 | "config": { 224 | "name": "maxpooling2d_3", 225 | "trainable": true, 226 | "dim_ordering": "th", 227 | "pool_size": [ 228 | 2, 229 | 2 230 | ], 231 | "strides": [ 232 | 2, 233 | 2 234 | ], 235 | "border_mode": "valid" 236 | } 237 | }, 238 | { 239 | "class_name": "ZeroPadding2D", 240 | "config": { 241 | "padding": [ 242 | 1, 243 | 1 244 | ], 245 | "trainable": true, 246 | "name": "zeropadding2d_4" 247 | } 248 | }, 249 | { 250 | "class_name": "Convolution2D", 251 | "config": { 252 | "W_constraint": null, 253 | "b_constraint": null, 254 | "name": "convolution2d_4", 255 | "activity_regularizer": null, 256 | "trainable": true, 257 | "dim_ordering": "th", 258 | "nb_col": 3, 259 | "subsample": [ 260 | 1, 261 | 1 262 | ], 263 | "init": "glorot_uniform", 264 | "bias": true, 265 | "nb_filter": 512, 266 | "b_regularizer": null, 267 | "W_regularizer": null, 268 | "nb_row": 3, 269 | "activation": "linear", 270 | "border_mode": "valid" 271 | } 272 | }, 273 | { 274 | "class_name": "BatchNormalization", 275 | "config": { 276 | "gamma_regularizer": null, 277 | "name": "batchnormalization_4", 278 | "epsilon": 1e-05, 279 | "trainable": true, 280 | "mode": 0, 281 | "beta_regularizer": null, 282 | "momentum": 0.99, 283 | "axis": -1 284 | } 285 | }, 286 | { 287 | "class_name": "Activation", 288 | "config": { 289 | "activation": "relu", 290 | "trainable": true, 291 | "name": "activation_4" 292 | } 293 | }, 294 | { 295 | "class_name": "ZeroPadding2D", 296 | "config": { 297 | "padding": [ 298 | 1, 299 | 1 300 | ], 301 | "trainable": true, 302 | "name": "zeropadding2d_5" 303 | } 304 | }, 305 | { 306 | "class_name": "Convolution2D", 307 | "config": { 308 | "W_constraint": null, 309 | "b_constraint": null, 310 | "name": "convolution2d_5", 311 | "activity_regularizer": null, 312 | "trainable": true, 313 | "dim_ordering": "th", 314 | "nb_col": 3, 315 | "subsample": [ 316 | 1, 317 | 1 318 | ], 319 | "init": "glorot_uniform", 320 | "bias": true, 321 | "nb_filter": 512, 322 | "b_regularizer": null, 323 | "W_regularizer": null, 324 | "nb_row": 3, 325 | "activation": "linear", 326 | "border_mode": "valid" 327 | } 328 | }, 329 | { 330 | "class_name": "BatchNormalization", 331 | "config": { 332 | "gamma_regularizer": null, 333 | "name": "batchnormalization_5", 334 | "epsilon": 1e-05, 335 | "trainable": true, 336 | "mode": 0, 337 | "beta_regularizer": null, 338 | "momentum": 0.99, 339 | "axis": -1 340 | } 341 | }, 342 | { 343 | "class_name": "UpSampling2D", 344 | "config": { 345 | "trainable": true, 346 | "name": "upsampling2d_1", 347 | "size": [ 348 | 2, 349 | 2 350 | ] 351 | } 352 | }, 353 | { 354 | "class_name": "ZeroPadding2D", 355 | "config": { 356 | "padding": [ 357 | 1, 358 | 1 359 | ], 360 | "trainable": true, 361 | "name": "zeropadding2d_6" 362 | } 363 | }, 364 | { 365 | "class_name": "Convolution2D", 366 | "config": { 367 | "W_constraint": null, 368 | "b_constraint": null, 369 | "name": "convolution2d_6", 370 | "activity_regularizer": null, 371 | "trainable": true, 372 | "dim_ordering": "th", 373 | "nb_col": 3, 374 | "subsample": [ 375 | 1, 376 | 1 377 | ], 378 | "init": "glorot_uniform", 379 | "bias": true, 380 | "nb_filter": 256, 381 | "b_regularizer": null, 382 | "W_regularizer": null, 383 | "nb_row": 3, 384 | "activation": "linear", 385 | "border_mode": "valid" 386 | } 387 | }, 388 | { 389 | "class_name": "BatchNormalization", 390 | "config": { 391 | "gamma_regularizer": null, 392 | "name": "batchnormalization_6", 393 | "epsilon": 1e-05, 394 | "trainable": true, 395 | "mode": 0, 396 | "beta_regularizer": null, 397 | "momentum": 0.99, 398 | "axis": -1 399 | } 400 | }, 401 | { 402 | "class_name": "UpSampling2D", 403 | "config": { 404 | "trainable": true, 405 | "name": "upsampling2d_2", 406 | "size": [ 407 | 2, 408 | 2 409 | ] 410 | } 411 | }, 412 | { 413 | "class_name": "ZeroPadding2D", 414 | "config": { 415 | "padding": [ 416 | 1, 417 | 1 418 | ], 419 | "trainable": true, 420 | "name": "zeropadding2d_7" 421 | } 422 | }, 423 | { 424 | "class_name": "Convolution2D", 425 | "config": { 426 | "W_constraint": null, 427 | "b_constraint": null, 428 | "name": "convolution2d_7", 429 | "activity_regularizer": null, 430 | "trainable": true, 431 | "dim_ordering": "th", 432 | "nb_col": 3, 433 | "subsample": [ 434 | 1, 435 | 1 436 | ], 437 | "init": "glorot_uniform", 438 | "bias": true, 439 | "nb_filter": 128, 440 | "b_regularizer": null, 441 | "W_regularizer": null, 442 | "nb_row": 3, 443 | "activation": "linear", 444 | "border_mode": "valid" 445 | } 446 | }, 447 | { 448 | "class_name": "BatchNormalization", 449 | "config": { 450 | "gamma_regularizer": null, 451 | "name": "batchnormalization_7", 452 | "epsilon": 1e-05, 453 | "trainable": true, 454 | "mode": 0, 455 | "beta_regularizer": null, 456 | "momentum": 0.99, 457 | "axis": -1 458 | } 459 | }, 460 | { 461 | "class_name": "UpSampling2D", 462 | "config": { 463 | "trainable": true, 464 | "name": "upsampling2d_3", 465 | "size": [ 466 | 2, 467 | 2 468 | ] 469 | } 470 | }, 471 | { 472 | "class_name": "ZeroPadding2D", 473 | "config": { 474 | "padding": [ 475 | 1, 476 | 1 477 | ], 478 | "trainable": true, 479 | "name": "zeropadding2d_8" 480 | } 481 | }, 482 | { 483 | "class_name": "Convolution2D", 484 | "config": { 485 | "W_constraint": null, 486 | "b_constraint": null, 487 | "name": "convolution2d_8", 488 | "activity_regularizer": null, 489 | "trainable": true, 490 | "dim_ordering": "th", 491 | "nb_col": 3, 492 | "subsample": [ 493 | 1, 494 | 1 495 | ], 496 | "init": "glorot_uniform", 497 | "bias": true, 498 | "nb_filter": 64, 499 | "b_regularizer": null, 500 | "W_regularizer": null, 501 | "nb_row": 3, 502 | "activation": "linear", 503 | "border_mode": "valid" 504 | } 505 | }, 506 | { 507 | "class_name": "BatchNormalization", 508 | "config": { 509 | "gamma_regularizer": null, 510 | "name": "batchnormalization_8", 511 | "epsilon": 1e-05, 512 | "trainable": true, 513 | "mode": 0, 514 | "beta_regularizer": null, 515 | "momentum": 0.99, 516 | "axis": -1 517 | } 518 | }, 519 | { 520 | "class_name": "Convolution2D", 521 | "config": { 522 | "W_constraint": null, 523 | "b_constraint": null, 524 | "name": "convolution2d_9", 525 | "activity_regularizer": null, 526 | "trainable": true, 527 | "dim_ordering": "th", 528 | "nb_col": 1, 529 | "subsample": [ 530 | 1, 531 | 1 532 | ], 533 | "init": "glorot_uniform", 534 | "bias": true, 535 | "nb_filter": 12, 536 | "b_regularizer": null, 537 | "W_regularizer": null, 538 | "nb_row": 1, 539 | "activation": "linear", 540 | "border_mode": "valid" 541 | } 542 | }, 543 | { 544 | "class_name": "Reshape", 545 | "config": { 546 | "target_shape": [ 547 | 12, 548 | 172800 549 | ], 550 | "batch_input_shape": [ 551 | null, 552 | 12, 553 | 360, 554 | 480 555 | ], 556 | "trainable": true, 557 | "name": "reshape_1", 558 | "input_dtype": "float32" 559 | } 560 | }, 561 | { 562 | "class_name": "Permute", 563 | "config": { 564 | "dims": [ 565 | 2, 566 | 1 567 | ], 568 | "trainable": true, 569 | "name": "permute_1" 570 | } 571 | }, 572 | { 573 | "class_name": "Activation", 574 | "config": { 575 | "activation": "softmax", 576 | "trainable": true, 577 | "name": "activation_5" 578 | } 579 | } 580 | ] 581 | } -------------------------------------------------------------------------------- /weights/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Keras-SegNet-Basic/41746f3f53aea0881b6489b958c9fd3873759b6b/weights/.keep --------------------------------------------------------------------------------