hysts HF Staff commited on
Commit
2c27ba0
·
1 Parent(s): 1a702e2
.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.9.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.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.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: 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: gray
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 4.42.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 5.44.1
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -1,7 +1,5 @@
1
  #!/usr/bin/env python
2
 
3
- from __future__ import annotations
4
-
5
  import pathlib
6
  import sys
7
  import tarfile
@@ -16,9 +14,9 @@ import torch
16
 
17
  sys.path.insert(0, "yolov5_anime")
18
 
19
- from models.yolo import Model
20
- from utils.datasets import letterbox
21
- from utils.general import non_max_suppression, scale_coords
22
 
23
  DESCRIPTION = "# [zymk9/yolov5_anime](https://github.com/zymk9/yolov5_anime)"
24
 
@@ -43,7 +41,7 @@ def load_sample_image_paths() -> list[pathlib.Path]:
43
  dataset_repo = "hysts/sample-images-TADNE"
44
  path = huggingface_hub.hf_hub_download(dataset_repo, "images.tar.gz", repo_type="dataset")
45
  with tarfile.open(path) as f:
46
- f.extractall()
47
  return sorted(image_dir.glob("*"))
48
 
49
 
@@ -80,14 +78,14 @@ image_paths = load_sample_image_paths()
80
  examples = [[path.as_posix(), 0.4, 0.5] for path in image_paths]
81
 
82
 
83
- with gr.Blocks(css="style.css") as demo:
84
  gr.Markdown(DESCRIPTION)
85
  with gr.Row():
86
  with gr.Column():
87
  image = gr.Image(label="Input", type="pil")
88
  score_threshold = gr.Slider(label="Score Threshold", minimum=0, maximum=1, step=0.05, value=0.4)
89
  iou_threshold = gr.Slider(label="IoU Threshold", minimum=0, maximum=1, step=0.05, value=0.5)
90
- run_button = gr.Button("Run")
91
  with gr.Column():
92
  result = gr.Image(label="Output")
93
 
@@ -102,8 +100,7 @@ with gr.Blocks(css="style.css") as demo:
102
  fn=predict,
103
  inputs=inputs,
104
  outputs=result,
105
- api_name="predict",
106
  )
107
 
108
  if __name__ == "__main__":
109
- demo.queue(max_size=20).launch()
 
1
  #!/usr/bin/env python
2
 
 
 
3
  import pathlib
4
  import sys
5
  import tarfile
 
14
 
15
  sys.path.insert(0, "yolov5_anime")
16
 
17
+ from models.yolo import Model # pyright: ignore[reportMissingImports]
18
+ from utils.datasets import letterbox # pyright: ignore[reportMissingImports]
19
+ from utils.general import non_max_suppression, scale_coords # pyright: ignore[reportMissingImports]
20
 
21
  DESCRIPTION = "# [zymk9/yolov5_anime](https://github.com/zymk9/yolov5_anime)"
22
 
 
41
  dataset_repo = "hysts/sample-images-TADNE"
42
  path = huggingface_hub.hf_hub_download(dataset_repo, "images.tar.gz", repo_type="dataset")
43
  with tarfile.open(path) as f:
44
+ f.extractall() # noqa: S202
45
  return sorted(image_dir.glob("*"))
46
 
47
 
 
78
  examples = [[path.as_posix(), 0.4, 0.5] for path in image_paths]
79
 
80
 
81
+ with gr.Blocks(css_paths="style.css") as demo:
82
  gr.Markdown(DESCRIPTION)
83
  with gr.Row():
84
  with gr.Column():
85
  image = gr.Image(label="Input", type="pil")
86
  score_threshold = gr.Slider(label="Score Threshold", minimum=0, maximum=1, step=0.05, value=0.4)
87
  iou_threshold = gr.Slider(label="IoU Threshold", minimum=0, maximum=1, step=0.05, value=0.5)
88
+ run_button = gr.Button()
89
  with gr.Column():
90
  result = gr.Image(label="Output")
91
 
 
100
  fn=predict,
101
  inputs=inputs,
102
  outputs=result,
 
103
  )
104
 
105
  if __name__ == "__main__":
106
+ demo.launch()
pyproject.toml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "yolov5-anime"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio>=5.44.1",
9
+ "hf-transfer>=0.1.9",
10
+ "matplotlib>=3.10.6",
11
+ "opencv-python-headless>=4.12.0.88",
12
+ "scipy>=1.15.3",
13
+ "spaces>=0.40.1",
14
+ "torch==2.8.0",
15
+ "torchvision>=0.23.0",
16
+ ]
17
+
18
+ [tool.ruff]
19
+ line-length = 119
20
+
21
+ [tool.ruff.lint]
22
+ select = ["ALL"]
23
+ ignore = [
24
+ "COM812", # missing-trailing-comma
25
+ "D203", # one-blank-line-before-class
26
+ "D213", # multi-line-summary-second-line
27
+ "E501", # line-too-long
28
+ "SIM117", # multiple-with-statements
29
+ #
30
+ "D100", # undocumented-public-module
31
+ "D101", # undocumented-public-class
32
+ "D102", # undocumented-public-method
33
+ "D103", # undocumented-public-function
34
+ "D104", # undocumented-public-package
35
+ "D105", # undocumented-magic-method
36
+ "D107", # undocumented-public-init
37
+ "EM101", # raw-string-in-exception
38
+ "FBT001", # boolean-type-hint-positional-argument
39
+ "FBT002", # boolean-default-value-positional-argument
40
+ "PD901", # pandas-df-variable-name
41
+ "PGH003", # blanket-type-ignore
42
+ "PLR0913", # too-many-arguments
43
+ "PLR0915", # too-many-statements
44
+ "TRY003", # raise-vanilla-args
45
+ ]
46
+ unfixable = [
47
+ "F401", # unused-import
48
+ ]
49
+
50
+ [tool.ruff.lint.pydocstyle]
51
+ convention = "google"
52
+
53
+ [tool.ruff.lint.per-file-ignores]
54
+ "*.ipynb" = ["T201", "T203"]
55
+
56
+ [tool.ruff.format]
57
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,7 +1,259 @@
1
- gradio==4.42.0
2
- numpy==1.26.4
3
- opencv-python-headless==4.10.0.84
4
- scipy==1.14.1
5
- spaces==0.29.3
6
- torch==2.0.1
7
- 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
+ contourpy==1.3.2
26
+ # via matplotlib
27
+ cycler==0.12.1
28
+ # via matplotlib
29
+ exceptiongroup==1.3.0
30
+ # via anyio
31
+ fastapi==0.116.1
32
+ # via gradio
33
+ ffmpy==0.6.1
34
+ # via gradio
35
+ filelock==3.19.1
36
+ # via
37
+ # huggingface-hub
38
+ # torch
39
+ fonttools==4.59.2
40
+ # via matplotlib
41
+ fsspec==2025.9.0
42
+ # via
43
+ # gradio-client
44
+ # huggingface-hub
45
+ # torch
46
+ gradio==5.44.1
47
+ # via
48
+ # yolov5-anime (pyproject.toml)
49
+ # spaces
50
+ gradio-client==1.12.1
51
+ # via gradio
52
+ groovy==0.1.2
53
+ # via gradio
54
+ h11==0.16.0
55
+ # via
56
+ # httpcore
57
+ # uvicorn
58
+ hf-transfer==0.1.9
59
+ # via yolov5-anime (pyproject.toml)
60
+ hf-xet==1.1.9
61
+ # via huggingface-hub
62
+ httpcore==1.0.9
63
+ # via httpx
64
+ httpx==0.28.1
65
+ # via
66
+ # gradio
67
+ # gradio-client
68
+ # safehttpx
69
+ # spaces
70
+ huggingface-hub==0.34.4
71
+ # via
72
+ # gradio
73
+ # gradio-client
74
+ idna==3.10
75
+ # via
76
+ # anyio
77
+ # httpx
78
+ # requests
79
+ jinja2==3.1.6
80
+ # via
81
+ # gradio
82
+ # torch
83
+ kiwisolver==1.4.9
84
+ # via matplotlib
85
+ markdown-it-py==4.0.0
86
+ # via rich
87
+ markupsafe==3.0.2
88
+ # via
89
+ # gradio
90
+ # jinja2
91
+ matplotlib==3.10.6
92
+ # via yolov5-anime (pyproject.toml)
93
+ mdurl==0.1.2
94
+ # via markdown-it-py
95
+ mpmath==1.3.0
96
+ # via sympy
97
+ networkx==3.4.2
98
+ # via torch
99
+ numpy==2.2.6
100
+ # via
101
+ # contourpy
102
+ # gradio
103
+ # matplotlib
104
+ # opencv-python-headless
105
+ # pandas
106
+ # scipy
107
+ # torchvision
108
+ nvidia-cublas-cu12==12.8.4.1
109
+ # via
110
+ # nvidia-cudnn-cu12
111
+ # nvidia-cusolver-cu12
112
+ # torch
113
+ nvidia-cuda-cupti-cu12==12.8.90
114
+ # via torch
115
+ nvidia-cuda-nvrtc-cu12==12.8.93
116
+ # via torch
117
+ nvidia-cuda-runtime-cu12==12.8.90
118
+ # via torch
119
+ nvidia-cudnn-cu12==9.10.2.21
120
+ # via torch
121
+ nvidia-cufft-cu12==11.3.3.83
122
+ # via torch
123
+ nvidia-cufile-cu12==1.13.1.3
124
+ # via torch
125
+ nvidia-curand-cu12==10.3.9.90
126
+ # via torch
127
+ nvidia-cusolver-cu12==11.7.3.90
128
+ # via torch
129
+ nvidia-cusparse-cu12==12.5.8.93
130
+ # via
131
+ # nvidia-cusolver-cu12
132
+ # torch
133
+ nvidia-cusparselt-cu12==0.7.1
134
+ # via torch
135
+ nvidia-nccl-cu12==2.27.3
136
+ # via torch
137
+ nvidia-nvjitlink-cu12==12.8.93
138
+ # via
139
+ # nvidia-cufft-cu12
140
+ # nvidia-cusolver-cu12
141
+ # nvidia-cusparse-cu12
142
+ # torch
143
+ nvidia-nvtx-cu12==12.8.90
144
+ # via torch
145
+ opencv-python-headless==4.12.0.88
146
+ # via yolov5-anime (pyproject.toml)
147
+ orjson==3.11.3
148
+ # via gradio
149
+ packaging==25.0
150
+ # via
151
+ # gradio
152
+ # gradio-client
153
+ # huggingface-hub
154
+ # matplotlib
155
+ # spaces
156
+ pandas==2.3.2
157
+ # via gradio
158
+ pillow==11.3.0
159
+ # via
160
+ # gradio
161
+ # matplotlib
162
+ # torchvision
163
+ psutil==5.9.8
164
+ # via spaces
165
+ pydantic==2.11.7
166
+ # via
167
+ # fastapi
168
+ # gradio
169
+ # spaces
170
+ pydantic-core==2.33.2
171
+ # via pydantic
172
+ pydub==0.25.1
173
+ # via gradio
174
+ pygments==2.19.2
175
+ # via rich
176
+ pyparsing==3.2.3
177
+ # via matplotlib
178
+ python-dateutil==2.9.0.post0
179
+ # via
180
+ # matplotlib
181
+ # pandas
182
+ python-multipart==0.0.20
183
+ # via gradio
184
+ pytz==2025.2
185
+ # via pandas
186
+ pyyaml==6.0.2
187
+ # via
188
+ # gradio
189
+ # huggingface-hub
190
+ requests==2.32.5
191
+ # via
192
+ # huggingface-hub
193
+ # spaces
194
+ rich==14.1.0
195
+ # via typer
196
+ ruff==0.12.12
197
+ # via gradio
198
+ safehttpx==0.1.6
199
+ # via gradio
200
+ scipy==1.15.3
201
+ # via yolov5-anime (pyproject.toml)
202
+ semantic-version==2.10.0
203
+ # via gradio
204
+ setuptools==80.9.0
205
+ # via triton
206
+ shellingham==1.5.4
207
+ # via typer
208
+ six==1.17.0
209
+ # via python-dateutil
210
+ sniffio==1.3.1
211
+ # via anyio
212
+ spaces==0.40.1
213
+ # via yolov5-anime (pyproject.toml)
214
+ starlette==0.47.3
215
+ # via
216
+ # fastapi
217
+ # gradio
218
+ sympy==1.14.0
219
+ # via torch
220
+ tomlkit==0.13.3
221
+ # via gradio
222
+ torch==2.8.0
223
+ # via
224
+ # yolov5-anime (pyproject.toml)
225
+ # torchvision
226
+ torchvision==0.23.0
227
+ # via yolov5-anime (pyproject.toml)
228
+ tqdm==4.67.1
229
+ # via huggingface-hub
230
+ triton==3.4.0
231
+ # via torch
232
+ typer==0.17.3
233
+ # via gradio
234
+ typing-extensions==4.15.0
235
+ # via
236
+ # anyio
237
+ # exceptiongroup
238
+ # fastapi
239
+ # gradio
240
+ # gradio-client
241
+ # huggingface-hub
242
+ # pydantic
243
+ # pydantic-core
244
+ # spaces
245
+ # starlette
246
+ # torch
247
+ # typer
248
+ # typing-inspection
249
+ # uvicorn
250
+ typing-inspection==0.4.1
251
+ # via pydantic
252
+ tzdata==2025.2
253
+ # via pandas
254
+ urllib3==2.5.0
255
+ # via requests
256
+ uvicorn==0.35.0
257
+ # via gradio
258
+ websockets==15.0.1
259
+ # via gradio-client
style.css CHANGED
@@ -2,10 +2,3 @@ h1 {
2
  text-align: center;
3
  display: block;
4
  }
5
-
6
- #duplicate-button {
7
- margin: auto;
8
- color: #fff;
9
- background: #1565c0;
10
- border-radius: 100vh;
11
- }
 
2
  text-align: center;
3
  display: block;
4
  }
 
 
 
 
 
 
 
uv.lock ADDED
The diff for this file is too large to render. See raw diff