File size: 1,828 Bytes
22257c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
 # Copyright 2020 Adobe
 # All Rights Reserved.
 
 # NOTICE: Adobe permits you to use, modify, and distribute this file in
 # accordance with the terms of the Adobe license agreement accompanying
 # it.
 
"""

import os, glob, time, sys
from src.dataset.utils.Av2Flau_Convertor import Av2Flau_Convertor

out_dir = r'/mnt/nfs/scratch1/yangzhou/PreprocessedVox_imagetranslation'
src_dir = r'/mnt/nfs/scratch1/yangzhou/vox_p3/train'

''' Step 1. Data preparation '''
# landmark extraction
# landmark_extraction(int(sys.argv[1]), int(sys.argv[2]))

def landmark_extraction(si, ei):
    '''

    :param si: start index
    :param ei: end index
    :return: save extracted landmarks to out_dir
    '''

    for folder_name in ['raw_wav', 'raw_fl3d', 'register_fl3d', 'dump', 'tmp_v', 'nn_result', 'ckpt', 'log']:
        try:
            os.mkdir(os.path.join(out_dir, folder_name))
        except:
            pass


    if(not os.path.isfile(os.path.join(out_dir, 'filename_index.txt'))):
        # generate all file list
        files = glob.glob1(src_dir, '*.mp4')
        with open(os.path.join(out_dir, 'filename_index.txt'), 'w') as f:
            for i, file in enumerate(files):
                f.write('{} {}\n'.format(i, file))
    else:
        with open(os.path.join(out_dir, 'filename_index.txt'), 'r') as f:
            lines = f.readlines()

        print(sys.argv)
        for line in lines[si:ei]:
            st = time.time()
            idx, file = int(line.split(' ')[0]), line.split(' ')[1][:-1]

            c = Av2Flau_Convertor(video_dir=os.path.join(src_dir, file),
                                  out_dir=out_dir, idx=idx)
            c.convert(show=False) #  (save_audio=False, register=False, show=False)
            print('Idx: {}, Processed time (min): {}'.format(idx, (time.time() - st) / 60.0))