hysts HF staff commited on
Commit
fa33f80
·
1 Parent(s): aea76d4
.pre-commit-config.yaml CHANGED
@@ -1,6 +1,6 @@
1
  repos:
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v4.6.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.10.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.4.2
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.8.5
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: v5.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.9.9
18
  hooks:
19
+ - id: ruff
20
+ args: ["--fix"]
21
+ - id: ruff-format
 
 
 
 
22
  - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.15.0
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: purple
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: false
10
  suggested_hardware: t4-small
 
4
  colorFrom: purple
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 5.20.0
8
  app_file: app.py
9
  pinned: false
10
  suggested_hardware: t4-small
app.py CHANGED
@@ -1,15 +1,14 @@
1
  #!/usr/bin/env python
2
 
3
- from __future__ import annotations
4
-
5
  import pickle
6
  import sys
7
 
8
  import gradio as gr
9
  import numpy as np
10
  import torch
11
- import torch.nn as nn
12
  from huggingface_hub import hf_hub_download
 
13
 
14
  sys.path.insert(0, "StyleGAN-Human")
15
 
@@ -19,8 +18,8 @@ DESCRIPTION = "https://github.com/stylegan-human/StyleGAN-Human"
19
 
20
  def load_model(file_name: str, device: torch.device) -> nn.Module:
21
  path = hf_hub_download("public-data/StyleGAN-Human", f"models/{file_name}")
22
- with open(path, "rb") as f:
23
- model = pickle.load(f)["G_ema"]
24
  model.eval()
25
  model.to(device)
26
  with torch.inference_mode():
 
1
  #!/usr/bin/env python
2
 
3
+ import pathlib
 
4
  import pickle
5
  import sys
6
 
7
  import gradio as gr
8
  import numpy as np
9
  import torch
 
10
  from huggingface_hub import hf_hub_download
11
+ from torch import nn
12
 
13
  sys.path.insert(0, "StyleGAN-Human")
14
 
 
18
 
19
  def load_model(file_name: str, device: torch.device) -> nn.Module:
20
  path = hf_hub_download("public-data/StyleGAN-Human", f"models/{file_name}")
21
+ with pathlib.Path(path).open("rb") as f:
22
+ model = pickle.load(f)["G_ema"] # noqa: S301
23
  model.eval()
24
  model.to(device)
25
  with torch.inference_mode():
pyproject.toml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "stylegan-human-app"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio>=5.20.0",
9
+ "hf-transfer>=0.1.9",
10
+ "setuptools>=75.8.2",
11
+ "torch==2.4.0",
12
+ "torchvision>=0.19.0",
13
+ ]
14
+
15
+ [tool.ruff]
16
+ line-length = 119
17
+
18
+ [tool.ruff.lint]
19
+ select = ["ALL"]
20
+ ignore = [
21
+ "COM812", # missing-trailing-comma
22
+ "D203", # one-blank-line-before-class
23
+ "D213", # multi-line-summary-second-line
24
+ "E501", # line-too-long
25
+ "SIM117", # multiple-with-statements
26
+ ]
27
+ extend-ignore = [
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,5 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  numpy==1.26.4
2
- Pillow==10.3.0
3
- scipy==1.13.1
4
- torch==2.0.1
5
- 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==23.2.1
4
+ # via gradio
5
+ annotated-types==0.7.0
6
+ # via pydantic
7
+ anyio==4.8.0
8
+ # via
9
+ # gradio
10
+ # httpx
11
+ # starlette
12
+ certifi==2025.1.31
13
+ # via
14
+ # httpcore
15
+ # httpx
16
+ # requests
17
+ charset-normalizer==3.4.1
18
+ # via requests
19
+ click==8.1.8
20
+ # via
21
+ # typer
22
+ # uvicorn
23
+ exceptiongroup==1.2.2
24
+ # via anyio
25
+ fastapi==0.115.11
26
+ # via gradio
27
+ ffmpy==0.5.0
28
+ # via gradio
29
+ filelock==3.17.0
30
+ # via
31
+ # huggingface-hub
32
+ # torch
33
+ # triton
34
+ fsspec==2025.2.0
35
+ # via
36
+ # gradio-client
37
+ # huggingface-hub
38
+ # torch
39
+ gradio==5.20.0
40
+ # via stylegan-human-app (pyproject.toml)
41
+ gradio-client==1.7.2
42
+ # via gradio
43
+ groovy==0.1.2
44
+ # via gradio
45
+ h11==0.14.0
46
+ # via
47
+ # httpcore
48
+ # uvicorn
49
+ hf-transfer==0.1.9
50
+ # via stylegan-human-app (pyproject.toml)
51
+ httpcore==1.0.7
52
+ # via httpx
53
+ httpx==0.28.1
54
+ # via
55
+ # gradio
56
+ # gradio-client
57
+ # safehttpx
58
+ huggingface-hub==0.29.2
59
+ # via
60
+ # gradio
61
+ # gradio-client
62
+ idna==3.10
63
+ # via
64
+ # anyio
65
+ # httpx
66
+ # requests
67
+ jinja2==3.1.6
68
+ # via
69
+ # gradio
70
+ # torch
71
+ markdown-it-py==3.0.0
72
+ # via rich
73
+ markupsafe==2.1.5
74
+ # via
75
+ # gradio
76
+ # jinja2
77
+ mdurl==0.1.2
78
+ # via markdown-it-py
79
+ mpmath==1.3.0
80
+ # via sympy
81
+ networkx==3.4.2
82
+ # via torch
83
  numpy==1.26.4
84
+ # via
85
+ # gradio
86
+ # pandas
87
+ # torchvision
88
+ nvidia-cublas-cu12==12.1.3.1
89
+ # via
90
+ # nvidia-cudnn-cu12
91
+ # nvidia-cusolver-cu12
92
+ # torch
93
+ nvidia-cuda-cupti-cu12==12.1.105
94
+ # via torch
95
+ nvidia-cuda-nvrtc-cu12==12.1.105
96
+ # via torch
97
+ nvidia-cuda-runtime-cu12==12.1.105
98
+ # via torch
99
+ nvidia-cudnn-cu12==9.1.0.70
100
+ # via torch
101
+ nvidia-cufft-cu12==11.0.2.54
102
+ # via torch
103
+ nvidia-curand-cu12==10.3.2.106
104
+ # via torch
105
+ nvidia-cusolver-cu12==11.4.5.107
106
+ # via torch
107
+ nvidia-cusparse-cu12==12.1.0.106
108
+ # via
109
+ # nvidia-cusolver-cu12
110
+ # torch
111
+ nvidia-nccl-cu12==2.20.5
112
+ # via torch
113
+ nvidia-nvjitlink-cu12==12.8.61
114
+ # via
115
+ # nvidia-cusolver-cu12
116
+ # nvidia-cusparse-cu12
117
+ nvidia-nvtx-cu12==12.1.105
118
+ # via torch
119
+ orjson==3.10.15
120
+ # via gradio
121
+ packaging==24.2
122
+ # via
123
+ # gradio
124
+ # gradio-client
125
+ # huggingface-hub
126
+ pandas==2.2.3
127
+ # via gradio
128
+ pillow==10.3.0
129
+ # via
130
+ # gradio
131
+ # torchvision
132
+ pydantic==2.10.6
133
+ # via
134
+ # fastapi
135
+ # gradio
136
+ pydantic-core==2.27.2
137
+ # via pydantic
138
+ pydub==0.25.1
139
+ # via gradio
140
+ pygments==2.19.1
141
+ # via rich
142
+ python-dateutil==2.9.0.post0
143
+ # via pandas
144
+ python-multipart==0.0.20
145
+ # via gradio
146
+ pytz==2025.1
147
+ # via pandas
148
+ pyyaml==6.0.2
149
+ # via
150
+ # gradio
151
+ # huggingface-hub
152
+ requests==2.32.3
153
+ # via huggingface-hub
154
+ rich==13.9.4
155
+ # via typer
156
+ ruff==0.9.9
157
+ # via gradio
158
+ safehttpx==0.1.6
159
+ # via gradio
160
+ semantic-version==2.10.0
161
+ # via gradio
162
+ setuptools==75.8.2
163
+ # via stylegan-human-app (pyproject.toml)
164
+ shellingham==1.5.4
165
+ # via typer
166
+ six==1.17.0
167
+ # via python-dateutil
168
+ sniffio==1.3.1
169
+ # via anyio
170
+ starlette==0.46.0
171
+ # via
172
+ # fastapi
173
+ # gradio
174
+ sympy==1.13.3
175
+ # via torch
176
+ tomlkit==0.13.2
177
+ # via gradio
178
+ torch==2.4.0
179
+ # via
180
+ # stylegan-human-app (pyproject.toml)
181
+ # torchvision
182
+ torchvision==0.19.0
183
+ # via stylegan-human-app (pyproject.toml)
184
+ tqdm==4.67.1
185
+ # via huggingface-hub
186
+ triton==3.0.0
187
+ # via torch
188
+ typer==0.15.2
189
+ # via gradio
190
+ typing-extensions==4.12.2
191
+ # via
192
+ # anyio
193
+ # fastapi
194
+ # gradio
195
+ # gradio-client
196
+ # huggingface-hub
197
+ # pydantic
198
+ # pydantic-core
199
+ # rich
200
+ # torch
201
+ # typer
202
+ # uvicorn
203
+ tzdata==2025.1
204
+ # via pandas
205
+ urllib3==2.3.0
206
+ # via requests
207
+ uvicorn==0.34.0
208
+ # via gradio
209
+ websockets==15.0.1
210
+ # via gradio-client
uv.lock ADDED
The diff for this file is too large to render. See raw diff