| 32 | """ FeatureExtractor of GRCNN (https://papers.nips.cc/paper/6637-gated-recurrent-convolution-neural-network-for-ocr.pdf) """ |
| 33 | |
| 34 | def __init__(self, input_channel, output_channel=512): |
| 35 | super(RCNN_FeatureExtractor, self).__init__() |
| 36 | self.output_channel = [int(output_channel / 8), int(output_channel / 4), |
| 37 | int(output_channel / 2), output_channel] # [64, 128, 256, 512] |
| 38 | self.ConvNet = nn.Sequential( |
| 39 | nn.Conv2d(input_channel, self.output_channel[0], 3, 1, 1), nn.ReLU(True), |
| 40 | nn.MaxPool2d(2, 2), # 64 x 16 x 50 |
| 41 | GRCL(self.output_channel[0], self.output_channel[0], num_iteration=5, kernel_size=3, pad=1), |
| 42 | nn.MaxPool2d(2, 2), # 64 x 8 x 25 |
| 43 | GRCL(self.output_channel[0], self.output_channel[1], num_iteration=5, kernel_size=3, pad=1), |
| 44 | nn.MaxPool2d(2, (2, 1), (0, 1)), # 128 x 4 x 26 |
| 45 | GRCL(self.output_channel[1], self.output_channel[2], num_iteration=5, kernel_size=3, pad=1), |
| 46 | nn.MaxPool2d(2, (2, 1), (0, 1)), # 256 x 2 x 27 |
| 47 | nn.Conv2d(self.output_channel[2], self.output_channel[3], 2, 1, 0, bias=False), |
| 48 | nn.BatchNorm2d(self.output_channel[3]), nn.ReLU(True)) # 512 x 1 x 26 |
| 49 | |
| 50 | def forward(self, input): |
| 51 | return self.ConvNet(input) |