target per shape_csv.py 632 Bytes
import pandas as pd
import os
import csv

class0_path = "../../data/MICCAI_BraTS_2019_Data_Training/circle_val"
class1_path = "../../data/MICCAI_BraTS_2019_Data_Training/ellipse_val"
target_csv = "../../data/MICCAI_BraTS_2019_Data_Training/ce_valid_targets.csv"

f=open(target_csv, 'w', newline='')
w=csv.writer(f)

for path, dirs, files in os.walk(class0_path):
    for filename in files:
        print(filename)
        n_class = 0
        w.writerow([filename, n_class])

for path, dirs, files in os.walk(class1_path):
    for filename in files:
        print(filename)
        n_class = 1
        w.writerow([filename, n_class])