def main()

in src/script.py [0:0]


def main(n_images):
    input_path = '/opt/ml/processing/input'
    jpeg_path = '/home/512px_Tiled'
    sorted_jpeg_path = "/home/tcga-svs-tiled-sorted"
    output_path = f'/opt/ml/processing/output'

    tcga_svs_labels_path = '/home/tcga-svs-labels'
    tcga_svs_luad_file_path = f'{tcga_svs_labels_path}/tcga-lung-luad.txt'
    tcga_svs_lusc_file_path = f'{tcga_svs_labels_path}/tcga-lung-lusc.txt'
    tcga_svs_norm_file_path = f'{tcga_svs_labels_path}/tcga-lung-normal.txt'

    print('Creating tiles .....')
    create_tiles(input_path)
    print('Tiles created.')

    luad_slides = sort_jpegs(tcga_svs_luad_file_path, 'luad', jpeg_path, sorted_jpeg_path)
    lusc_slides = sort_jpegs(tcga_svs_lusc_file_path, 'lusc', jpeg_path, sorted_jpeg_path)
    norm_slides = sort_jpegs(tcga_svs_norm_file_path, 'normal', jpeg_path, sorted_jpeg_path)
    print('Images sorted.')

    slides = luad_slides + lusc_slides + norm_slides

    for channel in ['train', 'test', 'valid']:
        convert_to_tf_records(f'{sorted_jpeg_path}/{channel}', channel, output_path, n_images, slides)

    print('TF records conversion complete.')