def make_new_images(dataset, imgs_train, imgs_val):
    """
    Split the annotations in dataset into two files train and val
    according to the img ids in imgs_train, imgs_val.
    """
    table_imgs = {x['id']:x for x in dataset['images']}
    table_anns = {x['image_id']:x for x in dataset['annotations']}

    keys = ['info', 'licenses', 'images', 'annotations', 'categories']
    
    # Train
    dataset_train = dict.fromkeys(keys)
    dataset_train['info'] = dataset['info']
    dataset_train['licenses'] = dataset['licenses']
    dataset_train['categories'] = dataset['categories']
    dataset_train['images'] = [table_imgs[x] for x in imgs_train]
    dataset_train['annotations'] = [table_anns[x] for x in imgs_train]

    # Validation
    dataset_val = dict.fromkeys(keys)
    dataset_val['info'] = dataset['info']
    dataset_val['licenses'] = dataset['licenses']
    dataset_val['categories'] = dataset['categories']
    dataset_val['images'] = [table_imgs[x] for x in imgs_val]
    dataset_val['annotations'] = [table_anns[x] for x in imgs_val]
    
    return dataset_train, dataset_val