Spaces:
Running
Running
Update
Browse files- .pre-commit-config.yaml +9 -36
- .python-version +1 -0
- .vscode/extensions.json +8 -0
- .vscode/settings.json +3 -16
- README.md +1 -1
- app.py +6 -7
- pyproject.toml +53 -0
- uv.lock +0 -0
.pre-commit-config.yaml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
-
rev:
|
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/
|
17 |
-
rev:
|
18 |
hooks:
|
19 |
-
- id:
|
20 |
-
args: ["--
|
21 |
-
|
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.
|
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: 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": "
|
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.
|
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: green
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: green
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.20.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
|
3 |
-
|
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, "stylegan3")
|
15 |
|
@@ -34,8 +33,8 @@ def make_transform(translate: tuple[float, float], angle: float) -> np.ndarray:
|
|
34 |
|
35 |
def load_model(device: torch.device) -> nn.Module:
|
36 |
path = hf_hub_download(MODEL_REPO, MODEL_FILE_NAME)
|
37 |
-
with open(
|
38 |
-
model = pickle.load(f)
|
39 |
model.eval()
|
40 |
model.to(device)
|
41 |
with torch.inference_mode():
|
@@ -79,8 +78,8 @@ demo = gr.Interface(
|
|
79 |
],
|
80 |
outputs=gr.Image(label="Output"),
|
81 |
title=TITLE,
|
82 |
-
|
83 |
)
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
-
demo.queue(max_size=20
|
|
|
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, "stylegan3")
|
14 |
|
|
|
33 |
|
34 |
def load_model(device: torch.device) -> nn.Module:
|
35 |
path = hf_hub_download(MODEL_REPO, MODEL_FILE_NAME)
|
36 |
+
with pathlib.Path(path).open("rb") as f:
|
37 |
+
model = pickle.load(f) # noqa: S301
|
38 |
model.eval()
|
39 |
model.to(device)
|
40 |
with torch.inference_mode():
|
|
|
78 |
],
|
79 |
outputs=gr.Image(label="Output"),
|
80 |
title=TITLE,
|
81 |
+
css_paths="style.css",
|
82 |
)
|
83 |
|
84 |
if __name__ == "__main__":
|
85 |
+
demo.queue(max_size=20).launch()
|
pyproject.toml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "stylegan3-food101"
|
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 |
+
"torch==2.4.0",
|
11 |
+
]
|
12 |
+
|
13 |
+
[tool.ruff]
|
14 |
+
line-length = 119
|
15 |
+
|
16 |
+
[tool.ruff.lint]
|
17 |
+
select = ["ALL"]
|
18 |
+
ignore = [
|
19 |
+
"COM812", # missing-trailing-comma
|
20 |
+
"D203", # one-blank-line-before-class
|
21 |
+
"D213", # multi-line-summary-second-line
|
22 |
+
"E501", # line-too-long
|
23 |
+
"SIM117", # multiple-with-statements
|
24 |
+
]
|
25 |
+
extend-ignore = [
|
26 |
+
"D100", # undocumented-public-module
|
27 |
+
"D101", # undocumented-public-class
|
28 |
+
"D102", # undocumented-public-method
|
29 |
+
"D103", # undocumented-public-function
|
30 |
+
"D104", # undocumented-public-package
|
31 |
+
"D105", # undocumented-magic-method
|
32 |
+
"D107", # undocumented-public-init
|
33 |
+
"EM101", # raw-string-in-exception
|
34 |
+
"FBT001", # boolean-type-hint-positional-argument
|
35 |
+
"FBT002", # boolean-default-value-positional-argument
|
36 |
+
"PD901", # pandas-df-variable-name
|
37 |
+
"PGH003", # blanket-type-ignore
|
38 |
+
"PLR0913", # too-many-arguments
|
39 |
+
"PLR0915", # too-many-statements
|
40 |
+
"TRY003", # raise-vanilla-args
|
41 |
+
]
|
42 |
+
unfixable = [
|
43 |
+
"F401", # unused-import
|
44 |
+
]
|
45 |
+
|
46 |
+
[tool.ruff.lint.pydocstyle]
|
47 |
+
convention = "google"
|
48 |
+
|
49 |
+
[tool.ruff.lint.per-file-ignores]
|
50 |
+
"*.ipynb" = ["T201", "T203"]
|
51 |
+
|
52 |
+
[tool.ruff.format]
|
53 |
+
docstring-code-format = true
|
uv.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|