pyramid pooling block from PSPNet Args: input_tensor: input to the pyramid pooling block bin_sizes: bin used to create pyramid Returns: concat_list: output from pyramid pooling block
(input_tensor, bin_sizes)
| 147 | return out |
| 148 | |
| 149 | def pyramid_pooling_block(input_tensor, bin_sizes): |
| 150 | """ |
| 151 | pyramid pooling block from PSPNet |
| 152 | Args: |
| 153 | input_tensor: input to the pyramid pooling block |
| 154 | bin_sizes: bin used to create pyramid |
| 155 | Returns: |
| 156 | concat_list: output from pyramid pooling block |
| 157 | """ |
| 158 | concat_list = [input_tensor] |
| 159 | width = 16 |
| 160 | height = 16 |
| 161 | for bin_size in bin_sizes: |
| 162 | out = tf.keras.layers.AveragePooling2D( |
| 163 | pool_size=(width // bin_size, height // bin_size), |
| 164 | strides=(width // bin_size, height // bin_size), |
| 165 | )(input_tensor) |
| 166 | out = tf.keras.layers.Conv2D(64, 3, 2, padding="same")(out) |
| 167 | out = tf.keras.layers.Lambda(lambda x: tf.image.resize(x, (width, height)))(out) |
| 168 | concat_list.append(out) |
| 169 | return tf.keras.layers.concatenate(concat_list) |
| 170 | |
| 171 | def tem_block(inputs): |
| 172 | """ |