Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Jun 18, 2024
1 parent ce754fd commit f88e7d1
Show file tree
Hide file tree
Showing 28 changed files with 6,092 additions and 875 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/actions_requirements.txt
poetry install --with dev
- name: Test with pytest
run: |
python --version
Expand Down
82 changes: 82 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# can be used to exclude certain regex patterns or paths
exclude: '^$'
# if set to true, fails on first failure
fail_fast: false
repos:
# The following pre-commit hooks could be very useful.
# They are not part of CI/CD, so use or remove them as you please
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: name-tests-test
args: [
"--pytest-test-first" # test_.*\.py
#"--pytest" # .*_test\.py
#"--unittest" # test.*\.py
]
- id: check-added-large-files
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-yaml
args: ['--unsafe']
- id: check-toml
- id: check-xml
- id: detect-private-key

- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.13.0
hooks:
- id: markdownlint-cli2
args: [ "--fix", "--config", ".markdownlint.yaml" ]

# part of CI/CD
- repo: local
hooks:
- id: poetry-check
name: poetry-check --lock
description: run poetry check to validate config
entry: poetry check --lock
language: python
pass_filenames: false
files: ^(.*/)?pyproject\.toml$
# - id: poetry-export
# name: poetry-export
# description: run poetry export to sync lock file with requirements.txt
# entry: poetry export
# language: python
# pass_filenames: false
# files: ^(.*/)?poetry\.lock$
# args: ["-f", "requirements.txt", "-o", "requirements.txt"]
# - id: poetry-export-dev
# name: poetry-export --with-dev
# description: run poetry export to sync lock file with requirements.txt
# entry: poetry export
# language: python
# pass_filenames: false
# files: ^(.*/)?poetry\.lock$
# args: ["--with", "dev", "-f", "requirements.txt", "-o", "requirements-dev.txt"]

- id: ruff-format
name: ruff-format
description: "Run 'ruff format' for extremely fast Python formatting"
entry: ruff format --force-exclude
language: python
types_or: [python, pyi]
args: []
- id: ruff
name: ruff
description: Run 'ruff' for extremely fast Python linting
entry: ruff check --force-exclude
language: python
types_or: [python, pyi]
args: [--fix]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Also included in this repo is an efficient pytorch implementation of MTCNN for f
```bash
# With pip:
pip install facenet-pytorch

# or clone this repo, removing the '-' to allow python imports:
git clone https://github.com/timesler/facenet-pytorch.git facenet_pytorch

# or use a docker container (see https://github.com/timesler/docker-jupyter-dl-gpu):
docker run -it --rm timesler/jupyter-dl-gpu pip install facenet-pytorch && ipython
```
Expand All @@ -50,10 +50,10 @@ Also included in this repo is an efficient pytorch implementation of MTCNN for f

```py
from facenet_pytorch import MTCNN, InceptionResnetV1
# If required, create a face detection pipeline using MTCNN:
mtcnn = MTCNN(image_size=<image_size>, margin=<margin>)
# Create an inception resnet (in eval mode):
resnet = InceptionResnetV1(pretrained='vggface2').eval()
```
Expand All @@ -62,7 +62,7 @@ Also included in this repo is an efficient pytorch implementation of MTCNN for f

```py
from PIL import Image
img = Image.open(<image path>)
# Get cropped and prewhitened image tensor
Expand Down Expand Up @@ -176,7 +176,7 @@ The package and any of the example notebooks can be run with docker (or nvidia-d
docker run --rm -p 8888:8888
-v ./facenet-pytorch:/home/jovyan timesler/jupyter-dl-gpu \
-v <path to data>:/home/jovyan/data
pip install facenet-pytorch && jupyter lab
pip install facenet-pytorch && jupyter lab
```
Navigate to the examples/ directory and run any of the ipython notebooks.
Expand Down
8 changes: 4 additions & 4 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Pytorch 模型权重使用从 David Sandberg 的 [tensorflow Facenet repo](https
## 快速启动

1. 安装:

````bash
# 使用pip安装:
pip install facenet-pytorch
Expand All @@ -85,7 +85,7 @@ docker run -it --rm timesler/jupyter-dl-gpu pip install facenet-pytorch && ipyth
````

2. 在python中,导入 facenet-pytorch 并实例化模型:

````python
from facenet_pytorch import MTCNN, InceptionResnetV1

Expand All @@ -97,7 +97,7 @@ resnet = InceptionResnetV1(pretrained='vggface2').eval()
````

3. 处理图像:

````python
from PIL import Image

Expand Down Expand Up @@ -214,7 +214,7 @@ MTCNN 可用于构建人脸跟踪系统(使用 `MTCNN.detect()` 方法)。
docker run --rm -p 8888:8888
-v ./facenet-pytorch:/home/jovyan timesler/jupyter-dl-gpu \
-v <path to data>:/home/jovyan/data
pip install facenet-pytorch && jupyter lab
pip install facenet-pytorch && jupyter lab
````

导航到 example/ 目录并运行任何 ipython 笔记本。
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ coverage:
status:
project: off
patch: off
codecov:
codecov:
token: 1e4f3aaa-9c74-4888-9408-71cc7fcfb64c
Loading

0 comments on commit f88e7d1

Please sign in to comment.