-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
177 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: py | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
cache: "pip" | ||
- name: Install Dependencies | ||
run: | | ||
pip install -e . | ||
pip install -r requirements.txt | ||
- run: sh download_ml_models.sh | ||
- run: python -m pytest tests --isort --black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,7 @@ isort | |
black | ||
fastapi | ||
uvicorn | ||
resvg_python | ||
resvg_python | ||
pytest | ||
pytest-black | ||
pytest-isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import cv2 | ||
|
||
|
||
def optimize_image(image, width=480, brightness=50): | ||
if image.shape[1] == width: | ||
return image | ||
|
||
aspect_ratio = float(image.shape[0]) / float(image.shape[1]) | ||
|
||
height = round(width * aspect_ratio) | ||
|
||
resized_image = cv2.resize(image, (width, height)) | ||
brightened_image = cv2.convertScaleAbs(resized_image, alpha=1, beta=brightness) | ||
|
||
return brightened_image |
Empty file.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import os | ||
from glob import glob | ||
|
||
import cv2 | ||
import numpy as np | ||
import pytest | ||
import resvg_python | ||
|
||
from src.svg.model import Model | ||
from src.tracking.tracking import Tracking | ||
from tests.utils import compare_img, overlay_webcam | ||
|
||
with open("tests/models/face.svg") as file: | ||
face_model_file = file.read() | ||
|
||
with open("tests/models/normal.svg") as file: | ||
normal_model_file = file.read() | ||
|
||
|
||
@pytest.mark.parametrize("file", glob("tests/images/test_*")) | ||
def test_basic_model(file): | ||
model = Model(face_model_file) | ||
|
||
tracking = Tracking() | ||
tracking.set_model(model) | ||
|
||
frame = cv2.imread(file) | ||
|
||
tracking.process(frame) | ||
|
||
while tracking.last_frame_ms is None: | ||
pass | ||
|
||
image_bytes = resvg_python.svg_to_png(model.tostring()) | ||
image_decoded = cv2.imdecode(np.array(bytearray(image_bytes)), cv2.IMREAD_COLOR) | ||
|
||
final_image = overlay_webcam(frame, image_decoded) | ||
|
||
assert compare_img(os.path.basename(file), "basic_model", final_image) < 4.5 | ||
|
||
|
||
@pytest.mark.parametrize("file", glob("tests/images/test_*")) | ||
def test_normal_model(file): | ||
model = Model(normal_model_file) | ||
|
||
tracking = Tracking() | ||
tracking.set_model(model) | ||
|
||
frame = cv2.imread(file) | ||
|
||
tracking.process(frame) | ||
|
||
while tracking.last_frame_ms is None: | ||
pass | ||
|
||
image_bytes = resvg_python.svg_to_png(model.tostring()) | ||
image_decoded = cv2.imdecode(np.array(bytearray(image_bytes)), cv2.IMREAD_COLOR) | ||
|
||
final_image = overlay_webcam(frame, image_decoded) | ||
|
||
assert compare_img(os.path.basename(file), "normal_model", final_image) < 4.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters