-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
36 lines (28 loc) · 1.08 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from types import MethodType
from keras.models import Model
from keras.layers import Reshape, Activation
import keras.backend as K
#from train import train
#from predict import predict, predict_multiple, evaluate
def get_segmentation_model(input, output):
img_input = input
o = output
o_shape = Model(img_input, o).output_shape
i_shape = Model(img_input, o).input_shape
output_height = o_shape[1]
output_width = o_shape[2]
n_classes = o_shape[3]
o = Reshape((output_height * output_width, -1))(o)
o = Activation('softmax')(o)
model = Model(img_input, o)
model.output_width = output_width
model.output_height = output_height
model.n_classes = n_classes
model.input_height = i_shape[1]
model.input_width = i_shape[2]
model.model_name = ""
#model.train = MethodType(train, model)
#model.predict_segmentation = MethodType(predict, model)
#model.predict_multiple = MethodType(predict_multiple, model)
#smodel.evaluate_segmentation = MethodType(evaluate, model)
return model