<jupyter_start><jupyter_text>Get images and boxes<jupyter_code>tf.reset_default_graph()

params = json.load(open('config.json'))
input_pipeline_params = params['input_pipeline_params']

pipeline = Pipeline(
    'data/val.tfrecords',
    batch_size=24, image_size=(640, 360),
    repeat=True, shuffle=False, 
    augmentation=input_pipeline_params
)
features, labels = pipeline.get_batch()
with tf.Session() as sess:
    sess.run(pipeline.init)
    I, B, L, N = sess.run([
        features['images'], labels['boxes'],
        labels['labels'], labels['num_boxes']
    ])<jupyter_output><empty_output><jupyter_text>Show an augmented image with boxes<jupyter_code>def draw_boxes(image, boxes, labels):
    image_copy = image.copy()
    draw = ImageDraw.Draw(image_copy, 'RGBA')
    width, height = image.size

    for box, label in zip(boxes, labels):
        ymin, xmin, ymax, xmax = box
        xmin, xmax = width*xmin, width*xmax
        ymin, ymax = height*ymin, height*ymax

        text = str(label)
        fill = (255, 255, 255, 45)
        outline = 'black'

        draw.rectangle(
            [(xmin, ymin), (xmax, ymax)],
            fill=fill, outline=outline
        )
        draw.rectangle(
            [(xmin, ymin), (xmin + 4*len(text) + 4, ymin + 10)],
            fill='white', outline='white'
        )
        draw.text((xmin + 1, ymin + 1), text, fill='red')

    return image_copy
# choose an image
i = 14
image = Image.fromarray((np.transpose(I[i], [1, 2, 0])*255.0).astype('uint8'))
num_boxes = N[i]
boxes = B[i][:num_boxes]
classes = L[i][:num_boxes]

draw_boxes(image, boxes, classes)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14948139109212935, 'fraction_numerical': 0.021354484441732765, 'mean_word_length': 3.3271767810026387, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '211371', 'license': 'MIT', 'n_tokens_mistral': 613, 'n_tokens_neox': 576, 'n_words': 123, 'path': 'test_input_pipeline.ipynb', 'repo_name': 'zsz00/single-shot-detector', 'size': '1639'}