def convert_to_tf_records()

in src/script.py [0:0]


def convert_to_tf_records(channel_jpegs_path, channel_name, op_dir, n_image, slides):
    if channel_name in ['train', 'valid']:
        tcga_image_labels = generate_image_dict(channel_jpegs_path)

        tot_files = len(tcga_image_labels)
        print(f'Channel: {channel_name}. Total number of images: {tot_files}')
        if tot_files == 0:
            return

        pathlib.Path(f'{op_dir}/{channel_name}').mkdir(parents=True, exist_ok=True)
        output_file = f'{op_dir}/{channel_name}/image-{str(uuid.uuid4())}.tfrecords'
        n_image = n_image if channel_name == 'train' else tot_files
        print(f'Count of input images: {n_image}')

        generate_tf_records(channel_jpegs_path, list(tcga_image_labels.items()), output_file, n_image)
    else:
        for slide in slides:
            tcga_image_labels = generate_image_dict(channel_jpegs_path, slide)

            tot_files = len(tcga_image_labels)
            print(f'Channel: {channel_name}. Total number of images for slide {slide}: {tot_files}')
            if tot_files == 0:
                continue

            pathlib.Path(f'{op_dir}/{channel_name}').mkdir(parents=True, exist_ok=True)
            output_file = f'{op_dir}/{channel_name}/{slide}.tfrecords'
            n_image = tot_files
            print(f'Count of input images: {n_image}')

            generate_tf_records(channel_jpegs_path, list(tcga_image_labels.items()), output_file, n_image, slide)