hysts HF staff commited on
Commit
8db855c
·
1 Parent(s): d776783
.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: yellow
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: false
10
  suggested_hardware: t4-small
 
4
  colorFrom: yellow
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  suggested_hardware: t4-small
app.py CHANGED
@@ -7,15 +7,15 @@ import torch
7
 
8
  torch.jit.script = lambda x: x
9
 
10
- from app_stylization import demo as demo_stylization
11
- from app_zero_shot import demo as demo_zero_shot
12
 
13
  DESCRIPTION = "# [BLIP-Diffusion](https://github.com/salesforce/LAVIS/tree/main/projects/blip-diffusion)"
14
 
15
  if not torch.cuda.is_available():
16
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
17
 
18
- with gr.Blocks(css="style.css") as demo:
19
  gr.Markdown(DESCRIPTION)
20
  gr.DuplicateButton(
21
  value="Duplicate Space for private use",
 
7
 
8
  torch.jit.script = lambda x: x
9
 
10
+ from app_stylization import demo as demo_stylization # noqa: E402
11
+ from app_zero_shot import demo as demo_zero_shot # noqa: E402
12
 
13
  DESCRIPTION = "# [BLIP-Diffusion](https://github.com/salesforce/LAVIS/tree/main/projects/blip-diffusion)"
14
 
15
  if not torch.cuda.is_available():
16
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
17
 
18
+ with gr.Blocks(css_paths="style.css") as demo:
19
  gr.Markdown(DESCRIPTION)
20
  gr.DuplicateButton(
21
  value="Duplicate Space for private use",
app_stylization.py CHANGED
@@ -33,7 +33,8 @@ def run(
33
  num_inference_steps: int = 25,
34
  ) -> PIL.Image.Image:
35
  if num_inference_steps > MAX_INFERENCE_STEPS:
36
- raise gr.Error(f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}")
 
37
  condition_image = canny_detector(condition_image, 30, 70, output_type="pil")
38
  return pipe(
39
  prompt,
 
33
  num_inference_steps: int = 25,
34
  ) -> PIL.Image.Image:
35
  if num_inference_steps > MAX_INFERENCE_STEPS:
36
+ error_message = f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}"
37
+ raise gr.Error(error_message)
38
  condition_image = canny_detector(condition_image, 30, 70, output_type="pil")
39
  return pipe(
40
  prompt,
app_zero_shot.py CHANGED
@@ -26,7 +26,8 @@ def run(
26
  num_inference_steps: int = 25,
27
  ) -> PIL.Image.Image:
28
  if num_inference_steps > MAX_INFERENCE_STEPS:
29
- raise gr.Error(f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}")
 
30
  return pipe(
31
  prompt,
32
  condition_image,
 
26
  num_inference_steps: int = 25,
27
  ) -> PIL.Image.Image:
28
  if num_inference_steps > MAX_INFERENCE_STEPS:
29
+ error_message = f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}"
30
+ raise gr.Error(error_message)
31
  return pipe(
32
  prompt,
33
  condition_image,
pyproject.toml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "blip-diffusion"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "accelerate>=1.2.1",
9
+ "controlnet-aux>=0.0.9",
10
+ "diffusers>=0.32.1",
11
+ "gradio>=5.9.1",
12
+ "spaces>=0.31.1",
13
+ "torch==2.4.0",
14
+ "torchvision>=0.19.0",
15
+ "transformers>=4.47.1",
16
+ ]
17
+
18
+ [tool.ruff]
19
+ line-length = 119
20
+
21
+ [tool.ruff.lint]
22
+ select = ["ALL"]
23
+ ignore = [
24
+ "COM812", # missing-trailing-comma
25
+ "D203", # one-blank-line-before-class
26
+ "D213", # multi-line-summary-second-line
27
+ "E501", # line-too-long
28
+ "SIM117", # multiple-with-statements
29
+ ]
30
+ extend-ignore = [
31
+ "D100", # undocumented-public-module
32
+ "D101", # undocumented-public-class
33
+ "D102", # undocumented-public-method
34
+ "D103", # undocumented-public-function
35
+ "D104", # undocumented-public-package
36
+ "D105", # undocumented-magic-method
37
+ "D107", # undocumented-public-init
38
+ "EM101", # raw-string-in-exception
39
+ "FBT001", # boolean-type-hint-positional-argument
40
+ "FBT002", # boolean-default-value-positional-argument
41
+ "PD901", # pandas-df-variable-name
42
+ "PGH003", # blanket-type-ignore
43
+ "PLR0913", # too-many-arguments
44
+ "PLR0915", # too-many-statements
45
+ "TRY003", # raise-vanilla-args
46
+ ]
47
+ unfixable = [
48
+ "F401", # unused-import
49
+ ]
50
+
51
+ [tool.ruff.format]
52
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,9 +1,300 @@
1
- accelerate==0.31.0
2
- controlnet_aux==0.0.7
3
- diffusers==0.28.2
4
- gradio==4.36.1
5
- Pillow==10.3.0
6
- spaces==0.28.3
7
- torch==2.0.1
8
- torchvision==0.15.2
9
- 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 blip-diffusion (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
+ controlnet-aux==0.0.9
26
+ # via blip-diffusion (pyproject.toml)
27
+ diffusers==0.32.1
28
+ # via blip-diffusion (pyproject.toml)
29
+ einops==0.8.0
30
+ # via controlnet-aux
31
+ exceptiongroup==1.2.2
32
+ # via anyio
33
+ fastapi==0.115.6
34
+ # via gradio
35
+ ffmpy==0.5.0
36
+ # via gradio
37
+ filelock==3.16.1
38
+ # via
39
+ # controlnet-aux
40
+ # diffusers
41
+ # huggingface-hub
42
+ # torch
43
+ # transformers
44
+ # triton
45
+ fsspec==2024.12.0
46
+ # via
47
+ # gradio-client
48
+ # huggingface-hub
49
+ # torch
50
+ gradio==5.9.1
51
+ # via
52
+ # blip-diffusion (pyproject.toml)
53
+ # spaces
54
+ gradio-client==1.5.2
55
+ # via gradio
56
+ h11==0.14.0
57
+ # via
58
+ # httpcore
59
+ # uvicorn
60
+ httpcore==1.0.7
61
+ # via httpx
62
+ httpx==0.28.1
63
+ # via
64
+ # gradio
65
+ # gradio-client
66
+ # safehttpx
67
+ # spaces
68
+ huggingface-hub==0.27.0
69
+ # via
70
+ # accelerate
71
+ # controlnet-aux
72
+ # diffusers
73
+ # gradio
74
+ # gradio-client
75
+ # tokenizers
76
+ # transformers
77
+ idna==3.10
78
+ # via
79
+ # anyio
80
+ # httpx
81
+ # requests
82
+ imageio==2.36.1
83
+ # via scikit-image
84
+ importlib-metadata==8.5.0
85
+ # via
86
+ # controlnet-aux
87
+ # diffusers
88
+ jinja2==3.1.5
89
+ # via
90
+ # gradio
91
+ # torch
92
+ lazy-loader==0.4
93
+ # via scikit-image
94
+ markdown-it-py==3.0.0
95
+ # via rich
96
+ markupsafe==2.1.5
97
+ # via
98
+ # gradio
99
+ # jinja2
100
+ mdurl==0.1.2
101
+ # via markdown-it-py
102
+ mpmath==1.3.0
103
+ # via sympy
104
+ networkx==3.4.2
105
+ # via
106
+ # scikit-image
107
+ # torch
108
+ numpy==2.2.1
109
+ # via
110
+ # accelerate
111
+ # controlnet-aux
112
+ # diffusers
113
+ # gradio
114
+ # imageio
115
+ # opencv-python-headless
116
+ # pandas
117
+ # scikit-image
118
+ # scipy
119
+ # tifffile
120
+ # torchvision
121
+ # transformers
122
+ nvidia-cublas-cu12==12.1.3.1
123
+ # via
124
+ # nvidia-cudnn-cu12
125
+ # nvidia-cusolver-cu12
126
+ # torch
127
+ nvidia-cuda-cupti-cu12==12.1.105
128
+ # via torch
129
+ nvidia-cuda-nvrtc-cu12==12.1.105
130
+ # via torch
131
+ nvidia-cuda-runtime-cu12==12.1.105
132
+ # via torch
133
+ nvidia-cudnn-cu12==9.1.0.70
134
+ # via torch
135
+ nvidia-cufft-cu12==11.0.2.54
136
+ # via torch
137
+ nvidia-curand-cu12==10.3.2.106
138
+ # via torch
139
+ nvidia-cusolver-cu12==11.4.5.107
140
+ # via torch
141
+ nvidia-cusparse-cu12==12.1.0.106
142
+ # via
143
+ # nvidia-cusolver-cu12
144
+ # torch
145
+ nvidia-nccl-cu12==2.20.5
146
+ # via torch
147
+ nvidia-nvjitlink-cu12==12.6.85
148
+ # via
149
+ # nvidia-cusolver-cu12
150
+ # nvidia-cusparse-cu12
151
+ nvidia-nvtx-cu12==12.1.105
152
+ # via torch
153
+ opencv-python-headless==4.10.0.84
154
+ # via controlnet-aux
155
+ orjson==3.10.13
156
+ # via gradio
157
+ packaging==24.2
158
+ # via
159
+ # accelerate
160
+ # gradio
161
+ # gradio-client
162
+ # huggingface-hub
163
+ # lazy-loader
164
+ # scikit-image
165
+ # spaces
166
+ # transformers
167
+ pandas==2.2.3
168
+ # via gradio
169
+ pillow==10.3.0
170
+ # via
171
+ # controlnet-aux
172
+ # diffusers
173
+ # gradio
174
+ # imageio
175
+ # scikit-image
176
+ # torchvision
177
+ psutil==5.9.8
178
+ # via
179
+ # accelerate
180
+ # spaces
181
+ pydantic==2.10.4
182
+ # via
183
+ # fastapi
184
+ # gradio
185
+ # spaces
186
+ pydantic-core==2.27.2
187
+ # via pydantic
188
+ pydub==0.25.1
189
+ # via gradio
190
+ pygments==2.18.0
191
+ # via rich
192
+ python-dateutil==2.9.0.post0
193
+ # via pandas
194
+ python-multipart==0.0.20
195
+ # via gradio
196
+ pytz==2024.2
197
+ # via pandas
198
+ pyyaml==6.0.2
199
+ # via
200
+ # accelerate
201
+ # gradio
202
+ # huggingface-hub
203
+ # transformers
204
+ regex==2024.11.6
205
+ # via
206
+ # diffusers
207
+ # transformers
208
+ requests==2.32.3
209
+ # via
210
+ # diffusers
211
+ # huggingface-hub
212
+ # spaces
213
+ # transformers
214
+ rich==13.9.4
215
+ # via typer
216
+ ruff==0.8.4
217
+ # via gradio
218
+ safehttpx==0.1.6
219
+ # via gradio
220
+ safetensors==0.4.5
221
+ # via
222
+ # accelerate
223
+ # diffusers
224
+ # transformers
225
+ scikit-image==0.25.0
226
+ # via controlnet-aux
227
+ scipy==1.14.1
228
+ # via
229
+ # controlnet-aux
230
+ # scikit-image
231
+ semantic-version==2.10.0
232
+ # via gradio
233
+ shellingham==1.5.4
234
+ # via typer
235
+ six==1.17.0
236
+ # via python-dateutil
237
+ sniffio==1.3.1
238
+ # via anyio
239
+ spaces==0.31.1
240
+ # via blip-diffusion (pyproject.toml)
241
+ starlette==0.41.3
242
+ # via
243
+ # fastapi
244
+ # gradio
245
+ sympy==1.13.3
246
+ # via torch
247
+ tifffile==2024.12.12
248
+ # via scikit-image
249
+ timm==0.6.7
250
+ # via controlnet-aux
251
+ tokenizers==0.21.0
252
+ # via transformers
253
+ tomlkit==0.13.2
254
+ # via gradio
255
+ torch==2.4.0
256
+ # via
257
+ # blip-diffusion (pyproject.toml)
258
+ # accelerate
259
+ # controlnet-aux
260
+ # timm
261
+ # torchvision
262
+ torchvision==0.19.0
263
+ # via
264
+ # blip-diffusion (pyproject.toml)
265
+ # controlnet-aux
266
+ # timm
267
+ tqdm==4.67.1
268
+ # via
269
+ # huggingface-hub
270
+ # transformers
271
+ transformers==4.47.1
272
+ # via blip-diffusion (pyproject.toml)
273
+ triton==3.0.0
274
+ # via torch
275
+ typer==0.15.1
276
+ # via gradio
277
+ typing-extensions==4.12.2
278
+ # via
279
+ # anyio
280
+ # fastapi
281
+ # gradio
282
+ # gradio-client
283
+ # huggingface-hub
284
+ # pydantic
285
+ # pydantic-core
286
+ # rich
287
+ # spaces
288
+ # torch
289
+ # typer
290
+ # uvicorn
291
+ tzdata==2024.2
292
+ # via pandas
293
+ urllib3==2.3.0
294
+ # via requests
295
+ uvicorn==0.34.0
296
+ # via gradio
297
+ websockets==14.1
298
+ # via gradio-client
299
+ zipp==3.21.0
300
+ # via importlib-metadata
uv.lock ADDED
The diff for this file is too large to render. See raw diff