diff --git a/tests/conftest.py b/tests/conftest.py index fbdb723..c265f6a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import numpy as np import os from prpy.ffmpeg.probe import probe_video from prpy.ffmpeg.readwrite import read_video_from_path @@ -52,7 +53,7 @@ def test_video_faces(request): test_video_fps = request.getfixturevalue('test_video_fps') boxes, _ = det(test_video_ndarray, fps=test_video_fps) boxes = (boxes * [test_video_ndarray.shape[2], test_video_ndarray.shape[1], test_video_ndarray.shape[2], test_video_ndarray.shape[1]]).astype(int) - return boxes[:,0] + return boxes[:,0].astype(np.int64) @pytest.fixture(scope='session') def test_dev_api_key(): diff --git a/vitallens/client.py b/vitallens/client.py index c3d8ec1..2fc151c 100644 --- a/vitallens/client.py +++ b/vitallens/client.py @@ -160,7 +160,7 @@ def __call__( logging.warn("No faces to analyze") return [] # Convert to absolute units - faces = (faces_rel * [width, height, width, height]).astype(int) + faces = (faces_rel * [width, height, width, height]).astype(np.int64) # Face axis first faces = np.transpose(faces, (1, 0, 2)) # Check if the faces are valid diff --git a/vitallens/methods/simple_rppg_method.py b/vitallens/methods/simple_rppg_method.py index 0d24305..43e2fea 100644 --- a/vitallens/methods/simple_rppg_method.py +++ b/vitallens/methods/simple_rppg_method.py @@ -62,7 +62,7 @@ def __call__( Args: frames: The video frames. Shape (n_frames, h, w, c) - faces: The face detection boxes. Shape (n_frames, 4) in form (x0, y0, x1, y1) + faces: The face detection boxes as np.int64. Shape (n_frames, 4) in form (x0, y0, x1, y1) fps: The rate at which video was sampled. override_fps_target: Override the method's default inference fps (optional). Returns: diff --git a/vitallens/methods/vitallens.py b/vitallens/methods/vitallens.py index a8ca58b..d60ea1d 100644 --- a/vitallens/methods/vitallens.py +++ b/vitallens/methods/vitallens.py @@ -61,7 +61,7 @@ def __call__( Args: frames: The video to analyze. Either a np.ndarray of shape (n_frames, h, w, 3) in unscaled uint8 RGB format, or a path to a video file. - faces: The face detection boxes. Shape (n_frames, 4) in form (x0, y0, x1, y1) + faces: The face detection boxes as np.int64. Shape (n_frames, 4) in form (x0, y0, x1, y1) fps: The rate at which video was sampled. override_fps_target: Override the method's default inference fps (optional). Returns: diff --git a/vitallens/utils.py b/vitallens/utils.py index 412eae9..1b7e414 100644 --- a/vitallens/utils.py +++ b/vitallens/utils.py @@ -182,9 +182,9 @@ def check_faces( if faces is None: # Assume that each entire frame is a single face logging.info("No faces given - assuming that frames have been cropped to a single face") - faces = np.tile(np.asarray([0, 0, w, h]), (n_frames, 1))[np.newaxis] # (1, n_frames, 4) + faces = np.tile(np.asarray([0, 0, w, h], dtype=np.int64), (n_frames, 1))[np.newaxis] # (1, n_frames, 4) else: - faces = np.asarray(faces) + faces = np.asarray(faces, dtype=np.int64) if faces.shape[-1] != 4: raise ValueError("Face detections must be in flat point form") if len(faces.shape) == 1: # Single face detection given - repeat for n_frames