Files changed (9) hide show
  1. .pre-commit-config.yaml +36 -9
  2. .python-version +0 -1
  3. .vscode/settings.json +30 -0
  4. README.md +1 -2
  5. app.py +7 -6
  6. pyproject.toml +0 -56
  7. requirements.txt +8 -340
  8. style.css +7 -0
  9. 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: v6.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.15.11
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.20.2
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.12
 
 
.vscode/settings.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
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,8 +4,7 @@ emoji: 🐠
4
  colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 6.14.0
8
- python_version: 3.12.12
9
  app_file: app.py
10
  pinned: false
11
  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() as demo:
48
  gr.Markdown(DESCRIPTION)
49
  with gr.Row():
50
  with gr.Column():
@@ -67,4 +68,4 @@ with gr.Blocks() as demo:
67
  )
68
 
69
  if __name__ == "__main__":
70
- demo.launch(css_paths="style.css")
 
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.12"
7
- dependencies = [
8
- "gradio[mcp,oauth]>=6.14.0",
9
- "sahi>=0.11.31",
10
- "spaces>=0.48.3",
11
- "torch==2.11.0",
12
- "torchvision==0.26.0",
13
- "transformers==4.50.3",
14
- ]
15
-
16
- [tool.ruff]
17
- line-length = 119
18
-
19
- [tool.ruff.lint]
20
- select = ["ALL"]
21
- ignore = [
22
- "COM812", # missing-trailing-comma
23
- "D203", # one-blank-line-before-class
24
- "D213", # multi-line-summary-second-line
25
- "E501", # line-too-long
26
- "SIM117", # multiple-with-statements
27
- #
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
- "PGH003", # blanket-type-ignore
39
- "PLR0913", # too-many-arguments
40
- "PLR0915", # too-many-statements
41
- "TRY003", # raise-vanilla-args
42
- ]
43
- unfixable = [
44
- "F401", # unused-import
45
- ]
46
-
47
- [tool.ruff.lint.pydocstyle]
48
- convention = "google"
49
-
50
- [tool.ruff.format]
51
- docstring-code-format = true
52
-
53
- [dependency-groups]
54
- hf-spaces = [
55
- "datasets",
56
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,340 +1,8 @@
1
- # This file was autogenerated by uv via the following command:
2
- # uv export --no-hashes --no-dev --no-emit-package typer-slim --no-emit-package spaces -o requirements.txt
3
- annotated-types==0.7.0
4
- # via pydantic
5
- anyio==4.9.0
6
- # via
7
- # gradio
8
- # httpx
9
- # mcp
10
- # sse-starlette
11
- # starlette
12
- attrs==26.1.0
13
- # via
14
- # jsonschema
15
- # referencing
16
- audioop-lts==0.2.1 ; python_full_version >= '3.13'
17
- # via gradio
18
- authlib==1.7.0
19
- # via gradio
20
- brotli==1.1.0
21
- # via gradio
22
- certifi==2025.7.14
23
- # via
24
- # httpcore
25
- # httpx
26
- # requests
27
- cffi==2.0.0 ; platform_python_implementation != 'PyPy'
28
- # via cryptography
29
- charset-normalizer==3.4.2
30
- # via requests
31
- click==8.2.1
32
- # via
33
- # sahi
34
- # typer
35
- # uvicorn
36
- colorama==0.4.6 ; sys_platform == 'win32'
37
- # via
38
- # click
39
- # tqdm
40
- cryptography==47.0.0
41
- # via
42
- # authlib
43
- # joserfc
44
- # pyjwt
45
- cuda-bindings==13.3.0 ; sys_platform == 'linux'
46
- # via torch
47
- cuda-pathfinder==1.5.5 ; sys_platform == 'linux'
48
- # via cuda-bindings
49
- cuda-toolkit==13.0.2 ; sys_platform == 'linux'
50
- # via torch
51
- fastapi==0.116.1
52
- # via gradio
53
- filelock==3.18.0
54
- # via
55
- # huggingface-hub
56
- # torch
57
- # transformers
58
- fire==0.7.0
59
- # via sahi
60
- fsspec==2025.7.0
61
- # via
62
- # gradio-client
63
- # huggingface-hub
64
- # torch
65
- gradio==6.14.0
66
- # via
67
- # deta
68
- # spaces
69
- gradio-client==2.5.0
70
- # via
71
- # gradio
72
- # hf-gradio
73
- groovy==0.1.2
74
- # via gradio
75
- h11==0.16.0
76
- # via
77
- # httpcore
78
- # uvicorn
79
- hf-gradio==0.4.1
80
- # via gradio
81
- hf-xet==1.1.5 ; platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'
82
- # via huggingface-hub
83
- httpcore==1.0.9
84
- # via httpx
85
- httpx==0.28.1
86
- # via
87
- # gradio
88
- # gradio-client
89
- # mcp
90
- # safehttpx
91
- # spaces
92
- httpx-sse==0.4.3
93
- # via mcp
94
- huggingface-hub==0.36.2
95
- # via
96
- # gradio
97
- # gradio-client
98
- # tokenizers
99
- # transformers
100
- idna==3.10
101
- # via
102
- # anyio
103
- # httpx
104
- # requests
105
- itsdangerous==2.2.0
106
- # via gradio
107
- jinja2==3.1.6
108
- # via
109
- # gradio
110
- # torch
111
- joserfc==1.6.4
112
- # via authlib
113
- jsonschema==4.26.0
114
- # via mcp
115
- jsonschema-specifications==2025.9.1
116
- # via jsonschema
117
- markdown-it-py==3.0.0
118
- # via rich
119
- markupsafe==3.0.2
120
- # via
121
- # gradio
122
- # jinja2
123
- mcp==1.27.0
124
- # via gradio
125
- mdurl==0.1.2
126
- # via markdown-it-py
127
- mpmath==1.3.0
128
- # via sympy
129
- networkx==3.5
130
- # via torch
131
- numpy==2.3.1
132
- # via
133
- # gradio
134
- # opencv-python
135
- # pandas
136
- # pybboxes
137
- # shapely
138
- # torchvision
139
- # transformers
140
- nvidia-cublas==13.1.0.3 ; sys_platform == 'linux'
141
- # via
142
- # cuda-toolkit
143
- # nvidia-cudnn-cu13
144
- # nvidia-cusolver
145
- nvidia-cuda-cupti==13.0.85 ; sys_platform == 'linux'
146
- # via cuda-toolkit
147
- nvidia-cuda-nvrtc==13.0.88 ; sys_platform == 'linux'
148
- # via cuda-toolkit
149
- nvidia-cuda-runtime==13.0.96 ; sys_platform == 'linux'
150
- # via cuda-toolkit
151
- nvidia-cudnn-cu13==9.19.0.56 ; sys_platform == 'linux'
152
- # via torch
153
- nvidia-cufft==12.0.0.61 ; sys_platform == 'linux'
154
- # via cuda-toolkit
155
- nvidia-cufile==1.15.1.6 ; sys_platform == 'linux'
156
- # via cuda-toolkit
157
- nvidia-curand==10.4.0.35 ; sys_platform == 'linux'
158
- # via cuda-toolkit
159
- nvidia-cusolver==12.0.4.66 ; sys_platform == 'linux'
160
- # via cuda-toolkit
161
- nvidia-cusparse==12.6.3.3 ; sys_platform == 'linux'
162
- # via
163
- # cuda-toolkit
164
- # nvidia-cusolver
165
- nvidia-cusparselt-cu13==0.8.0 ; sys_platform == 'linux'
166
- # via torch
167
- nvidia-nccl-cu13==2.28.9 ; sys_platform == 'linux'
168
- # via torch
169
- nvidia-nvjitlink==13.0.88 ; sys_platform == 'linux'
170
- # via
171
- # cuda-toolkit
172
- # nvidia-cufft
173
- # nvidia-cusolver
174
- # nvidia-cusparse
175
- nvidia-nvshmem-cu13==3.4.5 ; sys_platform == 'linux'
176
- # via torch
177
- nvidia-nvtx==13.0.85 ; sys_platform == 'linux'
178
- # via cuda-toolkit
179
- opencv-python==4.11.0.86
180
- # via sahi
181
- orjson==3.11.0
182
- # via gradio
183
- packaging==25.0
184
- # via
185
- # gradio
186
- # gradio-client
187
- # huggingface-hub
188
- # spaces
189
- # transformers
190
- pandas==2.3.1
191
- # via gradio
192
- pillow==11.3.0
193
- # via
194
- # gradio
195
- # sahi
196
- # torchvision
197
- psutil==5.9.8
198
- # via spaces
199
- pybboxes==0.1.6
200
- # via sahi
201
- pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy'
202
- # via cffi
203
- pydantic==2.12.5
204
- # via
205
- # fastapi
206
- # gradio
207
- # mcp
208
- # pydantic-settings
209
- # spaces
210
- pydantic-core==2.41.5
211
- # via pydantic
212
- pydantic-settings==2.14.0
213
- # via mcp
214
- pydub==0.25.1
215
- # via gradio
216
- pygments==2.19.2
217
- # via rich
218
- pyjwt==2.12.1
219
- # via mcp
220
- python-dateutil==2.9.0.post0
221
- # via pandas
222
- python-dotenv==1.2.2
223
- # via pydantic-settings
224
- python-multipart==0.0.20
225
- # via
226
- # gradio
227
- # mcp
228
- pytz==2025.2
229
- # via
230
- # gradio
231
- # pandas
232
- pywin32==311 ; sys_platform == 'win32'
233
- # via mcp
234
- pyyaml==6.0.2
235
- # via
236
- # gradio
237
- # huggingface-hub
238
- # sahi
239
- # transformers
240
- referencing==0.37.0
241
- # via
242
- # jsonschema
243
- # jsonschema-specifications
244
- regex==2024.11.6
245
- # via transformers
246
- requests==2.32.4
247
- # via
248
- # huggingface-hub
249
- # sahi
250
- # spaces
251
- # transformers
252
- rich==14.0.0
253
- # via typer
254
- rpds-py==0.30.0
255
- # via
256
- # jsonschema
257
- # referencing
258
- safehttpx==0.1.7
259
- # via gradio
260
- safetensors==0.5.3
261
- # via transformers
262
- sahi==0.11.31
263
- # via deta
264
- semantic-version==2.10.0
265
- # via gradio
266
- setuptools==80.9.0
267
- # via torch
268
- shapely==2.1.1
269
- # via sahi
270
- shellingham==1.5.4
271
- # via typer
272
- six==1.17.0
273
- # via python-dateutil
274
- sniffio==1.3.1
275
- # via anyio
276
- sse-starlette==3.0.3
277
- # via mcp
278
- starlette==0.47.1
279
- # via
280
- # fastapi
281
- # gradio
282
- # mcp
283
- sympy==1.14.0
284
- # via torch
285
- termcolor==3.1.0
286
- # via fire
287
- terminaltables==3.1.10
288
- # via sahi
289
- tokenizers==0.21.2
290
- # via transformers
291
- tomlkit==0.13.3
292
- # via gradio
293
- torch==2.11.0
294
- # via
295
- # deta
296
- # torchvision
297
- torchvision==0.26.0
298
- # via deta
299
- tqdm==4.67.1
300
- # via
301
- # huggingface-hub
302
- # sahi
303
- # transformers
304
- transformers==4.50.3
305
- # via deta
306
- triton==3.6.0 ; sys_platform == 'linux'
307
- # via torch
308
- typer==0.16.0
309
- # via
310
- # gradio
311
- # hf-gradio
312
- typing-extensions==4.14.1
313
- # via
314
- # anyio
315
- # fastapi
316
- # gradio
317
- # gradio-client
318
- # huggingface-hub
319
- # mcp
320
- # pydantic
321
- # pydantic-core
322
- # referencing
323
- # spaces
324
- # starlette
325
- # torch
326
- # typer
327
- # typing-inspection
328
- typing-inspection==0.4.2
329
- # via
330
- # mcp
331
- # pydantic
332
- # pydantic-settings
333
- tzdata==2025.2
334
- # via pandas
335
- urllib3==2.5.0
336
- # via requests
337
- uvicorn==0.35.0
338
- # via
339
- # gradio
340
- # mcp
 
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