forked from TianzhongSong/C3D-keras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_label_txt.py
37 lines (29 loc) · 881 Bytes
/
make_label_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
35
36
37
import os
img_path = '/home/tianz/datsets/ucfimgs/'
f1 = open('ucfTrainTestlist/train_file.txt','r')
f2 = open('ucfTrainTestlist/test_file.txt','r')
train_list = f1.readlines()
test_list = f2.readlines()
f3 = open('train_list.txt', 'w')
f4 = open('test_list.txt', 'w')
clip_length = 16
for line in train_list:
name = line.split(' ')[0]
image_path = img_path+name
label = line.split(' ')[-1]
images = os.listdir(image_path)
nb = len(images) // clip_length
for i in range(nb):
f3.write(name+' '+ str(i*clip_length+1)+' '+label)
for line in test_list:
name = line.split(' ')[0]
image_path = img_path+name
label = line.split(' ')[-1]
images = os.listdir(image_path)
nb = len(images) // clip_length
for i in range(nb):
f4.write(name+' '+ str(i*clip_length+1)+' '+label)
f1.close()
f2.close()
f3.close()
f4.close()