-
Notifications
You must be signed in to change notification settings - Fork 0
/
Json_file.py
32 lines (24 loc) · 927 Bytes
/
Json_file.py
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
32
import json
import os
train_dir = os.path.join('/content/drive/My Drive/Colab Notebooks/myDataset/DT', 'training')
valid_dir = os.path.join('/content/drive/My Drive/Colab Notebooks/myDataset/DT', 'valid')
train_class_name = [x[1] for x in os.walk(train_dir)]
train_class_name = train_class_name[0]
valid_class_name = [x[1] for x in os.walk(valid_dir)]
valid_class_name = valid_class_name[0]
train_json = {}
valid_json = {}
for tcn in train_class_name:
address = '/content/drive/My Drive/Colab Notebooks/myDataset/DT/training/' + tcn
for x in os.walk(address):
train_json[tcn] = x[2]
for vcn in valid_class_name:
address = '/content/drive/My Drive/Colab Notebooks/myDataset/DT/valid/' + vcn
for x in os.walk(address):
valid_json[vcn] = x[2]
dataset_split = {
'training':train_json,
'validation':valid_json
}
with open('dataset_split.json', 'w') as fp:
json.dump(dataset_split, fp)