Skip to content

Commit c7a3ff7

Browse files
Merge pull request #17 from tomas-gajarsky/feature/conda
Feature/conda
2 parents 06b1f5d + d112c1d commit c7a3ff7

File tree

11 files changed

+72
-35
lines changed

11 files changed

+72
-35
lines changed

.dockerignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ venv.bak/
7373
# Documentation
7474
docs/
7575

76-
# FaceTorch specific
77-
data/images/collages/
78-
output/
76+
# Hydra
77+
outputs/
78+
79+
# facetorch specific
80+
models/

.github/workflows/conda-env.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
conda env update --file environment.yml --name base
25+
- name: Install facetorch from conda-forge
26+
run: |
27+
conda install -c conda-forge facetorch

.github/workflows/docker-push.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515
env:
1616
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1717
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
18-
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.io
18+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.io
1919
- name: Docker compose push facetorch
2020
run: docker compose push facetorch
2121
docker-push-gpu:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v2
2525
- name: Docker compose build facetorch-gpu
26-
run: docker compose build facetorch-gpu
26+
run: docker compose build facetorch-gpu-no-device
2727
- name: Login to Docker hub
2828
env:
2929
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
3030
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
31-
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.io
31+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.io
3232
- name: Docker compose push facetorch-gpu
33-
run: docker compose push facetorch-gpu
33+
run: docker compose push facetorch-gpu-no-device

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ cython_debug/
108108
## User folders
109109
models/
110110
outputs/
111+
tests/data/output/

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Change Log
22

3+
## 0.0.8
4+
5+
Released on August 12, 2022.
6+
7+
### Added
8+
9+
* conda-forge documentation
10+
* entrypoints to docker compose services
11+
12+
### Changed
13+
14+
* workflow for testing conda installation
15+
* workflow for pushing facetorch-gpu Docker image to Docker Hub
16+
17+
318
## 0.0.7
419

520
Released on August 11, 2022.
@@ -18,6 +33,7 @@ Released on August 10, 2022.
1833

1934
* GitHub workflows
2035

36+
2137
## 0.0.5
2238

2339
Released on August 7, 2022.

README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
![build](https://github.com/tomas-gajarsky/facetorch/actions/workflows/build.yml/badge.svg?branch=main)
33
![lint](https://github.com/tomas-gajarsky/facetorch/actions/workflows/lint.yml/badge.svg?branch=main)
44
[![PyPI](https://img.shields.io/pypi/v/facetorch)](https://pypi.org/project/facetorch/)
5+
[![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/facetorch)](https://anaconda.org/conda-forge/facetorch)
6+
57
[![PyPI - License](https://img.shields.io/pypi/l/facetorch)](https://raw.githubusercontent.com/tomas-gajarsky/facetorch/main/LICENSE)
68
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
79

8-
[documentation](https://tomas-gajarsky.github.io/facetorch/facetorch/index.html)
10+
11+
[Documentation](https://tomas-gajarsky.github.io/facetorch/facetorch/index.html), [Docker Hub](https://hub.docker.com/repository/docker/tomasgajarsky/facetorch) [(GPU)](https://hub.docker.com/repository/docker/tomasgajarsky/facetorch-gpu)
912

1013
Facetorch is a Python library that can detect faces and analyze facial features using deep neural networks. The goal is to gather open sourced face analysis models from the community, optimize them for performance using TorchScript and combine them to create a face analysis tool that one can:
1114

@@ -23,7 +26,10 @@ The models are not perfect and may be biased.
2326
```bash
2427
pip install facetorch
2528
```
26-
29+
[Conda](https://anaconda.org/conda-forge/facetorch)
30+
```bash
31+
conda install -c conda-forge facetorch
32+
```
2733
## Usage
2834

2935
### Prerequisites
@@ -39,7 +45,7 @@ Docker Compose provides an easy way of building a working facetorch environment
3945

4046
### Configure
4147

42-
The project is configured by files located in *conf* with the main file *conf/config.yaml*.
48+
The project is configured by files located in *conf* with the main file: *conf/config.yaml*.
4349

4450
## Components
4551
FaceAnalyzer is the main class of facetorch as it is the orchestrator responsible for initializing and running the following components:
@@ -72,8 +78,8 @@ analyzer
7278
| RetinaFace | biubug6 | MIT license | 1 |
7379

7480
1. biubug6
75-
* code: [biubug6/Pytorch_Retinaface](https://github.com/biubug6/Pytorch_Retinaface)
76-
* paper: [RetinaFace: Single-Shot Multi-Level Face Localisation in the Wild](https://openaccess.thecvf.com/content_CVPR_2020/html/Deng_RetinaFace_Single-Shot_Multi-Level_Face_Localisation_in_the_Wild_CVPR_2020_paper.html)
81+
* code: [Pytorch_Retinaface](https://github.com/biubug6/Pytorch_Retinaface)
82+
* paper: [Deng et al. - RetinaFace: Single-Shot Multi-Level Face Localisation in the Wild](https://openaccess.thecvf.com/content_CVPR_2020/html/Deng_RetinaFace_Single-Shot_Multi-Level_Face_Localisation_in_the_Wild_CVPR_2020_paper.html)
7783

7884

7985
### Predictor
@@ -137,8 +143,8 @@ analyzer
137143

138144
## Development
139145
Run the Docker container:
140-
* CPU: ```docker compose -f docker-compose.dev.yml run facetorch-dev bash```
141-
* GPU: ```docker compose -f docker-compose.dev.yml run facetorch-dev-gpu bash```
146+
* CPU: ```docker compose -f docker-compose.dev.yml run facetorch-dev```
147+
* GPU: ```docker compose -f docker-compose.dev.yml run facetorch-dev-gpu```
142148

143149
### Add predictor
144150
#### Prerequisites
@@ -172,10 +178,10 @@ the requirements of the new model.
172178
2. Write a test for the new predictor in ```/tests/test_<predictor_name>.py```
173179

174180
#### Test and submit
175-
1. Run linting test: ```flake8 --config=.flake8```
176-
2. Run tests and generate coverage: ```pytest tests --verbose --cov-report html:coverage --cov facetorch```
177-
3. Add the new predictor to the README model table.
178-
4. Submit a pull request to add the new predictor to the main codebase.
181+
1. Run linting: ```black facetorch```
182+
2. Add the new predictor to the README model table.
183+
3. Update CHANGELOG and version
184+
4. Submit a pull request to the repository
179185

180186

181187
### Update environment
@@ -189,16 +195,16 @@ GPU:
189195
* Lock the environment: ```conda lock -p linux-64 -f gpu.environment.yml --lockfile gpu.conda-lock.yml```
190196
* Install the locked environment: ```conda-lock install --name env gpu.conda-lock.yml```
191197

198+
### Run tests + coverage
199+
* Run tests and generate coverage: ```pytest tests --verbose --cov-report html:coverage --cov facetorch```
200+
192201
### Generate documentation
193202
* Generate documentation from docstrings using pdoc3: ```pdoc --html facetorch --output-dir docs --force --template-dir pdoc/templates/```
194203

195204
### Profiling
196205
1. Run profiling of the example script: ```python -m cProfile -o profiling/example.prof scripts/example.py```
197206
2. Open profiling file in the browser: ```snakeviz profiling/example.prof```
198207

199-
### Docker Hub
200-
[facetorch Docker Hub](https://hub.docker.com/repository/docker/tomasgajarsky/facetorch)
201-
202208
## Acknowledgements
203209
I want to thank the open source code community and the researchers who have published the models. This project would not be possible without their work.
204210

docker-compose.dev.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ services:
1111
ports:
1212
- "8080:8080"
1313
entrypoint: ["/bin/bash"]
14-
environment:
15-
- PYTHONPATH="$${PYTHONPATH}:/opt/facetorch"
1614

1715
facetorch-dev-gpu:
1816
build:
@@ -32,25 +30,22 @@ services:
3230
capabilities: [ gpu ]
3331
entrypoint: ["/bin/bash"]
3432

35-
facetorch-dev-example:
33+
facetorch-tests:
3634
build:
3735
context: .
38-
dockerfile: ./docker/Dockerfile.dev
36+
dockerfile: ./docker/Dockerfile.tests
3937
volumes:
4038
- ./:/opt/facetorch
4139
ports:
4240
- "8080:8080"
43-
entrypoint: ["conda", "run", "--no-capture-output", "-n", "env", "python", "scripts/example.py"]
41+
entrypoint: ["conda", "run", "--no-capture-output", "-n", "env", "pytest", "-v", "--cov=facetorch", "--cov-report=term", "--cov-fail-under=95"]
4442

45-
facetorch-tests:
43+
facetorch-dev-example:
4644
build:
4745
context: .
48-
dockerfile: ./docker/Dockerfile.tests
46+
dockerfile: ./docker/Dockerfile.dev
4947
volumes:
5048
- ./:/opt/facetorch
5149
ports:
5250
- "8080:8080"
53-
# entrypoint: ["/bin/bash"]
54-
# entrypoint: ["conda", "run", "--no-capture-output", "-n", "env", "--cwd", "/opt/facetorch", "pip", "list"]
55-
entrypoint: ["conda", "run", "--no-capture-output", "-n", "env", "pytest", "-v", "--cov=facetorch", "--cov-report=term", "--cov-fail-under=95"]
56-
# environment: [ "PYTHONPATH=/opt/facetorch" ]
51+
entrypoint: ["conda", "run", "--no-capture-output", "-n", "env", "python", "scripts/example.py"]

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ services:
99
dockerfile: ./docker/Dockerfile
1010
volumes:
1111
- ./:/opt/facetorch
12+
entrypoint: ["/bin/bash"]
1213

1314
facetorch-gpu:
1415
image: tomasgajarsky/facetorch-gpu:latest
@@ -24,4 +25,13 @@ services:
2425
- driver: nvidia
2526
device_ids: ["0"]
2627
capabilities: [gpu]
28+
entrypoint: ["/bin/bash"]
2729

30+
facetorch-gpu-no-device:
31+
image: tomasgajarsky/facetorch-gpu:latest
32+
build:
33+
context: .
34+
dockerfile: ./docker/Dockerfile.gpu
35+
volumes:
36+
- ./:/opt/facetorch
37+
entrypoint: ["/bin/bash"]

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ WORKDIR $WORKDIR
88
RUN pip install --upgrade pip
99

1010
# Install facetorch from PyPI
11-
RUN pip install facetorch
11+
RUN pip install facetorch
12+
13+
COPY . .

docker/Dockerfile.gpu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ RUN ln -sf /usr/bin/python3.9 /usr/bin/python3 & \
2222
RUN pip install --upgrade pip
2323

2424
# Install facetorch from PyPI
25-
RUN pip install facetorch
25+
RUN pip install facetorch
26+
27+
COPY . .

0 commit comments

Comments
 (0)