hysts HF staff commited on
Commit
42bbd75
·
1 Parent(s): 32925c4
.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.8.6
18
  hooks:
19
+ - id: ruff
20
+ args: ["--fix"]
21
+ - id: ruff-format
 
 
 
 
22
  - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.14.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 ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
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: indigo
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: green
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 5.12.0
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
 
@@ -10,14 +8,13 @@ import gradio as gr
10
  import numpy as np
11
  import spaces
12
  import torch
13
- import torch.nn as nn
14
  from huggingface_hub import hf_hub_download
 
15
 
16
- current_dir = pathlib.Path(__file__).parent
17
- submodule_dir = current_dir / "MangaLineExtraction_PyTorch"
18
- sys.path.insert(0, submodule_dir.as_posix())
19
 
20
- from model_torch import res_skip
21
 
22
  DESCRIPTION = "# [MangaLineExtraction_PyTorch](https://github.com/ljsabc/MangaLineExtraction_PyTorch)"
23
 
@@ -57,11 +54,10 @@ def predict(image: np.ndarray) -> np.ndarray:
57
  out = model(tensor)
58
 
59
  res = out.cpu().numpy()[0, 0, :h, :w]
60
- res = np.clip(res, 0, 255).astype(np.uint8)
61
- return res
62
 
63
 
64
- with gr.Blocks(css="style.css") as demo:
65
  gr.Markdown(DESCRIPTION)
66
  with gr.Row():
67
  with gr.Column():
 
1
  #!/usr/bin/env python
2
 
 
 
3
  import pathlib
4
  import sys
5
 
 
8
  import numpy as np
9
  import spaces
10
  import torch
 
11
  from huggingface_hub import hf_hub_download
12
+ from torch import nn
13
 
14
+ submodule_dir = pathlib.Path(__file__).parent / "MangaLineExtraction_PyTorch"
15
+ sys.path.append(submodule_dir.as_posix())
 
16
 
17
+ from model_torch import res_skip # type: ignore # noqa: E402
18
 
19
  DESCRIPTION = "# [MangaLineExtraction_PyTorch](https://github.com/ljsabc/MangaLineExtraction_PyTorch)"
20
 
 
54
  out = model(tensor)
55
 
56
  res = out.cpu().numpy()[0, 0, :h, :w]
57
+ return np.clip(res, 0, 255).astype(np.uint8)
 
58
 
59
 
60
+ with gr.Blocks(css_paths="style.css") as demo:
61
  gr.Markdown(DESCRIPTION)
62
  with gr.Row():
63
  with gr.Column():
pyproject.toml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "mangalineextraction-pytorch"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio>=5.12.0",
9
+ "hf-transfer>=0.1.9",
10
+ "opencv-python-headless>=4.10.0.84",
11
+ "spaces>=0.32.0",
12
+ "torch==2.4.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.per-file-ignores]
49
+ "*.ipynb" = ["T201"]
50
+
51
+ [tool.ruff.format]
52
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,4 +1,214 @@
1
- numpy==1.26.4
2
- opencv-python-headless==4.10.0.82
3
- torch==2.0.1
4
- 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==2024.12.14
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.6
26
+ # via gradio
27
+ ffmpy==0.5.0
28
+ # via gradio
29
+ filelock==3.16.1
30
+ # via
31
+ # huggingface-hub
32
+ # torch
33
+ # triton
34
+ fsspec==2024.12.0
35
+ # via
36
+ # gradio-client
37
+ # huggingface-hub
38
+ # torch
39
+ gradio==5.12.0
40
+ # via
41
+ # mangalineextraction-pytorch (pyproject.toml)
42
+ # spaces
43
+ gradio-client==1.5.4
44
+ # via gradio
45
+ h11==0.14.0
46
+ # via
47
+ # httpcore
48
+ # uvicorn
49
+ hf-transfer==0.1.9
50
+ # via mangalineextraction-pytorch (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
+ # spaces
59
+ huggingface-hub==0.27.1
60
+ # via
61
+ # gradio
62
+ # gradio-client
63
+ idna==3.10
64
+ # via
65
+ # anyio
66
+ # httpx
67
+ # requests
68
+ jinja2==3.1.5
69
+ # via
70
+ # gradio
71
+ # torch
72
+ markdown-it-py==3.0.0
73
+ # via rich
74
+ markupsafe==2.1.5
75
+ # via
76
+ # gradio
77
+ # jinja2
78
+ mdurl==0.1.2
79
+ # via markdown-it-py
80
+ mpmath==1.3.0
81
+ # via sympy
82
+ networkx==3.4.2
83
+ # via torch
84
+ numpy==2.2.1
85
+ # via
86
+ # gradio
87
+ # opencv-python-headless
88
+ # pandas
89
+ nvidia-cublas-cu12==12.1.3.1
90
+ # via
91
+ # nvidia-cudnn-cu12
92
+ # nvidia-cusolver-cu12
93
+ # torch
94
+ nvidia-cuda-cupti-cu12==12.1.105
95
+ # via torch
96
+ nvidia-cuda-nvrtc-cu12==12.1.105
97
+ # via torch
98
+ nvidia-cuda-runtime-cu12==12.1.105
99
+ # via torch
100
+ nvidia-cudnn-cu12==9.1.0.70
101
+ # via torch
102
+ nvidia-cufft-cu12==11.0.2.54
103
+ # via torch
104
+ nvidia-curand-cu12==10.3.2.106
105
+ # via torch
106
+ nvidia-cusolver-cu12==11.4.5.107
107
+ # via torch
108
+ nvidia-cusparse-cu12==12.1.0.106
109
+ # via
110
+ # nvidia-cusolver-cu12
111
+ # torch
112
+ nvidia-nccl-cu12==2.20.5
113
+ # via torch
114
+ nvidia-nvjitlink-cu12==12.6.85
115
+ # via
116
+ # nvidia-cusolver-cu12
117
+ # nvidia-cusparse-cu12
118
+ nvidia-nvtx-cu12==12.1.105
119
+ # via torch
120
+ opencv-python-headless==4.10.0.84
121
+ # via mangalineextraction-pytorch (pyproject.toml)
122
+ orjson==3.10.14
123
+ # via gradio
124
+ packaging==24.2
125
+ # via
126
+ # gradio
127
+ # gradio-client
128
+ # huggingface-hub
129
+ # spaces
130
+ pandas==2.2.3
131
+ # via gradio
132
+ pillow==11.1.0
133
+ # via gradio
134
+ psutil==5.9.8
135
+ # via spaces
136
+ pydantic==2.10.5
137
+ # via
138
+ # fastapi
139
+ # gradio
140
+ # spaces
141
+ pydantic-core==2.27.2
142
+ # via pydantic
143
+ pydub==0.25.1
144
+ # via gradio
145
+ pygments==2.19.1
146
+ # via rich
147
+ python-dateutil==2.9.0.post0
148
+ # via pandas
149
+ python-multipart==0.0.20
150
+ # via gradio
151
+ pytz==2024.2
152
+ # via pandas
153
+ pyyaml==6.0.2
154
+ # via
155
+ # gradio
156
+ # huggingface-hub
157
+ requests==2.32.3
158
+ # via
159
+ # huggingface-hub
160
+ # spaces
161
+ rich==13.9.4
162
+ # via typer
163
+ ruff==0.9.1
164
+ # via gradio
165
+ safehttpx==0.1.6
166
+ # via gradio
167
+ semantic-version==2.10.0
168
+ # via gradio
169
+ shellingham==1.5.4
170
+ # via typer
171
+ six==1.17.0
172
+ # via python-dateutil
173
+ sniffio==1.3.1
174
+ # via anyio
175
+ spaces==0.32.0
176
+ # via mangalineextraction-pytorch (pyproject.toml)
177
+ starlette==0.41.3
178
+ # via
179
+ # fastapi
180
+ # gradio
181
+ sympy==1.13.3
182
+ # via torch
183
+ tomlkit==0.13.2
184
+ # via gradio
185
+ torch==2.4.0
186
+ # via mangalineextraction-pytorch (pyproject.toml)
187
+ tqdm==4.67.1
188
+ # via huggingface-hub
189
+ triton==3.0.0
190
+ # via torch
191
+ typer==0.15.1
192
+ # via gradio
193
+ typing-extensions==4.12.2
194
+ # via
195
+ # anyio
196
+ # fastapi
197
+ # gradio
198
+ # gradio-client
199
+ # huggingface-hub
200
+ # pydantic
201
+ # pydantic-core
202
+ # rich
203
+ # spaces
204
+ # torch
205
+ # typer
206
+ # uvicorn
207
+ tzdata==2024.2
208
+ # via pandas
209
+ urllib3==2.3.0
210
+ # via requests
211
+ uvicorn==0.34.0
212
+ # via gradio
213
+ websockets==14.1
214
+ # via gradio-client
uv.lock ADDED
The diff for this file is too large to render. See raw diff