src/data.py
def copy_speed_dataset_resize(old_path, new_path, new_size=(224, 224), split='train'):
    """copy and resize Speed images to a new directory. The new (empty) folders must be created before calling
    this function"""

    if split not in {'train', 'test', 'real_test'}:
        raise ValueError('Invalid split, has to be either \'train\', \'test\' or \'real_test\'')

    with open(os.path.join(old_path, split + '.json'), 'r') as f:
        target_list = json.load(f)

    sample_ids = [label['filename'] for label in target_list]

    image_root = os.path.join(old_path, 'images', split)

    image_resize_root = os.path.join(new_path, 'images', split)

    for i in range(len(sample_ids)):
        img_name = os.path.join(image_root, sample_ids[i])
        pil_img = Image.open(img_name).resize(new_size)
        new_name = os.path.join(image_resize_root, sample_ids[i])
        pil_img.save(new_name)
copy and resize Speed images to a new directory. The new (empty) folders must be created before calling
    this function
copy and resize Speed images to a new directory. The new (empty) folders must be created before calling
this function
copy and resize Speed images to a new directory . The new ( empty ) folders must be created before calling this function
def copy_speed_dataset_resize(old_path, new_path, new_size=(224, 224), split='train'):
    if split not in {'train', 'test', 'real_test'}:
        raise ValueError('Invalid split, has to be either \'train\', \'test\' or \'real_test\'')
    with open(os.path.join(old_path, split + '.json'), 'r') as f:
        target_list = json.load(f)
    sample_ids = [label['filename'] for label in target_list]
    image_root = os.path.join(old_path, 'images', split)
    image_resize_root = os.path.join(new_path, 'images', split)
    for i in range(len(sample_ids)):
        img_name = os.path.join(image_root, sample_ids[i])
        pil_img = Image.open(img_name).resize(new_size)
        new_name = os.path.join(image_resize_root, sample_ids[i])
        pil_img.save(new_name)
def copy_speed_dataset_resize ( old_path , new_path , new_size = ( 224 , 224 ) , split = 'train' ) : if split not in { 'train' , 'test' , 'real_test' } : raise ValueError ( 'Invalid split, has to be either \'train\', \'test\' or \'real_test\'' ) with open ( os . path . join ( old_path , split + '.json' ) , 'r' ) as f : target_list = json . load ( f ) sample_ids = [ label [ 'filename' ] for label in target_list ] image_root = os . path . join ( old_path , 'images' , split ) image_resize_root = os . path . join ( new_path , 'images' , split ) for i in range ( len ( sample_ids ) ) : img_name = os . path . join ( image_root , sample_ids [ i ] ) pil_img = Image . open ( img_name ) . resize ( new_size ) new_name = os . path . join ( image_resize_root , sample_ids [ i ] ) pil_img . save ( new_name )
copy and resize Speed images to a new directory.
copy and resize Speed images to a new directory .
"""copy and resize Speed images to a new directory. The new (empty) folders must be created before calling
    this function"""
old_path
new_path
new_size
split