-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNPY_Loader.py
More file actions
30 lines (23 loc) · 977 Bytes
/
NPY_Loader.py
File metadata and controls
30 lines (23 loc) · 977 Bytes
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
import numpy as np
import numpy.ma as ma
import glob
import os
class NPY_Loader():
def __init__(self, npy_path, npy_name):
# self.pred_land = np.load(os.path.join(npy_path, npy_name), allow_pickle=True).item()
self.pred_land = np.load(os.path.join(npy_path, npy_name), allow_pickle=True) # JVCR
self.sequences = list(sorted(self.pred_land.keys()))
self.len_seq = next(iter(self.pred_land.values())).shape[2]
def get_sequences(self):
return self.sequences
def get_seq_len(self):
return self.len_seq
def get_lmks_pred(self, seq, frame):
if np.any(self.pred_land[seq][:, :, frame]):
lmks_pred = self.pred_land[seq][:, :, frame]
else:
print("Warning! No face detected in frame {} of seq {}".format(frame, seq))
x = np.zeros((68, 3))
m = np.ones((68, 3), dtype=bool)
lmks_pred = ma.masked_array(x, mask=m)
return lmks_pred