split.py 413 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
input = open("list.txt", "r").readlines()
fout_train = open("CUB200_train.txt", "w")
fout_valid = open("CUB200_val.txt", "w")
for i, item in enumerate(input):
    label = item.strip().split("/")[-2].split(".")[0]
    label = int(label)
    if label <= 100:
        fout = fout_train
    else:
        fout = fout_valid
    fout.write(item.strip() + " " + str(label) + "\n")

fout_train.close()
fout_valid.close()