Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/auto_pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: pytest
on: [pull_request, push]

jobs:
pytest:
# 3.7.12はubuntu-22.04では対応していない
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytorchのドキュメント上ではPython 3.8-3.11 is generally installed by default on any of our supported Linux distributions, which meets our recommendation.となっていて、3.12は対象に含める必要がないように思います(pyproject.tomlも)
https://pytorch.org/get-started/locally/#linux-python

poetry-version: ["1.8.2"]
steps:

# checkout repository
- name: checkout
uses: actions/checkout@v2

# install python
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# poetry install
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: ${{ matrix.poetry-version}}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

# vertural env cache
- name: Cache Poetry cache
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.poetry-version}}-workflow-${{ hashFiles('**/.github/workflows/auto_pytest.yml') }}

# cacheがヒットする場合はインストールをスキップする
- name: install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install

# pytestを実行する -> カバレッジもあわせてみる
# poetry run python -m pytest -v --cov=api --cov-report=term-missing
- name: Test with pytest
run: |
poetry run python -m pytest -v
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ authors = ["Your Name <you@example.com>"]
readme = "readme.md"

[tool.poetry.dependencies]
python = "^3.7"

# この辺が必要だけど、depedenciesに入れない
# pytorch = "^1.13"
# opencv-python = "^4"
# numpy = "^1"
python = "^3.10, <4"
opencv-python = "^4.2"
torch = "^2.0, <3"
torchvision = "*"
pyaml = "*"
matplotlib = "^3.8.4"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"

[build-system]
requires = ["poetry-core"]
Expand Down
Binary file added test/1200px-Mona_Lisa_detail_face.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions test/test_tddfa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from tddfa import TDDFA
import cv2

tddfa_detector = TDDFA.TDDFA(is_default=True)
def test_compatibility():
image = cv2.imread("test/1200px-Mona_Lisa_detail_face.jpg")
param_lst, _ = tddfa_detector(image, [[188, 273, 850, 1200]])

py37_result = [0.00043021038, -2.2211763e-05, -0.00016407926, 68.20835, -3.1360892e-06, 0.00044362253, -4.889862e-05, 72.131805, 0.00015704853, 6.1540784e-05, 0.00043100235, -66.67119, 14795.219, 43122.39, -104139.375, 49645.61, 50802.95, -57159.81, -3584.4697, -3378.7075, 248.1875, 15383.321, 1674.9199, 42209.395, -7130.957, -20172.92, -24713.234, 24252.492, -10538.282, 9153.316, -6992.184, 17604.594, 8674.711, -11750.123, -10611.462, -20278.764, -4537.2163, -5434.6855, -9495.967, -4691.093, -8608.049, 262.59766, -3375.6838, -1621.607, -1242.7206, -4286.5566, -5841.9893, -5585.337, 617.3279, 6857.7173, -4683.7583, 4274.805, -0.4117626, -0.92245513, -0.06505554, 0.124700665, 0.062449865, 0.050159305, 0.013293922, -0.056043975, 0.0028799754, 0.031191215]

for py37, param in zip(py37_result, list(param_lst[0])):
assert abs(py37 - param) < 0.01