def test_pad(): img = _image() assert img.shape[0] == 480 assert img.shape[1] == 480 assert img.shape[2] == 3 augmentor = Pad(100) result = augmentor(**{'image': img}) image = result['image'] _show_image(image) assert image.shape[0] == 680 assert image.shape[1] == 680 assert image.shape[2] == 3 augmentor = Pad((40, 30)) result = augmentor(**{'image': img}) image = result['image'] _show_image(image) assert image.shape[0] == 480 + 30 * 2 assert image.shape[1] == 480 + 40 * 2 assert image.shape[2] == 3
PRE_PROCESSOR = Sequence([Resize(size=IMAGE_SIZE), PerImageStandardization()]) POST_PROCESSOR = None NETWORK = EasyDict() NETWORK.OPTIMIZER_CLASS = tf.train.MomentumOptimizer NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.train.piecewise_constant NETWORK.LEARNING_RATE_KWARGS = { "values": [0.1, 0.01, 0.001, 0.0001], "boundaries": [40000, 60000, 80000], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0001 NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = {'bit': 2, 'max_value': 2} NETWORK.WEIGHT_QUANTIZER = binary_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} # dataset DATASET = EasyDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([ Pad(2), Crop(size=IMAGE_SIZE), FlipLeftRight(), ])
NETWORK.OPTIMIZER_KWARGS = {"momentum": 0.9} NETWORK.LEARNING_RATE_FUNC = tf.train.piecewise_constant step_per_epoch = int(50000 / (BATCH_SIZE * num_worker)) NETWORK.LEARNING_RATE_KWARGS = { "values": ([ 0.01 * num_worker, 0.001 * num_worker, 0.0001 * num_worker, 0.00001 * num_worker ]), "boundaries": [step_per_epoch * 200, step_per_epoch * 300, step_per_epoch * 350], } NETWORK.IMAGE_SIZE = IMAGE_SIZE NETWORK.BATCH_SIZE = BATCH_SIZE NETWORK.DATA_FORMAT = DATA_FORMAT NETWORK.WEIGHT_DECAY_RATE = 0.0005 NETWORK.ACTIVATION_QUANTIZER = linear_mid_tread_half_quantizer NETWORK.ACTIVATION_QUANTIZER_KWARGS = {'bit': 2, 'max_value': 2} NETWORK.WEIGHT_QUANTIZER = binary_mean_scaling_quantizer NETWORK.WEIGHT_QUANTIZER_KWARGS = {} # dataset DATASET = EasyDict() DATASET.BATCH_SIZE = BATCH_SIZE DATASET.DATA_FORMAT = DATA_FORMAT DATASET.PRE_PROCESSOR = PRE_PROCESSOR DATASET.AUGMENTOR = Sequence([ Pad(4), Crop(size=IMAGE_SIZE), FlipLeftRight(), ])