Best Python code snippet using localstack_python
backbone.py
Source:backbone.py
1#! /usr/bin/env python2# coding=utf-83import tensorflow as tf4import core.common as common5def darknet53(input_data):6 input_data = common.convolutional(input_data, (3, 3, 3, 32))7 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True)8 for i in range(1):9 input_data = common.residual_block(input_data, 64, 32, 64)10 input_data = common.convolutional(input_data, (3, 3, 64, 128), downsample=True)11 for i in range(2):12 input_data = common.residual_block(input_data, 128, 64, 128)13 input_data = common.convolutional(input_data, (3, 3, 128, 256), downsample=True)14 for i in range(8):15 input_data = common.residual_block(input_data, 256, 128, 256)16 route_1 = input_data17 input_data = common.convolutional(input_data, (3, 3, 256, 512), downsample=True)18 for i in range(8):19 input_data = common.residual_block(input_data, 512, 256, 512)20 route_2 = input_data21 input_data = common.convolutional(input_data, (3, 3, 512, 1024), downsample=True)22 for i in range(4):23 input_data = common.residual_block(input_data, 1024, 512, 1024)24 return route_1, route_2, input_data25def cspdarknet53(input_data):26 input_data = common.convolutional(input_data, (3, 3, 3, 32), activate_type="mish")27 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True, activate_type="mish")28 route = input_data29 route = common.convolutional(route, (1, 1, 64, 64), activate_type="mish")30 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")31 for i in range(1):32 input_data = common.residual_block(input_data, 64, 32, 64, activate_type="mish")33 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")34 input_data = tf.concat([input_data, route], axis=-1)35 input_data = common.convolutional(input_data, (1, 1, 128, 64), activate_type="mish")36 input_data = common.convolutional(input_data, (3, 3, 64, 128), downsample=True, activate_type="mish")37 route = input_data38 route = common.convolutional(route, (1, 1, 128, 64), activate_type="mish")39 input_data = common.convolutional(input_data, (1, 1, 128, 64), activate_type="mish")40 for i in range(2):41 input_data = common.residual_block(input_data, 64, 64, 64, activate_type="mish")42 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")43 input_data = tf.concat([input_data, route], axis=-1)44 input_data = common.convolutional(input_data, (1, 1, 128, 128), activate_type="mish")45 input_data = common.convolutional(input_data, (3, 3, 128, 256), downsample=True, activate_type="mish")46 route = input_data47 route = common.convolutional(route, (1, 1, 256, 128), activate_type="mish")48 input_data = common.convolutional(input_data, (1, 1, 256, 128), activate_type="mish")49 for i in range(8):50 input_data = common.residual_block(input_data, 128, 128, 128, activate_type="mish")51 input_data = common.convolutional(input_data, (1, 1, 128, 128), activate_type="mish")52 input_data = tf.concat([input_data, route], axis=-1)53 input_data = common.convolutional(input_data, (1, 1, 256, 256), activate_type="mish")54 route_1 = input_data55 input_data = common.convolutional(input_data, (3, 3, 256, 512), downsample=True, activate_type="mish")56 route = input_data57 route = common.convolutional(route, (1, 1, 512, 256), activate_type="mish")58 input_data = common.convolutional(input_data, (1, 1, 512, 256), activate_type="mish")59 for i in range(8):60 input_data = common.residual_block(input_data, 256, 256, 256, activate_type="mish")61 input_data = common.convolutional(input_data, (1, 1, 256, 256), activate_type="mish")62 input_data = tf.concat([input_data, route], axis=-1)63 input_data = common.convolutional(input_data, (1, 1, 512, 512), activate_type="mish")64 route_2 = input_data65 input_data = common.convolutional(input_data, (3, 3, 512, 1024), downsample=True, activate_type="mish")66 route = input_data67 route = common.convolutional(route, (1, 1, 1024, 512), activate_type="mish")68 input_data = common.convolutional(input_data, (1, 1, 1024, 512), activate_type="mish")69 for i in range(4):70 input_data = common.residual_block(input_data, 512, 512, 512, activate_type="mish")71 input_data = common.convolutional(input_data, (1, 1, 512, 512), activate_type="mish")72 input_data = tf.concat([input_data, route], axis=-1)73 input_data = common.convolutional(input_data, (1, 1, 1024, 1024), activate_type="mish")74 input_data = common.convolutional(input_data, (1, 1, 1024, 512))75 input_data = common.convolutional(input_data, (3, 3, 512, 1024))76 input_data = common.convolutional(input_data, (1, 1, 1024, 512))77 input_data = tf.concat([tf.nn.max_pool(input_data, ksize=13, padding='SAME', strides=1), tf.nn.max_pool(input_data, ksize=9, padding='SAME', strides=1)78 , tf.nn.max_pool(input_data, ksize=5, padding='SAME', strides=1), input_data], axis=-1)79 input_data = common.convolutional(input_data, (1, 1, 2048, 512))80 input_data = common.convolutional(input_data, (3, 3, 512, 1024))81 input_data = common.convolutional(input_data, (1, 1, 1024, 512))82 return route_1, route_2, input_data83def cspdarknet53_tiny(input_data):84 input_data = common.convolutional(input_data, (3, 3, 3, 32), downsample=True)85 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True)86 input_data = common.convolutional(input_data, (3, 3, 64, 64))87 route = input_data88 input_data = common.route_group(input_data, 2, 1)89 input_data = common.convolutional(input_data, (3, 3, 32, 32))90 route_1 = input_data91 input_data = common.convolutional(input_data, (3, 3, 32, 32))92 input_data = tf.concat([input_data, route_1], axis=-1)93 input_data = common.convolutional(input_data, (1, 1, 32, 64))94 input_data = tf.concat([route, input_data], axis=-1)95 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)96 input_data = common.convolutional(input_data, (3, 3, 64, 128))97 route = input_data98 input_data = common.route_group(input_data, 2, 1)99 input_data = common.convolutional(input_data, (3, 3, 64, 64))100 route_1 = input_data101 input_data = common.convolutional(input_data, (3, 3, 64, 64))102 input_data = tf.concat([input_data, route_1], axis=-1)103 input_data = common.convolutional(input_data, (1, 1, 64, 128))104 input_data = tf.concat([route, input_data], axis=-1)105 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)106 input_data = common.convolutional(input_data, (3, 3, 128, 256))107 route = input_data108 input_data = common.route_group(input_data, 2, 1)109 input_data = common.convolutional(input_data, (3, 3, 128, 128))110 route_1 = input_data111 input_data = common.convolutional(input_data, (3, 3, 128, 128))112 input_data = tf.concat([input_data, route_1], axis=-1)113 input_data = common.convolutional(input_data, (1, 1, 128, 256))114 route_1 = input_data115 input_data = tf.concat([route, input_data], axis=-1)116 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)117 input_data = common.convolutional(input_data, (3, 3, 512, 512))118 return route_1, input_data119def darknet53_tiny(input_data):120 input_data = common.convolutional(input_data, (3, 3, 3, 16))121 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)122 input_data = common.convolutional(input_data, (3, 3, 16, 32))123 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)124 input_data = common.convolutional(input_data, (3, 3, 32, 64))125 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)126 input_data = common.convolutional(input_data, (3, 3, 64, 128))127 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)128 input_data = common.convolutional(input_data, (3, 3, 128, 256))129 route_1 = input_data130 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)131 input_data = common.convolutional(input_data, (3, 3, 256, 512))132 input_data = tf.keras.layers.MaxPool2D(2, 1, 'same')(input_data)133 input_data = common.convolutional(input_data, (3, 3, 512, 1024))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!