vgg16_fast_rcnn.py
Go to the documentation of this file.
00001 import chainer
00002 import chainer.functions as F
00003 import chainer.links as L
00004 
00005 from roi_pooling_2d import roi_pooling_2d
00006 
00007 
00008 class VGG16FastRCNN(chainer.Chain):
00009 
00010     def __init__(self):
00011         super(self.__class__, self).__init__(
00012             conv1_1=L.Convolution2D(3, 64, 3, stride=1, pad=1),
00013             conv1_2=L.Convolution2D(64, 64, 3, stride=1, pad=1),
00014 
00015             conv2_1=L.Convolution2D(64, 128, 3, stride=1, pad=1),
00016             conv2_2=L.Convolution2D(128, 128, 3, stride=1, pad=1),
00017 
00018             conv3_1=L.Convolution2D(128, 256, 3, stride=1, pad=1),
00019             conv3_2=L.Convolution2D(256, 256, 3, stride=1, pad=1),
00020             conv3_3=L.Convolution2D(256, 256, 3, stride=1, pad=1),
00021 
00022             conv4_1=L.Convolution2D(256, 512, 3, stride=1, pad=1),
00023             conv4_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
00024             conv4_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),
00025 
00026             conv5_1=L.Convolution2D(512, 512, 3, stride=1, pad=1),
00027             conv5_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
00028             conv5_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),
00029 
00030             fc6=L.Linear(25088, 4096),
00031             fc7=L.Linear(4096, 4096),
00032             cls_score=L.Linear(4096, 21),
00033             bbox_pred=L.Linear(4096, 84)
00034         )
00035         self.train = False
00036 
00037     def __call__(self, x, rois):
00038         h = F.relu(self.conv1_1(x))
00039         h = F.relu(self.conv1_2(h))
00040         h = F.max_pooling_2d(h, 2, stride=2)
00041 
00042         h = F.relu(self.conv2_1(h))
00043         h = F.relu(self.conv2_2(h))
00044         h = F.max_pooling_2d(h, 2, stride=2)
00045 
00046         h = F.relu(self.conv3_1(h))
00047         h = F.relu(self.conv3_2(h))
00048         h = F.relu(self.conv3_3(h))
00049         h = F.max_pooling_2d(h, 2, stride=2)
00050 
00051         h = F.relu(self.conv4_1(h))
00052         h = F.relu(self.conv4_2(h))
00053         h = F.relu(self.conv4_3(h))
00054         h = F.max_pooling_2d(h, 2, stride=2)
00055 
00056         h = F.relu(self.conv5_1(h))
00057         h = F.relu(self.conv5_2(h))
00058         h = F.relu(self.conv5_3(h))
00059         h = roi_pooling_2d(h, rois, 7, 7, spatial_scale=0.0625)
00060 
00061         h = F.dropout(F.relu(self.fc6(h)), train=self.train, ratio=0.5)
00062         h = F.dropout(F.relu(self.fc7(h)), train=self.train, ratio=0.5)
00063         cls_score = F.softmax(self.cls_score(h))
00064         bbox_pred = self.bbox_pred(h)
00065 
00066         return cls_score, bbox_pred


jsk_recognition_utils
Author(s):
autogenerated on Sun Oct 8 2017 02:42:48