<jupyter_start><jupyter_text>Getting classes names<jupyter_code>model_path = 'training-output/model.pt'
model_dict = torch.load(model_path)
classes = model_dict['classes']<jupyter_output><empty_output><jupyter_text>Getting roi_numbers and scores<jupyter_code>filename = 'run-output/ExampleRunResults/D20200605T214358_IFCB010_class_v2.h5'
with h5py.File(filename, "r") as f:
    # List all groups
    keys = list(f.keys())
    print("Keys: %s" % keys)
    # Get the data
    roi_numbers = list(f[keys[0]])
    scores = list(f[keys[1]])<jupyter_output>Keys: ['roi_numbers', 'scores']<jupyter_text>Converting raw data to images<jupyter_code>pid = 'D20200605T214358_IFCB010'
data_path = 'run-data'
output_path = 'run-output/ExampleRunResults'
data_dir = ifcb.DataDirectory(data_path)
for folder_name in classes:
    path = output_path + '/' + folder_name
    try:
        os.mkdir(path)
    except OSError:
        print ("Creation of the directory %s failed" % path)
    else:
        print ("Successfully created the directory %s " % path)
for sample_bin in data_dir:
    n_images = len(sample_bin.images)
    lid = sample_bin.lid
    print('{} has {} image(s)'.format(lid, n_images))
    with sample_bin:
        for roi_number in sample_bin.images:
            pos = roi_numbers.index(roi_number)
            best_class = np.where(scores[pos] == np.amax(scores[pos]))[0][0]
            folder_name = classes[best_class]
            img_path = output_path + '/' + folder_name + '/' +  pid + '_' + str(roi_number) + '.png'
            imageio.imwrite(img_path, sample_bin.images[roi_number])<jupyter_output>D20200605T214358_IFCB010 has 6723 image(s)
{'fraction_non_alphanumeric': 0.12568306010928962, 'fraction_numerical': 0.03764420157862781, 'mean_word_length': 4.08641975308642, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '362315', 'license': 'MIT', 'n_tokens_mistral': 637, 'n_tokens_neox': 595, 'n_words': 108, 'path': 'notebooks/model_results.ipynb', 'repo_name': 'SAMS-UK/ifcb_classifier', 'size': '1647'}