-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_cambridge_scene.py
executable file
·55 lines (41 loc) · 1.33 KB
/
create_cambridge_scene.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import json
# Train and Test file paths for a particular Scene
train_gt_files = 'ShopFacade/dataset_train.txt' #Specify path to files for training
test_gt_files = 'ShopFacade/dataset_test.txt' #Specify path to files for testing
f = open(train_gt_files,'r')
train_gt_files = f.readlines()
f = open(test_gt_files,'r')
test_gt_files = f.readlines()
train_gt_files = train_gt_files[3:]
test_gt_files = test_gt_files[3:]
dataset = [[],[],[],[]]
for i in range(len(train_gt_files)):
temp = train_gt_files[i].split(' ')
temp = [j.strip() for j in temp]
dataset[0].append(temp[0])
temp2 = temp[4:]
temp2 = [float(j) for j in temp2]
temp = temp[1:3]
temp = [float(j) for j in temp]
dataset[1].append(temp)
dataset[2].append(temp2)
dataset[3].append(temp)
# Dump dataset for training (specify path)
with open('ShopFacade/dataset_train_mod.txt','w') as f:
json.dump(dataset,f)
dataset = [[],[],[],[]]
for i in range(len(test_gt_files)):
temp = test_gt_files[i].split(' ')
temp = [j.strip() for j in temp]
dataset[0].append(temp[0])
temp2 = temp[4:]
temp2 = [float(j) for j in temp2]
temp = temp[1:3]
temp = [float(j) for j in temp]
dataset[1].append(temp)
dataset[2].append(temp2)
dataset[3].append(temp)
# Dump dataset for testing (specify path)
with open('ShopFacade/dataset_test_mod.txt','w') as f:
json.dump(dataset,f)