.pre-commit-config.yaml CHANGED
@@ -1,6 +1,6 @@
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,21 +13,48 @@ repos:
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.1
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.16.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
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  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"]
.python-version DELETED
@@ -1 +0,0 @@
1
- 3.10
 
 
.vscode/extensions.json DELETED
@@ -1,8 +0,0 @@
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,16 +2,29 @@
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
  }
 
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
  }
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🐠
4
  colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.37.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 4.31.5
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.py CHANGED
@@ -35,16 +35,17 @@ def run(image_path: str, threshold: float) -> np.ndarray:
35
  cat_ids = results["labels"].cpu().numpy().tolist()
36
 
37
  preds = []
38
- for box, score, cat_id in zip(boxes, scores, cat_ids, strict=True):
39
- box_int = np.round(box).astype(int)
40
  cat_label = model.config.id2label[cat_id]
41
- pred = ObjectPrediction(bbox=box_int, category_id=cat_id, category_name=cat_label, score=score)
42
  preds.append(pred)
43
 
44
- return visualize_object_predictions(np.asarray(image), preds)["image"]
 
45
 
46
 
47
- with gr.Blocks(css_paths="style.css") as demo:
48
  gr.Markdown(DESCRIPTION)
49
  with gr.Row():
50
  with gr.Column():
@@ -67,4 +68,4 @@ with gr.Blocks(css_paths="style.css") as demo:
67
  )
68
 
69
  if __name__ == "__main__":
70
- demo.launch()
 
35
  cat_ids = results["labels"].cpu().numpy().tolist()
36
 
37
  preds = []
38
+ for box, score, cat_id in zip(boxes, scores, cat_ids):
39
+ box = np.round(box).astype(int)
40
  cat_label = model.config.id2label[cat_id]
41
+ pred = ObjectPrediction(bbox=box, category_id=cat_id, category_name=cat_label, score=score)
42
  preds.append(pred)
43
 
44
+ res = visualize_object_predictions(np.asarray(image), preds)["image"]
45
+ return res
46
 
47
 
48
+ with gr.Blocks(css="style.css") as demo:
49
  gr.Markdown(DESCRIPTION)
50
  with gr.Row():
51
  with gr.Column():
 
68
  )
69
 
70
  if __name__ == "__main__":
71
+ demo.queue(max_size=20).launch()
pyproject.toml DELETED
@@ -1,56 +0,0 @@
1
- [project]
2
- name = "deta"
3
- version = "0.1.0"
4
- description = ""
5
- readme = "README.md"
6
- requires-python = ">=3.10"
7
- dependencies = [
8
- "gradio>=5.37.0",
9
- "hf-transfer>=0.1.9",
10
- "sahi>=0.11.31",
11
- "spaces>=0.37.1",
12
- "torch==2.5.1",
13
- "torchvision>=0.20.1",
14
- "transformers==4.50.3",
15
- ]
16
-
17
- [tool.ruff]
18
- line-length = 119
19
-
20
- [tool.ruff.lint]
21
- select = ["ALL"]
22
- ignore = [
23
- "COM812", # missing-trailing-comma
24
- "D203", # one-blank-line-before-class
25
- "D213", # multi-line-summary-second-line
26
- "E501", # line-too-long
27
- "SIM117", # multiple-with-statements
28
- #
29
- "D100", # undocumented-public-module
30
- "D101", # undocumented-public-class
31
- "D102", # undocumented-public-method
32
- "D103", # undocumented-public-function
33
- "D104", # undocumented-public-package
34
- "D105", # undocumented-magic-method
35
- "D107", # undocumented-public-init
36
- "EM101", # raw-string-in-exception
37
- "FBT001", # boolean-type-hint-positional-argument
38
- "FBT002", # boolean-default-value-positional-argument
39
- "PD901", # pandas-df-variable-name
40
- "PGH003", # blanket-type-ignore
41
- "PLR0913", # too-many-arguments
42
- "PLR0915", # too-many-statements
43
- "TRY003", # raise-vanilla-args
44
- ]
45
- unfixable = [
46
- "F401", # unused-import
47
- ]
48
-
49
- [tool.ruff.lint.pydocstyle]
50
- convention = "google"
51
-
52
- [tool.ruff.lint.per-file-ignores]
53
- "*.ipynb" = ["T201", "T203"]
54
-
55
- [tool.ruff.format]
56
- docstring-code-format = true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,269 +1,8 @@
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.9.0
8
- # via
9
- # gradio
10
- # httpx
11
- # starlette
12
- brotli==1.1.0
13
- # via gradio
14
- certifi==2025.7.14
15
- # via
16
- # httpcore
17
- # httpx
18
- # requests
19
- charset-normalizer==3.4.2
20
- # via requests
21
- click==8.2.1
22
- # via
23
- # sahi
24
- # typer
25
- # uvicorn
26
- exceptiongroup==1.3.0
27
- # via anyio
28
- fastapi==0.116.1
29
- # via gradio
30
- ffmpy==0.6.0
31
- # via gradio
32
- filelock==3.18.0
33
- # via
34
- # huggingface-hub
35
- # torch
36
- # transformers
37
- # triton
38
- fire==0.7.0
39
- # via sahi
40
- fsspec==2025.7.0
41
- # via
42
- # gradio-client
43
- # huggingface-hub
44
- # torch
45
- gradio==5.37.0
46
- # via
47
- # deta (pyproject.toml)
48
- # spaces
49
- gradio-client==1.10.4
50
- # via gradio
51
- groovy==0.1.2
52
- # via gradio
53
- h11==0.16.0
54
- # via
55
- # httpcore
56
- # uvicorn
57
- hf-transfer==0.1.9
58
- # via deta (pyproject.toml)
59
- hf-xet==1.1.5
60
- # via huggingface-hub
61
- httpcore==1.0.9
62
- # via httpx
63
- httpx==0.28.1
64
- # via
65
- # gradio
66
- # gradio-client
67
- # safehttpx
68
- # spaces
69
- huggingface-hub==0.33.4
70
- # via
71
- # gradio
72
- # gradio-client
73
- # tokenizers
74
- # transformers
75
- idna==3.10
76
- # via
77
- # anyio
78
- # httpx
79
- # requests
80
- jinja2==3.1.6
81
- # via
82
- # gradio
83
- # torch
84
- markdown-it-py==3.0.0
85
- # via rich
86
- markupsafe==3.0.2
87
- # via
88
- # gradio
89
- # jinja2
90
- mdurl==0.1.2
91
- # via markdown-it-py
92
- mpmath==1.3.0
93
- # via sympy
94
- networkx==3.4.2
95
- # via torch
96
- numpy==2.2.6
97
- # via
98
- # gradio
99
- # opencv-python
100
- # pandas
101
- # pybboxes
102
- # shapely
103
- # torchvision
104
- # transformers
105
- nvidia-cublas-cu12==12.4.5.8
106
- # via
107
- # nvidia-cudnn-cu12
108
- # nvidia-cusolver-cu12
109
- # torch
110
- nvidia-cuda-cupti-cu12==12.4.127
111
- # via torch
112
- nvidia-cuda-nvrtc-cu12==12.4.127
113
- # via torch
114
- nvidia-cuda-runtime-cu12==12.4.127
115
- # via torch
116
- nvidia-cudnn-cu12==9.1.0.70
117
- # via torch
118
- nvidia-cufft-cu12==11.2.1.3
119
- # via torch
120
- nvidia-curand-cu12==10.3.5.147
121
- # via torch
122
- nvidia-cusolver-cu12==11.6.1.9
123
- # via torch
124
- nvidia-cusparse-cu12==12.3.1.170
125
- # via
126
- # nvidia-cusolver-cu12
127
- # torch
128
- nvidia-nccl-cu12==2.21.5
129
- # via torch
130
- nvidia-nvjitlink-cu12==12.4.127
131
- # via
132
- # nvidia-cusolver-cu12
133
- # nvidia-cusparse-cu12
134
- # torch
135
- nvidia-nvtx-cu12==12.4.127
136
- # via torch
137
- opencv-python==4.11.0.86
138
- # via sahi
139
- orjson==3.11.0
140
- # via gradio
141
- packaging==25.0
142
- # via
143
- # gradio
144
- # gradio-client
145
- # huggingface-hub
146
- # spaces
147
- # transformers
148
- pandas==2.3.1
149
- # via gradio
150
- pillow==11.3.0
151
- # via
152
- # gradio
153
- # sahi
154
- # torchvision
155
- psutil==5.9.8
156
- # via spaces
157
- pybboxes==0.1.6
158
- # via sahi
159
- pydantic==2.11.7
160
- # via
161
- # fastapi
162
- # gradio
163
- # spaces
164
- pydantic-core==2.33.2
165
- # via pydantic
166
- pydub==0.25.1
167
- # via gradio
168
- pygments==2.19.2
169
- # via rich
170
- python-dateutil==2.9.0.post0
171
- # via pandas
172
- python-multipart==0.0.20
173
- # via gradio
174
- pytz==2025.2
175
- # via pandas
176
- pyyaml==6.0.2
177
- # via
178
- # gradio
179
- # huggingface-hub
180
- # sahi
181
- # transformers
182
- regex==2024.11.6
183
- # via transformers
184
- requests==2.32.4
185
- # via
186
- # huggingface-hub
187
- # sahi
188
- # spaces
189
- # transformers
190
- rich==14.0.0
191
- # via typer
192
- ruff==0.12.3
193
- # via gradio
194
- safehttpx==0.1.6
195
- # via gradio
196
- safetensors==0.5.3
197
- # via transformers
198
- sahi==0.11.31
199
- # via deta (pyproject.toml)
200
- semantic-version==2.10.0
201
- # via gradio
202
- shapely==2.1.1
203
- # via sahi
204
- shellingham==1.5.4
205
- # via typer
206
- six==1.17.0
207
- # via python-dateutil
208
- sniffio==1.3.1
209
- # via anyio
210
- spaces==0.37.1
211
- # via deta (pyproject.toml)
212
- starlette==0.47.1
213
- # via
214
- # fastapi
215
- # gradio
216
- sympy==1.13.1
217
- # via torch
218
- termcolor==3.1.0
219
- # via fire
220
- terminaltables==3.1.10
221
- # via sahi
222
- tokenizers==0.21.2
223
- # via transformers
224
- tomlkit==0.13.3
225
- # via gradio
226
- torch==2.5.1
227
- # via
228
- # deta (pyproject.toml)
229
- # torchvision
230
- torchvision==0.20.1
231
- # via deta (pyproject.toml)
232
- tqdm==4.67.1
233
- # via
234
- # huggingface-hub
235
- # sahi
236
- # transformers
237
- transformers==4.50.3
238
- # via deta (pyproject.toml)
239
- triton==3.1.0
240
- # via torch
241
- typer==0.16.0
242
- # via gradio
243
- typing-extensions==4.14.1
244
- # via
245
- # anyio
246
- # exceptiongroup
247
- # fastapi
248
- # gradio
249
- # gradio-client
250
- # huggingface-hub
251
- # pydantic
252
- # pydantic-core
253
- # rich
254
- # spaces
255
- # starlette
256
- # torch
257
- # typer
258
- # typing-inspection
259
- # uvicorn
260
- typing-inspection==0.4.1
261
- # via pydantic
262
- tzdata==2025.2
263
- # via pandas
264
- urllib3==2.5.0
265
- # via requests
266
- uvicorn==0.35.0
267
- # via gradio
268
- websockets==15.0.1
269
- # via gradio-client
 
1
+ gradio==4.31.5
2
+ numpy==1.26.4
3
+ Pillow==10.3.0
4
+ sahi==0.11.16
5
+ spaces==0.28.3
6
+ torch==2.0.1
7
+ torchvision==0.15.2
8
+ transformers==4.41.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style.css CHANGED
@@ -2,3 +2,10 @@ h1 {
2
  text-align: center;
3
  display: block;
4
  }
 
 
 
 
 
 
 
 
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
+ }
uv.lock DELETED
The diff for this file is too large to render. See raw diff