def call(self, inputs, training=None, mask=None): x = compose(self.conv1, self.normalize1, self.activity1)(inputs) x = compose(self.conv2, self.normalize2, self.activity2)(x) x = compose(self.conv3, self.normalize3)(x) x = layers.add([x, inputs]) x = self.activity3(x) return x
def call(self, inputs, training=None, mask=None): x = compose(self.conv1, self.normalize1, self.activity1)(inputs) x = compose(self.conv2, self.normalize2, self.activity2)(x) x = compose(self.conv3, self.normalize3)(x) y = compose(self.conv4, self.normalize4)(inputs) z = layers.add([x, y]) z = self.activity4(z) return z
def YOLOv4(input_layer, NUM_CLASS): route_1, route_2, route_3 = cspdarknet53(input_layer) conv = YoloConv(filters=256, kernel_size=1)(route_3) conv = up_sample(conv) route_2 = YoloConv(filters=256, kernel_size=1)(route_2) # conv = tf.concat([route_2, conv], axis=-1) # conv = compose(YoloConv(filters=256, kernel_size=1), # YoloConv(filters=512, kernel_size=3), # YoloConv(filters=256, kernel_size=1), # YoloConv(filters=512, kernel_size=3), # YoloConv(filters=256, kernel_size=1))(conv) conv = YoloNeck(route_2, conv, filters=256) route_tmp = conv route_1 = YoloConv(filters=128, kernel_size=1)(route_1) conv = YoloConv(filters=128, kernel_size=1)(conv) conv = up_sample(conv) conv = YoloNeck(route_1, conv, filters=128) conv_sbbox = compose( YoloConv(filters=256, kernel_size=3), YoloConv(filters=3 * (NUM_CLASS + 5), kernel_size=1, activate=False, bn=False))(conv) conv = YoloConv(filters=256, kernel_size=3, down_sample=True)(conv) conv = YoloNeck(conv, route_tmp, filters=256) conv_mbbox = compose( YoloConv(filters=512, kernel_size=3), YoloConv(filters=3 * (NUM_CLASS + 5), kernel_size=1, activate=False, bn=False))(conv) conv = YoloConv(filters=512, kernel_size=3, down_sample=True)(conv) conv = YoloNeck(conv, route_3, filters=512) conv_lbbox = compose( YoloConv(filters=1024, kernel_size=3), YoloConv(filters=3 * (NUM_CLASS + 5), kernel_size=1, activate=False, bn=False))(conv) return [conv_sbbox, conv_mbbox, conv_lbbox]
def call(self, inputs, **kwargs): output = compose(*self.compose_list)(inputs) if self.activate: if self.activate_type == "leaky": output = tf.nn.leaky_relu(output, alpha=0.1) elif self.activate_type == "mish": output = mish(output) return output
def YoloNeck(conv, route_tmp, filters): conv = tf.concat([conv, route_tmp], axis=-1) conv = compose(YoloConv(filters=filters, kernel_size=1), YoloConv(filters=filters * 2, kernel_size=3), YoloConv(filters=filters, kernel_size=1), YoloConv(filters=filters * 2, kernel_size=3), YoloConv(filters=filters, kernel_size=1))(conv) return conv
def call(self, inputs, **kwargs): out0 = self.layer0(inputs) out1 = self.block1(out0) out2 = self.block2(out1) out3 = self.block3(out2) out4 = self.block4(out3) out5 = self.block5(out4) x = self.make_list[0][0](out5) y1 = compose(*self.make_list[0][1:])(x) x = compose(*self.conv_samp[0])(x) x = self.concat[0]([x, out4]) x = self.make_list[1][0](x) y2 = compose(*self.make_list[1][1:])(x) x = compose(*self.conv_samp[1])(x) x = self.concat[1]([x, out3]) x = self.make_list[2][0](x) y3 = compose(*self.make_list[2][1:])(x) return y1, y2, y3
def call(self, inputs, **kwargs): residual_output = inputs + compose(*self.compose_list)(inputs) return residual_output
def call(self, inputs, **kwargs): return compose(*self.conv_list)(inputs)
def call(self, inputs, **kwargs): output = compose(*self.compose_list)(inputs) return output
def call(self, inputs, **kwargs): x = compose(self.zero, self.conv)(inputs) for conv1, conv2, add in self.block_layers: y = compose(conv1, conv2)(x) x = add([x, y]) return x