File size: 433 Bytes
8136987 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import os
import scipy.io
mat = scipy.io.loadmat('meta.mat')
classes = os.listdir("./train")
classes = sorted(classes)
classname2idx = {}
idx = 0
for classname in classes:
classname2idx[classname] = idx
idx += 1
with open("id2wnid&class.txt", "a+") as fp:
for meta in mat["synsets"][:1000]:
meta = meta[0]
id, wnid = meta[0], meta[1]
fp.write(f"{id[0,0]},{wnid[0]},{classname2idx[wnid[0]]}\n")
|