<jupyter_start><jupyter_text>Create a labeling document Let's start by creating a labeling document with a single image and open it by clicking the link.<jupyter_code>image_files = ['example_1.jpg', 'example_2.png']

labeling_document_no_labeles = 'no_labels.html'

image_set = label_wrapper.ImageSet().add_images(image_files)
image_set.create_via(labeling_document_no_labeles)

FileLink(labeling_document_no_labeles)<jupyter_output><empty_output><jupyter_text>In the labeling document we can create annotations by manually drawing shapes and export as json them by selecting **Annotations / Export Annotations (as json)** in the top menu of the annotation tool.The annotation tool we're using is [VIA](http://www.robots.ox.ac.uk/~vgg/software/via/).  Load labeles and visualise themOnce we have a labeled dataset we want to use images and json annotations to create a set of images and image masks and use them for training. We do this by loading the json file and exporting it to a practical file format. Here we use tfrecords.<jupyter_code>created_json = 'via_region_data.json'
tf_records_filepath = './test.tfrecords'

labeled_image_set = label_wrapper.ImageSet().load_json(created_json)
labeled_image_set.export(tf_records_filepath)<jupyter_output><empty_output><jupyter_text>We can load and view the created images and image masks dataset:<jupyter_code>for fileref, image, mask in label_wrapper.io._tfrecord_decoder(tf_records_filepath):
    fig = plt.figure(figsize=(16,7))
    
    fig.add_subplot(1,2,1)
    image = np.squeeze(image)
    plt.imshow(image)
    
    fig.add_subplot(1,2,2)
    plt.imshow(mask)<jupyter_output>WARNING:tensorflow:From /home/rok/.virtualenvs/d3m/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py:532: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.<jupyter_text>Training and inference Here we first run training and then inference on the exported `tfrecords` dataset.We store it to a new tfrecords file.This is not done in this notebook.  Inference reviewWe now want to review the inferece results. We do this by converting binary masks to polygons and creating a labeling document for review.<jupyter_code>extracted_via_inference_generation_0 = 'recognized_labels.html'
tf_records_generation_0_filepath = './test.tfrecords'

imported_image_set = label_wrapper.ImageSet().import_labels(tf_records_generation_0_filepath)
imported_image_set.create_via(extracted_via_inference_generation_0)

FileLink(extracted_via_inference_generation_0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07605421686746988, 'fraction_numerical': 0.008283132530120483, 'mean_word_length': 6.463483146067416, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '187230', 'license': 'MIT', 'n_tokens_mistral': 844, 'n_tokens_neox': 807, 'n_words': 231, 'path': 'examples/label_wrapper.ipynb', 'repo_name': 'rok/label-wrapper', 'size': '2656'}