Skip to content

Commit

Permalink
Merge pull request #3 from Rouast-Labs/windows-support
Browse files Browse the repository at this point in the history
Windows support
  • Loading branch information
prouast authored Jul 18, 2024
2 parents fdfbc70 + c4b3760 commit 84c693b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
46 changes: 39 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion vitallens/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vitallens/methods/simple_rppg_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion vitallens/methods/vitallens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions vitallens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 84c693b

Please sign in to comment.