Skip to content

Commit 0ddb48a

Browse files
committed
Merge branch 'dev' of https://github.com/RichieHakim/face-rhythm into dev
2 parents 11e4169 + adfda30 commit 0ddb48a

File tree

12 files changed

+546
-1689
lines changed

12 files changed

+546
-1689
lines changed

face_rhythm/alignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import ffmpeg
1010
import matplotlib.pyplot as plt
1111
import cv2
12-
from tqdm import tqdm
12+
from tqdm.auto import tqdm
1313

1414
from face_rhythm import rois
1515

face_rhythm/data_importing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import multiprocessing as mp
55

66
import numpy as np
7-
from tqdm import tqdm
7+
from tqdm.auto import tqdm
88
import decord
99

1010
from .util import FR_Module

face_rhythm/decomposition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77

88
import numpy as np
9-
from tqdm import tqdm
9+
from tqdm.auto import tqdm
1010
import torch
1111
import tensorly as tl
1212
import einops

face_rhythm/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import cv2
1717
import decord
1818
import torch
19-
from tqdm import tqdm
19+
from tqdm.auto import tqdm
2020
import yaml
2121
import zipfile
2222
import pickle

face_rhythm/pipelines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ def pipeline_basic(params):
9494

9595
if 'load_videos' in params['steps']:
9696

97+
## Load video data from the specified directory.\
98+
print(f'Loading video data from {directory_videos}...') if params['project']['verbose'] > 1 else None
9799
paths_videos = fr.helpers.find_paths(
98100
dir_outer=directory_videos,
99101
reMatch=filename_videos_strMatch, ## string to use to search for files in directory. Uses regular expressions!
100102
depth=0, ## how many folders deep to search
103+
verbose=params['project']['verbose'],
101104
)[:]
102105

103106
pprint('Paths to videos:') if params['project']['verbose'] > 1 else None

face_rhythm/point_tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33

44
import numpy as np
5-
from tqdm import tqdm
5+
from tqdm.auto import tqdm
66
import decord
77
import cv2
88
import torch

face_rhythm/rois.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import cv2
66
import numpy as np
77
import scipy.interpolate
8-
from tqdm import tqdm
8+
from tqdm.auto import tqdm
99
import matplotlib.pyplot as plt
1010

1111
from .util import FR_Module
@@ -144,7 +144,20 @@ def __init__(
144144
)
145145
self.set_point_positions(point_positions) if point_positions is not None else None
146146

147+
self._fill_config_runInfo_runData(
148+
path_file=self._path_file,
149+
coords_rois=self.roi_points,
150+
point_positions=self.point_positions,
151+
mask_images=self.mask_images,
152+
)
147153

154+
def _fill_config_runInfo_runData(
155+
self,
156+
path_file=None,
157+
coords_rois=None,
158+
point_positions=None,
159+
mask_images=None,
160+
):
148161
## For FR_Module compatibility
149162
self.config = {
150163
"select_mode": self._select_mode,
@@ -164,8 +177,6 @@ def __init__(
164177
"point_positions": self.point_positions,
165178
"exampleImage": self.exampleImage,
166179
}
167-
# ## Append the self.run_info data to self.run_data
168-
# self.run_data.update(self.run_info)
169180

170181
def make_points(self, rois, point_spacing=10):
171182
"""
@@ -329,8 +340,34 @@ def plot_rois(self, image=None, **kwargs_imshow):
329340
## show figure
330341
plt.show()
331342
return fig, ax
343+
344+
def fliplr(self):
345+
"""
346+
Flip the ROIs left-right. In place
347+
"""
348+
if hasattr(self, 'exampleImage'):
349+
if self.exampleImage is not None:
350+
self.exampleImage = np.fliplr(self.exampleImage)
332351

333-
352+
if hasattr(self, 'mask_images'):
353+
if self.mask_images is not None:
354+
self.mask_images = {k: np.fliplr(m) for k, m in self.mask_images.items()}
355+
356+
if hasattr(self, 'roi_points'):
357+
if self.roi_points is not None:
358+
for k, p in self.roi_points.items():
359+
self.roi_points[k][:, 0] = self.img_hw[1] - p[:, 0]
360+
361+
if hasattr(self, 'point_positions'):
362+
if self.point_positions is not None:
363+
self.point_positions[:, 0] = self.img_hw[1] - self.point_positions[:, 0]
364+
365+
self._fill_config_runInfo_runData(
366+
path_file=self._path_file,
367+
coords_rois=self.roi_points,
368+
point_positions=self.point_positions,
369+
mask_images=self.mask_images,
370+
)
334371

335372
class _Select_ROI:
336373
"""

face_rhythm/spectral_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66
import torch
7-
from tqdm import tqdm
7+
from tqdm.auto import tqdm
88

99
from .util import FR_Module
1010
from . import helpers

face_rhythm/visualization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import cv2
88
import torch
99
# import scipy.sparse
10-
from tqdm import tqdm
10+
from tqdm.auto import tqdm
1111

1212
from .helpers import BufferedVideoReader
1313

0 commit comments

Comments
 (0)