Skip to content

Commit

Permalink
ssd
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYang1994 authored and YunYang1994 committed Nov 7, 2019
1 parent 101a696 commit 85af3f8
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions 4-Object_Detection/SSD/ssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,23 @@ def __init__(self, num_class=21):
self.conv5_3 = tf.keras.layers.Conv2D(512, 3, activation='relu', padding='same')
self.pool5 = tf.keras.layers.MaxPooling2D(3, strides=1, padding='same')

# fc6
# fc6, => vgg backbone is finished. now they are all SSD blocks
self.fc6 = tf.keras.layers.Conv2D(1024, 3, dilation_rate=6, activation='relu', padding='same')
# fc7
self.fc7 = tf.keras.layers.Conv2D(1024, 1, activation='relu', padding='same')

# Block 8/9/10/11: 1x1 and 3x3 convolutions strides 2 (except lasts)
# conv8
self.conv8_1 = tf.keras.layers.Conv2D(256, 1, activation='relu', padding='same')
self.conv8_2 = tf.keras.layers.Conv2D(512, 3, strides=2, activation='relu', padding='same')
# conv9
self.conv9_1 = tf.keras.layers.Conv2D(128, 1, activation='relu', padding='same')
self.conv9_2 = tf.keras.layers.Conv2D(256, 3, strides=2, activation='relu', padding='same')
# conv10
self.conv10_1 = tf.keras.layers.Conv2D(128, 1, activation='relu', padding='same')
self.conv10_2 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='valid')
# conv11
self.conv11_1 = tf.keras.layers.Conv2D(128, 1, activation='relu', padding='same')
self.conv11_2 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='valid')



Expand All @@ -71,18 +82,33 @@ def call(self, x, training=False):
h = self.conv4_1(h)
h = self.conv4_2(h)
h = self.conv4_3(h)
print(h.shape)
h = self.pool4(h)

h = self.conv5_1(h)
h = self.conv5_2(h)
h = self.conv5_3(h)
print(h.shape)
h = self.pool5(h)

h = self.fc6(h) # [1,19,19,1024]
h = self.fc7(h) # [1,19,19,1024]
print(h.shape)

h = self.conv8_1(h)
h = self.conv8_2(h) # [1,10,10, 512]
print(h.shape)
h = self.fc6(h)

h = self.conv9_1(h)
h = self.conv9_2(h) # [1, 5, 5, 256]
print(h.shape)
h = self.fc7(h)

h = self.conv10_1(h)
h = self.conv10_2(h) # [1, 3, 3, 256]
print(h.shape)

h = self.conv11_1(h)
h = self.conv11_2(h) # [1, 1, 1, 256]
print(h.shape)
return h

model = SSD(21)
Expand Down

0 comments on commit 85af3f8

Please sign in to comment.