Exemple #1
0
    octave_base_scale=6,
    scales_per_octave=1,
)
featmap_sizes = [
    [80, 80],
    [40, 40],
    [20, 20],
    [10, 10],
    [5, 5],
]

mlvl_anchors = anchor_gen.grid_anchors(featmap_sizes)
num_level_bboxes = [a.shape[0] for a in mlvl_anchors]
anchors = tf.concat(mlvl_anchors, axis=0)

bbox_coder = BBoxCoder(anchors)


@curry
def preprocess(example,
               output_size=(HEIGHT, WIDTH),
               max_objects=50,
               training=True):
    image, objects, image_id = decode(example)

    # if training:
    # image = random_resize(image, output_size, ratio_range=(0.8, 1.2))
    # image, objects = random_crop(image, objects, output_size)
    # image, objects = random_hflip(image, objects, 0.5)
    # else:
    image = resize(image, output_size)
Exemple #2
0
anchor_gen = AnchorGenerator(
    strides=[8, 16, 32, 64, 128],
    ratios=[0.5, 1.0, 2.0],
    octave_base_scale=2,
    scales_per_octave=3,
)
featmap_sizes = [
    [32, 32], [16, 16], [8, 8], [4, 4], [2, 2],
]

mlvl_anchors = anchor_gen.grid_anchors(featmap_sizes)
num_level_bboxes = [a.shape[0] for a in mlvl_anchors]
anchors = tf.concat(mlvl_anchors, axis=0)

bbox_coder = BBoxCoder(anchors, (0.1, 0.1, 0.2, 0.2))


@curry
def preprocess(example, output_size=(HEIGHT, WIDTH), max_objects=50, training=True):
    image, objects, image_id = decode(example)

    if training:
        image = random_resize(image, output_size, ratio_range=(0.5, 2.0))
        image, objects = random_crop(image, objects, output_size)
        image, objects = random_hflip(image, objects, 0.5)
    else:
        image = resize(image, output_size)

    image = normalize(image, [123.68, 116.779, 103.939], [58.393, 57.12, 57.375])
    image, objects = pad_to(image, objects, output_size)