-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefModel.py
68 lines (52 loc) · 2.12 KB
/
defModel.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 7 09:41:25 2020
@author: Ines
"""
from keras.models import Sequential
from keras.layers.convolutional import Conv2D
from keras.layers.convolutional import MaxPooling2D
from keras.layers import LeakyReLU
from keras.layers.core import Flatten
from keras.layers.core import Dense
import tensorflow as tf
def Model(INPUT_SHAPE,metric_iou):
model = Sequential()
model.add(Conv2D(16, kernel_size=(3, 3), padding = 'same', input_shape=(INPUT_SHAPE)))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(16, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(32, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(64, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(128, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(128, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(256, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(256, kernel_size=(3, 3), padding = 'same'))
model.add(LeakyReLU(alpha=0.2))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(256))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(128))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(6))
#bbox
#model_outputsB = model.add(Dense(4))
#size
#model_outputsS = model.add(Dense(2))
model.compile(optimizer=tf.keras.optimizers.RMSprop(lr=0.0001),loss='mean_squared_error',metrics=[metric_iou])
return model