| 6 | """ FeatureExtractor of CRNN (https://arxiv.org/pdf/1507.05717.pdf) """ |
| 7 | |
| 8 | def __init__(self, input_channel, output_channel=512): |
| 9 | super(VGG_FeatureExtractor, self).__init__() |
| 10 | self.output_channel = [int(output_channel / 8), int(output_channel / 4), |
| 11 | int(output_channel / 2), output_channel] # [64, 128, 256, 512] |
| 12 | self.ConvNet = nn.Sequential( |
| 13 | nn.Conv2d(input_channel, self.output_channel[0], 3, 1, 1), nn.ReLU(True), |
| 14 | nn.MaxPool2d(2, 2), # 64x16x50 |
| 15 | nn.Conv2d(self.output_channel[0], self.output_channel[1], 3, 1, 1), nn.ReLU(True), |
| 16 | nn.MaxPool2d(2, 2), # 128x8x25 |
| 17 | nn.Conv2d(self.output_channel[1], self.output_channel[2], 3, 1, 1), nn.ReLU(True), # 256x8x25 |
| 18 | nn.Conv2d(self.output_channel[2], self.output_channel[2], 3, 1, 1), nn.ReLU(True), |
| 19 | nn.MaxPool2d((2, 1), (2, 1)), # 256x4x25 |
| 20 | nn.Conv2d(self.output_channel[2], self.output_channel[3], 3, 1, 1, bias=False), |
| 21 | nn.BatchNorm2d(self.output_channel[3]), nn.ReLU(True), # 512x4x25 |
| 22 | nn.Conv2d(self.output_channel[3], self.output_channel[3], 3, 1, 1, bias=False), |
| 23 | nn.BatchNorm2d(self.output_channel[3]), nn.ReLU(True), |
| 24 | nn.MaxPool2d((2, 1), (2, 1)), # 512x2x25 |
| 25 | nn.Conv2d(self.output_channel[3], self.output_channel[3], 2, 1, 0), nn.ReLU(True)) # 512x1x24 |
| 26 | |
| 27 | def forward(self, input): |
| 28 | return self.ConvNet(input) |