File size: 905 Bytes
fcbbb8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import pandas
from pathlib import Path
import string
import shutil

# read all the folders in data/train
data_folder = Path("./data/train")
folders = os.listdir(data_folder)

entries = []

image_index = 0
for folder in folders:
    images_path = data_folder.joinpath(folder)
    images = os.listdir(images_path)

    view = 0
    for image in images:
        object_description = folder.replace('_', ' ')
        entry = {'file_name' : image, 'object_type' : 'small_scenery', 'object_description' : object_description, 'view': view, 'color1' : 'none', 'color2' : 'none', 'color3' : 'none'}
        entries.append(entry)
        view = view + 1
        
#put the entries into the metadata.csv
dataframe = pandas.DataFrame(entries)

# dont overwrite the old metadata.csv
if os.path.exists('metadata.csv'):
    shutil.copyfile('metadata.csv', 'metadata_backup.csv')
dataframe.to_csv('metadata.csv')