-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_txt.py
34 lines (27 loc) · 912 Bytes
/
make_txt.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
import os
import numpy
import shutil
project_path = '/storage/hieunmt/zaloai_liveness'
# route = f'{project_path}/unzip/seed_42_20_fold_10'
route = f'{project_path}/unzip/train_full'
def convert_txt(route, file_txt, stage):
with open(file_txt, "r") as f:
data = f.read()
with open(f"{stage}.txt", "w") as f:
data = data.split("\n")
for line in data:
try:
name, label = line.split(' ')
f_path = os.path.join(route, stage, name)
except:
pass
f.write(f"{f_path} {label}\n")
# file_txt = os.path.join(route, 'train_video.txt')
# stage = "train"
# convert_txt(route, file_txt, stage)
# file_txt = os.path.join(route, 'val_video.txt')
# stage = "val"
# convert_txt(route, file_txt, stage)
file_txt = os.path.join(route, 'train_video_full.txt')
stage = "train"
convert_txt(route, file_txt, stage)