import os

split = 0.8

indices = np.arange(n_all_images)
np.random.shuffle(indices)
train_indices = indices[: int(n_all_images * split)]
test_indices = indices[int(n_all_images * split):]

! rm -rf data

dst='data/train'
if not os.path.exists(dst):
    os.makedirs(dst)
for idx in train_indices:
    path = all_file_paths[idx]
    dpath, fname = os.path.split(path)
    os.symlink(f'../../{path}', f'{dst}/{fname}')

dst='data/test'
if not os.path.exists(dst):
    os.makedirs(dst)
for idx in test_indices:
    path = all_file_paths[idx]
    dpath, fname = os.path.split(path)
    os.symlink(f'../../{path}', f'{dst}/{fname}')
