-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalex_net.py
61 lines (42 loc) · 3.02 KB
/
alex_net.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
from model import BaseNet
import tensorflow as tf
class AlexNet(BaseNet):
def __init__(self,num_default_boxes,num_classes):
super().__init__(num_default_boxes,num_classes)
def graph(self,x,phase):
"""
Alex NET!
"""
y_predict_box_coords = []
y_predict_class = []
x= self.conv_layer_optional_pooling(x,96,(11,11),(4,4),"conv1", phase, padding_type= "SAME",pool_ksize=(3,3),pool_strides=(2,2),pool_name="pool1")
x= self.conv_layer_optional_pooling(x,192,(5,5),(1,1),"conv2", phase, padding_type= "SAME",pool_ksize=(3,3),pool_strides=(2,2),pool_name="pool2")
x= self.conv_layer_optional_pooling(x,384,(3,3),(1,1),"conv3",phase)
x= self.conv_layer_optional_pooling(x,384,(3,3),(1,1),"conv4",phase)
x= self.conv_layer_optional_pooling(x,256,(3,3),(1,1),"conv5", phase, padding_type= "SAME",pool_ksize=(3,3),pool_strides=(2,2),pool_name="pool5")
# Additional SSD Layers
# LAYERS FROM SSD PAPER
x = self.conv_layer_optional_pooling(x,1024,(3,3),(1,1),"conv6", phase, padding_type="SAME")
x = self.conv_layer_optional_pooling(x,1024,(1,1),(1,1),"conv7", phase, padding_type="SAME")
print("\n >>>>> FEATURE MAP 1:",x)
self.convolve_and_collect(x,"conv7_collect",y_predict_box_coords,y_predict_class,phase)
x = self.conv_layer_optional_pooling(x,256,(1,1),(1,1),"conv8", phase, padding_type="SAME")
x = self.conv_layer_optional_pooling(x,512,(3,3),(2,2),"conv9", phase, padding_type="SAME")
print("\n >>>>> FEATURE MAP 2:",x)
self.convolve_and_collect(x,"conv9_collect",y_predict_box_coords,y_predict_class,phase)
x = self.conv_layer_optional_pooling(x,128,(1,1),(1,1),"conv10", phase, padding_type="SAME")
x = self.conv_layer_optional_pooling(x,256,(3,3),(2,2),"conv11", phase, padding_type="SAME")
print("\n >>>>> FEATURE MAP 3:",x)
self.convolve_and_collect(x,"conv11_collect",y_predict_box_coords,y_predict_class,phase)
# Comment these out as pedestrians aren't going to be takeing up that much of the intput view.
x = self.conv_layer_optional_pooling(x,128,(1,1),(1,1),"conv12", phase, padding_type="SAME")
x = self.conv_layer_optional_pooling(x,256,(3,3),(2,2),"conv13", phase, padding_type="SAME")
print("\n >>>>> FEATURE MAP 4:",x)
self.convolve_and_collect(x,"conv13_collect",y_predict_box_coords,y_predict_class,phase)
print("ALEX Size OF BOX COORD PREDICT:",len(y_predict_box_coords))
print("ALEX Size OF CLASSES CREDIT:",len(y_predict_class))
y_predict_box_flat = tf.concat(y_predict_box_coords,1,name="y_predict_loc")
y_predict_class_flat = tf.concat(y_predict_class,1,name="y_predict_conf")
print("ALEX FLAT BOX COORD PREDICT:", y_predict_box_flat)
print("ALEX FLAT OF CLASSES CREDIT:", y_predict_class_flat)
return [y_predict_box_flat,y_predict_class_flat]