how to transform a folder of images into csv file?

I have a data set for segmentation project. The dataset have 2 folders containing train folder and annotated_train_data folder, both folders have images. input and label both are images. I want to make a csv file of this dataset to feed into a neural network. what is the easiest and efficient way to make csv file?

./images
./images/train
./images/train/label1.jpg
./images/train/label2.jpg
./images/train/label3.jpg
./images/annotated_train_data
./images/annotated_train_data/label1.jpg
./images/annotated_train_data/label2.jpg
./images/annotated_train_data/label3.jpg

• How are labels stored in the form of images? Is the tree structure correct? – thanatoz Apr 11 '19 at 5:31
• the labels are also images with same name as the input image itself but labels are stored in another folder – babayagaa00070 Apr 11 '19 at 6:08
• the label image is annotated version of the input image, and i am trying to use this dataset for segementation purpose. – babayagaa00070 Apr 11 '19 at 6:10
• what do you want in the output csv files? Only the path of each jpg file? – aborruso Apr 11 '19 at 8:01
• path of each file is also ok – babayagaa00070 Apr 11 '19 at 8:36

import os
import pandas as pd

BASE_DIR = 'images/'
train_folder = BASE_DIR+'train/'
train_annotation = BASE_DIR+'annotated_train_data/'

files_in_train = sorted(os.listdir(train_folder))
files_in_annotated = sorted(os.listdir(train_annotation))

images=[i for i in files_in_train if i in files_in_annotated]

df = pd.DataFrame()
df['images']=[train_folder+str(x) for x in images]
df['labels']=[train_annotation+str(x) for x in images]