hysts HF staff commited on
Commit
c99adac
1 Parent(s): 039b908
.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
@@ -18,13 +18,15 @@ repos:
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"]
@@ -35,14 +37,8 @@ repos:
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:
@@ -51,7 +47,7 @@ repos:
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
 
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
 
18
  hooks:
19
  - id: docformatter
20
  args: ["--in-place"]
21
+ - repo: https://github.com/astral-sh/ruff-pre-commit
22
+ rev: v0.8.4
23
  hooks:
24
+ - id: ruff
25
+ args: ["--fix"]
26
+ - id: ruff-format
27
+ args: ["--line-length", "119"]
28
  - repo: https://github.com/pre-commit/mirrors-mypy
29
+ rev: v1.14.0
30
  hooks:
31
  - id: mypy
32
  args: ["--ignore-missing-imports"]
 
37
  "types-PyYAML",
38
  "types-pytz",
39
  ]
 
 
 
 
 
 
40
  - repo: https://github.com/kynan/nbstripout
41
+ rev: 0.8.1
42
  hooks:
43
  - id: nbstripout
44
  args:
 
47
  "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
48
  ]
49
  - repo: https://github.com/nbQA-dev/nbQA
50
+ rev: 1.9.1
51
  hooks:
52
  - id: nbqa-black
53
  - id: nbqa-pyupgrade
.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,20 @@
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.formatOnCellExecution": true,
17
  "notebook.formatOnSave.enabled": true,
18
+ "notebook.codeActionsOnSave": {
19
+ "source.organizeImports": "explicit"
20
+ }
21
  }
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: ⚡
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.py CHANGED
@@ -1,7 +1,5 @@
1
  #!/usr/bin/env python
2
 
3
- from __future__ import annotations
4
-
5
  import os
6
 
7
  import gradio as gr
@@ -53,11 +51,10 @@ def run(
53
  length_penalty=length_penalty,
54
  temperature=temperature,
55
  )
56
- generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
57
- return generated_caption
58
 
59
 
60
- with gr.Blocks(css="style.css") as demo:
61
  gr.Markdown(DESCRIPTION)
62
 
63
  with gr.Row():
 
1
  #!/usr/bin/env python
2
 
 
 
3
  import os
4
 
5
  import gradio as gr
 
51
  length_penalty=length_penalty,
52
  temperature=temperature,
53
  )
54
+ return processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
 
55
 
56
 
57
+ with gr.Blocks(css_paths="style.css") as demo:
58
  gr.Markdown(DESCRIPTION)
59
 
60
  with gr.Row():
pyproject.toml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "instructblip"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "accelerate>=1.2.1",
9
+ "gradio>=5.9.1",
10
+ "spaces>=0.31.1",
11
+ "torch==2.4.0",
12
+ "torchvision>=0.19.0",
13
+ "transformers>=4.47.1",
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
+ extend-ignore = [
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.format]
50
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,7 +1,244 @@
1
- accelerate==0.31.0
2
- gradio==4.36.1
3
- Pillow==10.3.0
4
- spaces==0.28.3
5
- torch==2.0.1
6
- torchvision==0.15.2
7
- transformers==4.41.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ accelerate==1.2.1
4
+ # via instructblip (pyproject.toml)
5
+ aiofiles==23.2.1
6
+ # via gradio
7
+ annotated-types==0.7.0
8
+ # via pydantic
9
+ anyio==4.7.0
10
+ # via
11
+ # gradio
12
+ # httpx
13
+ # starlette
14
+ certifi==2024.12.14
15
+ # via
16
+ # httpcore
17
+ # httpx
18
+ # requests
19
+ charset-normalizer==3.4.1
20
+ # via requests
21
+ click==8.1.8
22
+ # via
23
+ # typer
24
+ # uvicorn
25
+ exceptiongroup==1.2.2
26
+ # via anyio
27
+ fastapi==0.115.6
28
+ # via gradio
29
+ ffmpy==0.5.0
30
+ # via gradio
31
+ filelock==3.16.1
32
+ # via
33
+ # huggingface-hub
34
+ # torch
35
+ # transformers
36
+ # triton
37
+ fsspec==2024.12.0
38
+ # via
39
+ # gradio-client
40
+ # huggingface-hub
41
+ # torch
42
+ gradio==5.9.1
43
+ # via
44
+ # instructblip (pyproject.toml)
45
+ # spaces
46
+ gradio-client==1.5.2
47
+ # via gradio
48
+ h11==0.14.0
49
+ # via
50
+ # httpcore
51
+ # uvicorn
52
+ httpcore==1.0.7
53
+ # via httpx
54
+ httpx==0.28.1
55
+ # via
56
+ # gradio
57
+ # gradio-client
58
+ # safehttpx
59
+ # spaces
60
+ huggingface-hub==0.27.0
61
+ # via
62
+ # accelerate
63
+ # gradio
64
+ # gradio-client
65
+ # tokenizers
66
+ # transformers
67
+ idna==3.10
68
+ # via
69
+ # anyio
70
+ # httpx
71
+ # requests
72
+ jinja2==3.1.5
73
+ # via
74
+ # gradio
75
+ # torch
76
+ markdown-it-py==3.0.0
77
+ # via rich
78
+ markupsafe==2.1.5
79
+ # via
80
+ # gradio
81
+ # jinja2
82
+ mdurl==0.1.2
83
+ # via markdown-it-py
84
+ mpmath==1.3.0
85
+ # via sympy
86
+ networkx==3.4.2
87
+ # via torch
88
+ numpy==2.2.1
89
+ # via
90
+ # accelerate
91
+ # gradio
92
+ # pandas
93
+ # torchvision
94
+ # transformers
95
+ nvidia-cublas-cu12==12.1.3.1
96
+ # via
97
+ # nvidia-cudnn-cu12
98
+ # nvidia-cusolver-cu12
99
+ # torch
100
+ nvidia-cuda-cupti-cu12==12.1.105
101
+ # via torch
102
+ nvidia-cuda-nvrtc-cu12==12.1.105
103
+ # via torch
104
+ nvidia-cuda-runtime-cu12==12.1.105
105
+ # via torch
106
+ nvidia-cudnn-cu12==9.1.0.70
107
+ # via torch
108
+ nvidia-cufft-cu12==11.0.2.54
109
+ # via torch
110
+ nvidia-curand-cu12==10.3.2.106
111
+ # via torch
112
+ nvidia-cusolver-cu12==11.4.5.107
113
+ # via torch
114
+ nvidia-cusparse-cu12==12.1.0.106
115
+ # via
116
+ # nvidia-cusolver-cu12
117
+ # torch
118
+ nvidia-nccl-cu12==2.20.5
119
+ # via torch
120
+ nvidia-nvjitlink-cu12==12.6.85
121
+ # via
122
+ # nvidia-cusolver-cu12
123
+ # nvidia-cusparse-cu12
124
+ nvidia-nvtx-cu12==12.1.105
125
+ # via torch
126
+ orjson==3.10.13
127
+ # via gradio
128
+ packaging==24.2
129
+ # via
130
+ # accelerate
131
+ # gradio
132
+ # gradio-client
133
+ # huggingface-hub
134
+ # spaces
135
+ # transformers
136
+ pandas==2.2.3
137
+ # via gradio
138
+ pillow==11.0.0
139
+ # via
140
+ # gradio
141
+ # torchvision
142
+ psutil==5.9.8
143
+ # via
144
+ # accelerate
145
+ # spaces
146
+ pydantic==2.10.4
147
+ # via
148
+ # fastapi
149
+ # gradio
150
+ # spaces
151
+ pydantic-core==2.27.2
152
+ # via pydantic
153
+ pydub==0.25.1
154
+ # via gradio
155
+ pygments==2.18.0
156
+ # via rich
157
+ python-dateutil==2.9.0.post0
158
+ # via pandas
159
+ python-multipart==0.0.20
160
+ # via gradio
161
+ pytz==2024.2
162
+ # via pandas
163
+ pyyaml==6.0.2
164
+ # via
165
+ # accelerate
166
+ # gradio
167
+ # huggingface-hub
168
+ # transformers
169
+ regex==2024.11.6
170
+ # via transformers
171
+ requests==2.32.3
172
+ # via
173
+ # huggingface-hub
174
+ # spaces
175
+ # transformers
176
+ rich==13.9.4
177
+ # via typer
178
+ ruff==0.8.4
179
+ # via gradio
180
+ safehttpx==0.1.6
181
+ # via gradio
182
+ safetensors==0.4.5
183
+ # via
184
+ # accelerate
185
+ # transformers
186
+ semantic-version==2.10.0
187
+ # via gradio
188
+ shellingham==1.5.4
189
+ # via typer
190
+ six==1.17.0
191
+ # via python-dateutil
192
+ sniffio==1.3.1
193
+ # via anyio
194
+ spaces==0.31.1
195
+ # via instructblip (pyproject.toml)
196
+ starlette==0.41.3
197
+ # via
198
+ # fastapi
199
+ # gradio
200
+ sympy==1.13.3
201
+ # via torch
202
+ tokenizers==0.21.0
203
+ # via transformers
204
+ tomlkit==0.13.2
205
+ # via gradio
206
+ torch==2.4.0
207
+ # via
208
+ # instructblip (pyproject.toml)
209
+ # accelerate
210
+ # torchvision
211
+ torchvision==0.19.0
212
+ # via instructblip (pyproject.toml)
213
+ tqdm==4.67.1
214
+ # via
215
+ # huggingface-hub
216
+ # transformers
217
+ transformers==4.47.1
218
+ # via instructblip (pyproject.toml)
219
+ triton==3.0.0
220
+ # via torch
221
+ typer==0.15.1
222
+ # via gradio
223
+ typing-extensions==4.12.2
224
+ # via
225
+ # anyio
226
+ # fastapi
227
+ # gradio
228
+ # gradio-client
229
+ # huggingface-hub
230
+ # pydantic
231
+ # pydantic-core
232
+ # rich
233
+ # spaces
234
+ # torch
235
+ # typer
236
+ # uvicorn
237
+ tzdata==2024.2
238
+ # via pandas
239
+ urllib3==2.3.0
240
+ # via requests
241
+ uvicorn==0.34.0
242
+ # via gradio
243
+ websockets==14.1
244
+ # via gradio-client
uv.lock ADDED
The diff for this file is too large to render. See raw diff