-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_gustavo_files.py
69 lines (47 loc) · 1.86 KB
/
make_gustavo_files.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
import torch
# python preprocess_sign.py data/ori/test.txt data/processed/test.pt
# python preprocess.py --source-lang pt --target-lang pt --testpref data/processed/test --destdir data-bin/ --dataset-impl raw
folder = "./i3d-features-gustavo/span=16_stride=2/"
test_signer = "gabriel"
#open("./data/ori/train.txt", "w").close()
open("./data/ori/test.txt", "w").close()
open("test.sign-pt.sign", "w").close()
#open("train.sign-pt.sign", "w").close()
with open('./New_Libraria_Texts.txt', 'r', encoding="utf8") as f:
lines = f.readlines()
f.close()
i = 0
for pt in os.listdir(folder):
for line in lines:
video = line.split(";")[0]
frase = line.split(";")[-1].lower()
if video in pt:
i += 1
print(i, pt)
filename = pt.split(".")[0]
array = torch.load(folder+pt)
json = "{\"ident\": "+ "\""+filename+"\", "+"\"size\": "+str(len(array))+"}, "
with open('./data/ori/test.txt', 'a', encoding="utf8") as f:
f.write(frase)
f.close()
with open('./test.sign-pt.sign', 'a', encoding="utf8") as f:
f.write(json)
f.close()
"""
if not test_signer in filename:
with open('./data/ori/train.txt', 'a', encoding="utf8") as f:
f.write(frase)
f.close()
with open('./train.sign-pt.sign', 'a', encoding="utf8") as f:
f.write(json)
f.close()
else:
with open('./data/ori/test.txt', 'a', encoding="utf8") as f:
f.write(frase)
f.close()
with open('./test.sign-pt.sign', 'a', encoding="utf8") as f:
f.write(json)
f.close()
"""
break