Skip to content

Instantly share code, notes, and snippets.

@pbamotra
Created July 3, 2019 21:10
Show Gist options
  • Save pbamotra/dda1df7e7552376a23562085713c9891 to your computer and use it in GitHub Desktop.
Save pbamotra/dda1df7e7552376a23562085713c9891 to your computer and use it in GitHub Desktop.
DALI Post-1.4
from os import listdir
from os.path import isfile, join
images_directory = './flower_data/flower_data_flat'
# read names of all image files
image_files = [f for f in listdir(image_dir) if isfile(join(image_dir, f))]
# we create a data frame with the image names and dummy labels - label_1, label_2
data = pd.DataFrame(list(zip(image_files,
list(range(len(image_files))),
list(range(len(image_files))))),
columns=['image_filename', 'label_1', 'label_2'])
processed_data_file = 'flower_dummy_data.ssv'
data.to_csv(processed_data_file, index=False, header=False, sep=' ')
print(data.head())
# image_filename label_1 label_2
# 0 image_05973.jpg 0 0
# 1 image_00956.jpg 1 1
# 2 image_06047.jpg 2 2
# 3 image_07168.jpg 3 3
# 4 image_04466.jpg 4 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment