diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72f5d12..c3ca85b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,18 +2,17 @@ name: Tests on: push: - branches: ["main", "development"] + branches: ['*'] pull_request: - branches: ["main", "development"] + branches: ["main"] jobs: - build: + linux: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest strategy: matrix: python-version: ["3.8", "3.9", "3.10"] - steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -32,8 +31,41 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install ".[test]" - - name: Set API_URL for development branch - if: github.ref == 'refs/heads/development' + - name: Set development API_URL for non-main branches + if: github.ref != 'refs/heads/main' + run: echo "API_URL=https://api.rouast.com/vitallens-dev" >> $GITHUB_ENV + - name: Lint with flake8 + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - name: Test with pytest + env: + VITALLENS_DEV_API_KEY: ${{ secrets.VITALLENS_DEV_API_KEY }} + run: | + pytest + + windows: + + runs-on: windows-latest + steps: + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install ffmpeg + uses: Iamshankhadeep/setup-ffmpeg@v1.2 + with: + version: "4.4" + token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout vitallens-python + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Install vitallens-python and dependencies + run: | + python -m pip install --upgrade pip + python -m pip install ".[test]" + - name: Set development API_URL for non-main branches + if: github.ref != 'refs/heads/main' run: echo "API_URL=https://api.rouast.com/vitallens-dev" >> $GITHUB_ENV - name: Lint with flake8 run: | diff --git a/MANIFEST.in b/MANIFEST.in index 1080d26..1ba02b1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,6 @@ recursive-include vitallens/configs * recursive-include vitallens/methods * recursive-include vitallens/models * recursive-include tests * -prune **/__pycache__ +global-exclude .DS_Store +prune **/__pycache__ +prune .github/workflows diff --git a/pyproject.toml b/pyproject.toml index 44f809f..3ff2e71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ dependencies = [ "importlib_resources", "numpy", "onnxruntime", - "prpy[ffmpeg,numpy_min]>=0.2.7", + "prpy[ffmpeg,numpy_min]>=0.2.8", "python-dotenv", "pyyaml", "requests", 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