hysts HF Staff commited on
Commit
7430609
·
1 Parent(s): 8cf953c
.pre-commit-config.yaml CHANGED
@@ -1,6 +1,6 @@
1
  repos:
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v4.5.0
4
  hooks:
5
  - id: check-executables-have-shebangs
6
  - id: check-json
@@ -13,48 +13,21 @@ repos:
13
  args: ["--fix=lf"]
14
  - id: requirements-txt-fixer
15
  - id: trailing-whitespace
16
- - repo: https://github.com/myint/docformatter
17
- rev: v1.7.5
18
  hooks:
19
- - id: docformatter
20
- args: ["--in-place"]
21
- - repo: https://github.com/pycqa/isort
22
- rev: 5.13.2
23
- hooks:
24
- - id: isort
25
- args: ["--profile", "black"]
26
  - repo: https://github.com/pre-commit/mirrors-mypy
27
- rev: v1.8.0
28
  hooks:
29
  - id: mypy
30
  args: ["--ignore-missing-imports"]
31
  additional_dependencies:
32
  [
33
  "types-python-slugify",
34
- "types-requests",
35
- "types-PyYAML",
36
  "types-pytz",
 
 
37
  ]
38
- - repo: https://github.com/psf/black
39
- rev: 24.2.0
40
- hooks:
41
- - id: black
42
- language_version: python3.10
43
- args: ["--line-length", "119"]
44
- - repo: https://github.com/kynan/nbstripout
45
- rev: 0.7.1
46
- hooks:
47
- - id: nbstripout
48
- args:
49
- [
50
- "--extra-keys",
51
- "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
52
- ]
53
- - repo: https://github.com/nbQA-dev/nbQA
54
- rev: 1.7.1
55
- hooks:
56
- - id: nbqa-black
57
- - id: nbqa-pyupgrade
58
- args: ["--py37-plus"]
59
- - id: nbqa-isort
60
- args: ["--float-to-top"]
 
1
  repos:
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
  hooks:
5
  - id: check-executables-have-shebangs
6
  - id: check-json
 
13
  args: ["--fix=lf"]
14
  - id: requirements-txt-fixer
15
  - id: trailing-whitespace
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ rev: v0.12.12
18
  hooks:
19
+ - id: ruff-check
20
+ args: ["--fix"]
21
+ - id: ruff-format
 
 
 
 
22
  - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.17.1
24
  hooks:
25
  - id: mypy
26
  args: ["--ignore-missing-imports"]
27
  additional_dependencies:
28
  [
29
  "types-python-slugify",
 
 
30
  "types-pytz",
31
+ "types-PyYAML",
32
+ "types-requests",
33
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.10
.vscode/extensions.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recommendations": [
3
+ "ms-python.python",
4
+ "charliermarsh.ruff",
5
+ "streetsidesoftware.code-spell-checker",
6
+ "tamasfe.even-better-toml"
7
+ ]
8
+ }
.vscode/settings.json CHANGED
@@ -2,29 +2,16 @@
2
  "editor.formatOnSave": true,
3
  "files.insertFinalNewline": false,
4
  "[python]": {
5
- "editor.defaultFormatter": "ms-python.black-formatter",
6
  "editor.formatOnType": true,
7
  "editor.codeActionsOnSave": {
 
8
  "source.organizeImports": "explicit"
9
  }
10
  },
11
  "[jupyter]": {
12
  "files.insertFinalNewline": false
13
  },
14
- "black-formatter.args": [
15
- "--line-length=119"
16
- ],
17
- "isort.args": ["--profile", "black"],
18
- "flake8.args": [
19
- "--max-line-length=119"
20
- ],
21
- "ruff.lint.args": [
22
- "--line-length=119"
23
- ],
24
  "notebook.output.scrolling": true,
25
- "notebook.formatOnCellExecution": true,
26
- "notebook.formatOnSave.enabled": true,
27
- "notebook.codeActionsOnSave": {
28
- "source.organizeImports": "explicit"
29
- }
30
  }
 
2
  "editor.formatOnSave": true,
3
  "files.insertFinalNewline": false,
4
  "[python]": {
5
+ "editor.defaultFormatter": "charliermarsh.ruff",
6
  "editor.formatOnType": true,
7
  "editor.codeActionsOnSave": {
8
+ "source.fixAll.ruff": "explicit",
9
  "source.organizeImports": "explicit"
10
  }
11
  },
12
  "[jupyter]": {
13
  "files.insertFinalNewline": false
14
  },
 
 
 
 
 
 
 
 
 
 
15
  "notebook.output.scrolling": true,
16
+ "notebook.formatOnSave.enabled": true
 
 
 
 
17
  }
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 💻
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 5.44.1
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -1,8 +1,5 @@
1
  #!/usr/bin/env python
2
 
3
- from __future__ import annotations
4
-
5
- import os
6
  import pathlib
7
 
8
  import cv2
@@ -25,9 +22,9 @@ def detect(image: np.ndarray) -> np.ndarray:
25
  return image
26
 
27
  res = image.copy()
28
- for pts, box in zip(landmarks, boxes):
29
- box = np.round(box[:4]).astype(int)
30
- cv2.rectangle(res, tuple(box[:2]), tuple(box[2:]), (0, 255, 0), 2)
31
  tl = pts.min(axis=0)
32
  br = pts.max(axis=0)
33
  size = (br - tl).max()
@@ -40,7 +37,7 @@ def detect(image: np.ndarray) -> np.ndarray:
40
  image_paths = sorted(pathlib.Path("images").glob("*.jpg"))
41
  examples = [[path.as_posix()] for path in image_paths]
42
 
43
- with gr.Blocks(css="style.css") as demo:
44
  gr.Markdown(DESCRIPTION)
45
  with gr.Row():
46
  with gr.Column():
@@ -53,15 +50,13 @@ with gr.Blocks(css="style.css") as demo:
53
  inputs=image,
54
  outputs=output,
55
  fn=detect,
56
- cache_examples=os.getenv("CACHE_EXAMPLES") == "1",
57
  )
58
 
59
  run_button.click(
60
  fn=detect,
61
  inputs=image,
62
  outputs=output,
63
- api_name="run",
64
  )
65
 
66
  if __name__ == "__main__":
67
- demo.queue(max_size=20).launch()
 
1
  #!/usr/bin/env python
2
 
 
 
 
3
  import pathlib
4
 
5
  import cv2
 
22
  return image
23
 
24
  res = image.copy()
25
+ for pts, box in zip(landmarks, boxes, strict=False):
26
+ box_int = np.round(box[:4]).astype(int)
27
+ cv2.rectangle(res, tuple(box_int[:2]), tuple(box_int[2:]), (0, 255, 0), 2)
28
  tl = pts.min(axis=0)
29
  br = pts.max(axis=0)
30
  size = (br - tl).max()
 
37
  image_paths = sorted(pathlib.Path("images").glob("*.jpg"))
38
  examples = [[path.as_posix()] for path in image_paths]
39
 
40
+ with gr.Blocks(css_paths="style.css") as demo:
41
  gr.Markdown(DESCRIPTION)
42
  with gr.Row():
43
  with gr.Column():
 
50
  inputs=image,
51
  outputs=output,
52
  fn=detect,
 
53
  )
54
 
55
  run_button.click(
56
  fn=detect,
57
  inputs=image,
58
  outputs=output,
 
59
  )
60
 
61
  if __name__ == "__main__":
62
+ demo.launch()
pyproject.toml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "1adrianb-face-alignment"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "face-alignment>=1.4.1",
9
+ "gradio>=5.44.1",
10
+ "hf-transfer>=0.1.9",
11
+ "opencv-python-headless>=4.12.0.88",
12
+ "torch==2.8.0",
13
+ "torchvision>=0.23.0",
14
+ ]
15
+
16
+ [tool.ruff]
17
+ line-length = 119
18
+
19
+ [tool.ruff.lint]
20
+ select = ["ALL"]
21
+ ignore = [
22
+ "COM812", # missing-trailing-comma
23
+ "D203", # one-blank-line-before-class
24
+ "D213", # multi-line-summary-second-line
25
+ "E501", # line-too-long
26
+ "SIM117", # multiple-with-statements
27
+ #
28
+ "D100", # undocumented-public-module
29
+ "D101", # undocumented-public-class
30
+ "D102", # undocumented-public-method
31
+ "D103", # undocumented-public-function
32
+ "D104", # undocumented-public-package
33
+ "D105", # undocumented-magic-method
34
+ "D107", # undocumented-public-init
35
+ "EM101", # raw-string-in-exception
36
+ "FBT001", # boolean-type-hint-positional-argument
37
+ "FBT002", # boolean-default-value-positional-argument
38
+ "PD901", # pandas-df-variable-name
39
+ "PGH003", # blanket-type-ignore
40
+ "PLR0913", # too-many-arguments
41
+ "PLR0915", # too-many-statements
42
+ "TRY003", # raise-vanilla-args
43
+ ]
44
+ unfixable = [
45
+ "F401", # unused-import
46
+ ]
47
+
48
+ [tool.ruff.lint.pydocstyle]
49
+ convention = "google"
50
+
51
+ [tool.ruff.lint.per-file-ignores]
52
+ "*.ipynb" = ["T201", "T203"]
53
+
54
+ [tool.ruff.format]
55
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,9 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  face-alignment==1.4.1
2
- numba==0.59.0
3
- numpy==1.26.4
4
- opencv-python-headless==4.9.0.80
5
- Pillow==10.2.0
6
- scikit-image==0.22.0
7
- scipy==1.12.0
8
- torch==2.0.1
9
- torchvision==0.15.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ aiofiles==24.1.0
4
+ # via gradio
5
+ annotated-types==0.7.0
6
+ # via pydantic
7
+ anyio==4.10.0
8
+ # via
9
+ # gradio
10
+ # httpx
11
+ # starlette
12
+ brotli==1.1.0
13
+ # via gradio
14
+ certifi==2025.8.3
15
+ # via
16
+ # httpcore
17
+ # httpx
18
+ # requests
19
+ charset-normalizer==3.4.3
20
+ # via requests
21
+ click==8.2.1
22
+ # via
23
+ # typer
24
+ # uvicorn
25
+ exceptiongroup==1.3.0
26
+ # via anyio
27
  face-alignment==1.4.1
28
+ # via 1adrianb-face-alignment (pyproject.toml)
29
+ fastapi==0.116.1
30
+ # via gradio
31
+ ffmpy==0.6.1
32
+ # via gradio
33
+ filelock==3.19.1
34
+ # via
35
+ # huggingface-hub
36
+ # torch
37
+ fsspec==2025.9.0
38
+ # via
39
+ # gradio-client
40
+ # huggingface-hub
41
+ # torch
42
+ gradio==5.44.1
43
+ # via 1adrianb-face-alignment (pyproject.toml)
44
+ gradio-client==1.12.1
45
+ # via gradio
46
+ groovy==0.1.2
47
+ # via gradio
48
+ h11==0.16.0
49
+ # via
50
+ # httpcore
51
+ # uvicorn
52
+ hf-transfer==0.1.9
53
+ # via 1adrianb-face-alignment (pyproject.toml)
54
+ hf-xet==1.1.9
55
+ # via huggingface-hub
56
+ httpcore==1.0.9
57
+ # via httpx
58
+ httpx==0.28.1
59
+ # via
60
+ # gradio
61
+ # gradio-client
62
+ # safehttpx
63
+ huggingface-hub==0.34.4
64
+ # via
65
+ # gradio
66
+ # gradio-client
67
+ idna==3.10
68
+ # via
69
+ # anyio
70
+ # httpx
71
+ # requests
72
+ imageio==2.37.0
73
+ # via scikit-image
74
+ jinja2==3.1.6
75
+ # via
76
+ # gradio
77
+ # torch
78
+ lazy-loader==0.4
79
+ # via scikit-image
80
+ llvmlite==0.44.0
81
+ # via numba
82
+ markdown-it-py==4.0.0
83
+ # via rich
84
+ markupsafe==3.0.2
85
+ # via
86
+ # gradio
87
+ # jinja2
88
+ mdurl==0.1.2
89
+ # via markdown-it-py
90
+ mpmath==1.3.0
91
+ # via sympy
92
+ networkx==3.4.2
93
+ # via
94
+ # scikit-image
95
+ # torch
96
+ numba==0.61.2
97
+ # via face-alignment
98
+ numpy==2.2.6
99
+ # via
100
+ # face-alignment
101
+ # gradio
102
+ # imageio
103
+ # numba
104
+ # opencv-python
105
+ # opencv-python-headless
106
+ # pandas
107
+ # scikit-image
108
+ # scipy
109
+ # tifffile
110
+ # torchvision
111
+ nvidia-cublas-cu12==12.8.4.1
112
+ # via
113
+ # nvidia-cudnn-cu12
114
+ # nvidia-cusolver-cu12
115
+ # torch
116
+ nvidia-cuda-cupti-cu12==12.8.90
117
+ # via torch
118
+ nvidia-cuda-nvrtc-cu12==12.8.93
119
+ # via torch
120
+ nvidia-cuda-runtime-cu12==12.8.90
121
+ # via torch
122
+ nvidia-cudnn-cu12==9.10.2.21
123
+ # via torch
124
+ nvidia-cufft-cu12==11.3.3.83
125
+ # via torch
126
+ nvidia-cufile-cu12==1.13.1.3
127
+ # via torch
128
+ nvidia-curand-cu12==10.3.9.90
129
+ # via torch
130
+ nvidia-cusolver-cu12==11.7.3.90
131
+ # via torch
132
+ nvidia-cusparse-cu12==12.5.8.93
133
+ # via
134
+ # nvidia-cusolver-cu12
135
+ # torch
136
+ nvidia-cusparselt-cu12==0.7.1
137
+ # via torch
138
+ nvidia-nccl-cu12==2.27.3
139
+ # via torch
140
+ nvidia-nvjitlink-cu12==12.8.93
141
+ # via
142
+ # nvidia-cufft-cu12
143
+ # nvidia-cusolver-cu12
144
+ # nvidia-cusparse-cu12
145
+ # torch
146
+ nvidia-nvtx-cu12==12.8.90
147
+ # via torch
148
+ opencv-python==4.12.0.88
149
+ # via face-alignment
150
+ opencv-python-headless==4.12.0.88
151
+ # via 1adrianb-face-alignment (pyproject.toml)
152
+ orjson==3.11.3
153
+ # via gradio
154
+ packaging==25.0
155
+ # via
156
+ # gradio
157
+ # gradio-client
158
+ # huggingface-hub
159
+ # lazy-loader
160
+ # scikit-image
161
+ pandas==2.3.2
162
+ # via gradio
163
+ pillow==11.3.0
164
+ # via
165
+ # gradio
166
+ # imageio
167
+ # scikit-image
168
+ # torchvision
169
+ pydantic==2.11.7
170
+ # via
171
+ # fastapi
172
+ # gradio
173
+ pydantic-core==2.33.2
174
+ # via pydantic
175
+ pydub==0.25.1
176
+ # via gradio
177
+ pygments==2.19.2
178
+ # via rich
179
+ python-dateutil==2.9.0.post0
180
+ # via pandas
181
+ python-multipart==0.0.20
182
+ # via gradio
183
+ pytz==2025.2
184
+ # via pandas
185
+ pyyaml==6.0.2
186
+ # via
187
+ # gradio
188
+ # huggingface-hub
189
+ requests==2.32.5
190
+ # via huggingface-hub
191
+ rich==14.1.0
192
+ # via typer
193
+ ruff==0.12.12
194
+ # via gradio
195
+ safehttpx==0.1.6
196
+ # via gradio
197
+ scikit-image==0.25.2
198
+ # via face-alignment
199
+ scipy==1.15.3
200
+ # via
201
+ # face-alignment
202
+ # scikit-image
203
+ semantic-version==2.10.0
204
+ # via gradio
205
+ setuptools==80.9.0
206
+ # via triton
207
+ shellingham==1.5.4
208
+ # via typer
209
+ six==1.17.0
210
+ # via python-dateutil
211
+ sniffio==1.3.1
212
+ # via anyio
213
+ starlette==0.47.3
214
+ # via
215
+ # fastapi
216
+ # gradio
217
+ sympy==1.14.0
218
+ # via torch
219
+ tifffile==2025.5.10
220
+ # via scikit-image
221
+ tomlkit==0.13.3
222
+ # via gradio
223
+ torch==2.8.0
224
+ # via
225
+ # 1adrianb-face-alignment (pyproject.toml)
226
+ # face-alignment
227
+ # torchvision
228
+ torchvision==0.23.0
229
+ # via 1adrianb-face-alignment (pyproject.toml)
230
+ tqdm==4.67.1
231
+ # via
232
+ # face-alignment
233
+ # huggingface-hub
234
+ triton==3.4.0
235
+ # via torch
236
+ typer==0.17.3
237
+ # via gradio
238
+ typing-extensions==4.15.0
239
+ # via
240
+ # anyio
241
+ # exceptiongroup
242
+ # fastapi
243
+ # gradio
244
+ # gradio-client
245
+ # huggingface-hub
246
+ # pydantic
247
+ # pydantic-core
248
+ # starlette
249
+ # torch
250
+ # typer
251
+ # typing-inspection
252
+ # uvicorn
253
+ typing-inspection==0.4.1
254
+ # via pydantic
255
+ tzdata==2025.2
256
+ # via pandas
257
+ urllib3==2.5.0
258
+ # via requests
259
+ uvicorn==0.35.0
260
+ # via gradio
261
+ websockets==15.0.1
262
+ # via gradio-client
uv.lock ADDED
The diff for this file is too large to render. See raw diff