-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackNet.py
More file actions
140 lines (102 loc) · 4.54 KB
/
Copy pathTrackNet.py
File metadata and controls
140 lines (102 loc) · 4.54 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from keras.models import *
from keras.layers import *
from keras.activations import *
def TrackNet( input_height, input_width ): #input_height = 288, input_width = 512
imgs_input = Input(shape=(9,input_height,input_width))
#Layer1
x = Conv2D(64, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(imgs_input)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer2
x = Conv2D(64, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x1 = ( BatchNormalization())(x)
#Layer3
x = MaxPooling2D((2, 2), strides=(2, 2), data_format='channels_first' )(x1)
#Layer4
x = Conv2D(128, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer5
x = Conv2D(128, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x2 = ( BatchNormalization())(x)
#Layer6
x = MaxPooling2D((2, 2), strides=(2, 2), data_format='channels_first' )(x2)
#Layer7
x = Conv2D(256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer8
x = Conv2D(256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer9
x = Conv2D(256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('relu'))(x)
x3 = ( BatchNormalization())(x)
#Layer10
x = MaxPooling2D((2, 2), strides=(2, 2), data_format='channels_first' )(x3)
#Layer11
x = ( Conv2D(512, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer12
x = ( Conv2D(512, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer13
x = ( Conv2D(512, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer14
x = concatenate( [UpSampling2D( (2,2), data_format='channels_first')(x), x3], axis=1)
#Layer15
x = ( Conv2D( 256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer16
x = ( Conv2D( 256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer17
x = ( Conv2D( 256, (3, 3), kernel_initializer='random_uniform', padding='same', data_format='channels_first'))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer18
x = concatenate( [UpSampling2D( (2,2), data_format='channels_first')(x), x2], axis=1)
#Layer19
x = ( Conv2D( 128 , (3, 3), kernel_initializer='random_uniform', padding='same' , data_format='channels_first' ))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer20
x = ( Conv2D( 128 , (3, 3), kernel_initializer='random_uniform', padding='same' , data_format='channels_first' ))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer21
x = concatenate( [UpSampling2D( (2,2), data_format='channels_first')(x), x1], axis=1)
#Layer22
x = ( Conv2D( 64 , (3, 3), kernel_initializer='random_uniform', padding='same' , data_format='channels_first' ))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer23
x = ( Conv2D( 64 , (3, 3), kernel_initializer='random_uniform', padding='same' , data_format='channels_first' ))(x)
x = ( Activation('relu'))(x)
x = ( BatchNormalization())(x)
#Layer24
x = Conv2D( 1 , (1, 1) , kernel_initializer='random_uniform', padding='same', data_format='channels_first' )(x)
x = ( Activation('sigmoid'))(x)
o_shape = Model(imgs_input , x ).output_shape
#print ("layer24 output shape:", o_shape[1],o_shape[2],o_shape[3])
#Layer24 output shape: (1, 288, 512)
OutputHeight = o_shape[2]
OutputWidth = o_shape[3]
#Reshape the size to (288, 512)
output = (Reshape((OutputHeight, OutputWidth)))(x)
model = Model( imgs_input , output)
#model input unit:9*288*512, output unit:288*512
model.outputWidth = OutputWidth
model.outputHeight = OutputHeight
#Show model's details
#model.summary()
return model