Skip to content

Instantly share code, notes, and snippets.

@philschmid
Created October 25, 2019 14:42
Show Gist options
  • Save philschmid/691183997945327b987d74f37c0ad5e7 to your computer and use it in GitHub Desktop.
Save philschmid/691183997945327b987d74f37c0ad5e7 to your computer and use it in GitHub Desktop.
from PIL import Image
import os
import argparse
def rescale_images(directory, size):
for img in os.listdir(directory):
im = Image.open(directory+img)
im_resized = im.resize(size, Image.ANTIALIAS)
im_resized.save(directory+img)if __name__ == '__main__':
def main():
for folder in ['train', 'test']:
image_path = os.path.join(os.getcwd(), ('images/' + folder))
xml_df = xml_to_csv(image_path)
xml_df.to_csv(('images/'+folder+'_labels.csv'), index=None)
print('Successfully converted xml to csv.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment