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 -329
  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.5.1",
12
- "torchvision>=0.20.1",
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,329 +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
- fastapi==0.116.1
46
- # via gradio
47
- filelock==3.18.0
48
- # via
49
- # huggingface-hub
50
- # torch
51
- # transformers
52
- # triton
53
- fire==0.7.0
54
- # via sahi
55
- fsspec==2025.7.0
56
- # via
57
- # gradio-client
58
- # huggingface-hub
59
- # torch
60
- gradio==6.14.0
61
- # via
62
- # deta
63
- # spaces
64
- gradio-client==2.5.0
65
- # via
66
- # gradio
67
- # hf-gradio
68
- groovy==0.1.2
69
- # via gradio
70
- h11==0.16.0
71
- # via
72
- # httpcore
73
- # uvicorn
74
- hf-gradio==0.4.1
75
- # via gradio
76
- hf-xet==1.1.5 ; platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'
77
- # via huggingface-hub
78
- httpcore==1.0.9
79
- # via httpx
80
- httpx==0.28.1
81
- # via
82
- # gradio
83
- # gradio-client
84
- # mcp
85
- # safehttpx
86
- # spaces
87
- httpx-sse==0.4.3
88
- # via mcp
89
- huggingface-hub==0.36.2
90
- # via
91
- # gradio
92
- # gradio-client
93
- # tokenizers
94
- # transformers
95
- idna==3.10
96
- # via
97
- # anyio
98
- # httpx
99
- # requests
100
- itsdangerous==2.2.0
101
- # via gradio
102
- jinja2==3.1.6
103
- # via
104
- # gradio
105
- # torch
106
- joserfc==1.6.4
107
- # via authlib
108
- jsonschema==4.26.0
109
- # via mcp
110
- jsonschema-specifications==2025.9.1
111
- # via jsonschema
112
- markdown-it-py==3.0.0
113
- # via rich
114
- markupsafe==3.0.2
115
- # via
116
- # gradio
117
- # jinja2
118
- mcp==1.27.0
119
- # via gradio
120
- mdurl==0.1.2
121
- # via markdown-it-py
122
- mpmath==1.3.0
123
- # via sympy
124
- networkx==3.5
125
- # via torch
126
- numpy==2.3.1
127
- # via
128
- # gradio
129
- # opencv-python
130
- # pandas
131
- # pybboxes
132
- # shapely
133
- # torchvision
134
- # transformers
135
- nvidia-cublas-cu12==12.4.5.8 ; platform_machine == 'x86_64' and sys_platform == 'linux'
136
- # via
137
- # nvidia-cudnn-cu12
138
- # nvidia-cusolver-cu12
139
- # torch
140
- nvidia-cuda-cupti-cu12==12.4.127 ; platform_machine == 'x86_64' and sys_platform == 'linux'
141
- # via torch
142
- nvidia-cuda-nvrtc-cu12==12.4.127 ; platform_machine == 'x86_64' and sys_platform == 'linux'
143
- # via torch
144
- nvidia-cuda-runtime-cu12==12.4.127 ; platform_machine == 'x86_64' and sys_platform == 'linux'
145
- # via torch
146
- nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
147
- # via torch
148
- nvidia-cufft-cu12==11.2.1.3 ; platform_machine == 'x86_64' and sys_platform == 'linux'
149
- # via torch
150
- nvidia-curand-cu12==10.3.5.147 ; platform_machine == 'x86_64' and sys_platform == 'linux'
151
- # via torch
152
- nvidia-cusolver-cu12==11.6.1.9 ; platform_machine == 'x86_64' and sys_platform == 'linux'
153
- # via torch
154
- nvidia-cusparse-cu12==12.3.1.170 ; platform_machine == 'x86_64' and sys_platform == 'linux'
155
- # via
156
- # nvidia-cusolver-cu12
157
- # torch
158
- nvidia-nccl-cu12==2.21.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
159
- # via torch
160
- nvidia-nvjitlink-cu12==12.4.127 ; platform_machine == 'x86_64' and sys_platform == 'linux'
161
- # via
162
- # nvidia-cufft-cu12
163
- # nvidia-cusolver-cu12
164
- # nvidia-cusparse-cu12
165
- # torch
166
- nvidia-nvtx-cu12==12.4.127 ; platform_machine == 'x86_64' and sys_platform == 'linux'
167
- # via torch
168
- opencv-python==4.11.0.86
169
- # via sahi
170
- orjson==3.11.0
171
- # via gradio
172
- packaging==25.0
173
- # via
174
- # gradio
175
- # gradio-client
176
- # huggingface-hub
177
- # spaces
178
- # transformers
179
- pandas==2.3.1
180
- # via gradio
181
- pillow==11.3.0
182
- # via
183
- # gradio
184
- # sahi
185
- # torchvision
186
- psutil==5.9.8
187
- # via spaces
188
- pybboxes==0.1.6
189
- # via sahi
190
- pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy'
191
- # via cffi
192
- pydantic==2.12.5
193
- # via
194
- # fastapi
195
- # gradio
196
- # mcp
197
- # pydantic-settings
198
- # spaces
199
- pydantic-core==2.41.5
200
- # via pydantic
201
- pydantic-settings==2.14.0
202
- # via mcp
203
- pydub==0.25.1
204
- # via gradio
205
- pygments==2.19.2
206
- # via rich
207
- pyjwt==2.12.1
208
- # via mcp
209
- python-dateutil==2.9.0.post0
210
- # via pandas
211
- python-dotenv==1.2.2
212
- # via pydantic-settings
213
- python-multipart==0.0.20
214
- # via
215
- # gradio
216
- # mcp
217
- pytz==2025.2
218
- # via
219
- # gradio
220
- # pandas
221
- pywin32==311 ; sys_platform == 'win32'
222
- # via mcp
223
- pyyaml==6.0.2
224
- # via
225
- # gradio
226
- # huggingface-hub
227
- # sahi
228
- # transformers
229
- referencing==0.37.0
230
- # via
231
- # jsonschema
232
- # jsonschema-specifications
233
- regex==2024.11.6
234
- # via transformers
235
- requests==2.32.4
236
- # via
237
- # huggingface-hub
238
- # sahi
239
- # spaces
240
- # transformers
241
- rich==14.0.0
242
- # via typer
243
- rpds-py==0.30.0
244
- # via
245
- # jsonschema
246
- # referencing
247
- safehttpx==0.1.7
248
- # via gradio
249
- safetensors==0.5.3
250
- # via transformers
251
- sahi==0.11.31
252
- # via deta
253
- semantic-version==2.10.0
254
- # via gradio
255
- setuptools==80.9.0
256
- # via torch
257
- shapely==2.1.1
258
- # via sahi
259
- shellingham==1.5.4
260
- # via typer
261
- six==1.17.0
262
- # via python-dateutil
263
- sniffio==1.3.1
264
- # via anyio
265
- sse-starlette==3.0.3
266
- # via mcp
267
- starlette==0.47.1
268
- # via
269
- # fastapi
270
- # gradio
271
- # mcp
272
- sympy==1.13.1
273
- # via torch
274
- termcolor==3.1.0
275
- # via fire
276
- terminaltables==3.1.10
277
- # via sahi
278
- tokenizers==0.21.2
279
- # via transformers
280
- tomlkit==0.13.3
281
- # via gradio
282
- torch==2.5.1
283
- # via
284
- # deta
285
- # torchvision
286
- torchvision==0.20.1
287
- # via deta
288
- tqdm==4.67.1
289
- # via
290
- # huggingface-hub
291
- # sahi
292
- # transformers
293
- transformers==4.50.3
294
- # via deta
295
- triton==3.1.0 ; python_full_version < '3.13' and platform_machine == 'x86_64' and sys_platform == 'linux'
296
- # via torch
297
- typer==0.16.0
298
- # via
299
- # gradio
300
- # hf-gradio
301
- typing-extensions==4.14.1
302
- # via
303
- # anyio
304
- # fastapi
305
- # gradio
306
- # gradio-client
307
- # huggingface-hub
308
- # mcp
309
- # pydantic
310
- # pydantic-core
311
- # referencing
312
- # spaces
313
- # starlette
314
- # torch
315
- # typer
316
- # typing-inspection
317
- typing-inspection==0.4.2
318
- # via
319
- # mcp
320
- # pydantic
321
- # pydantic-settings
322
- tzdata==2025.2
323
- # via pandas
324
- urllib3==2.5.0
325
- # via requests
326
- uvicorn==0.35.0
327
- # via
328
- # gradio
329
- # 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