hysts HF Staff commited on
Commit
3fd27c0
·
1 Parent(s): ab34023
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.pre-commit-config.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
7
+ - id: check-merge-conflict
8
+ - id: check-shebang-scripts-are-executable
9
+ - id: check-toml
10
+ - id: check-yaml
11
+ - id: end-of-file-fixer
12
+ - id: mixed-line-ending
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.11.10
18
+ hooks:
19
+ - id: ruff
20
+ args: ["--fix"]
21
+ - id: ruff-format
22
+ - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.15.0
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
+ ]
.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 ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
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
+ }
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
  title: Rembg
3
- emoji: 🏆
4
- colorFrom: pink
5
- colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.31.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Rembg
3
+ emoji:
4
+ colorFrom: red
5
+ colorTo: purple
6
  sdk: gradio
7
  sdk_version: 5.31.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: image background removal
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import gradio as gr
4
+ import PIL.Image
5
+ import rembg
6
+
7
+ DESCRIPTION = "# rembg - Image background removal"
8
+
9
+
10
+ def remove_background(image: PIL.Image.Image) -> tuple[PIL.Image.Image, PIL.Image.Image]:
11
+ """Remove background from image using `rembg`.
12
+
13
+ Args:
14
+ image: The image to remove the background from.
15
+
16
+ Returns:
17
+ A tuple containing the original image and the image with the background removed.
18
+ """
19
+ return image, rembg.remove(image)
20
+
21
+
22
+ with gr.Blocks(css_paths="style.css") as demo:
23
+ gr.Markdown(DESCRIPTION)
24
+ with gr.Row():
25
+ with gr.Column():
26
+ image = gr.Image(type="pil")
27
+ run_button = gr.Button()
28
+ with gr.Column():
29
+ out = gr.ImageSlider()
30
+ gr.Examples(examples=["cats.jpg"], fn=remove_background, inputs=image, outputs=out)
31
+
32
+ run_button.click(fn=remove_background, inputs=image, outputs=out)
33
+
34
+ if __name__ == "__main__":
35
+ demo.launch(mcp_server=True)
cats.jpg ADDED

Git LFS Details

  • SHA256: 114e83cc896e9df6476fd682c8d0dc8fafb76e8cf1da5f6396280040081ee1ca
  • Pointer size: 131 Bytes
  • Size of remote file: 681 kB
pyproject.toml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "rembg-space"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio[mcp]>=5.31.0",
9
+ "hf-transfer>=0.1.9",
10
+ "onnxruntime>=1.22.0",
11
+ "rembg>=2.0.66",
12
+ ]
13
+
14
+ [tool.ruff]
15
+ line-length = 119
16
+
17
+ [tool.ruff.lint]
18
+ select = ["ALL"]
19
+ ignore = [
20
+ "COM812", # missing-trailing-comma
21
+ "D203", # one-blank-line-before-class
22
+ "D213", # multi-line-summary-second-line
23
+ "E501", # line-too-long
24
+ "SIM117", # multiple-with-statements
25
+ #
26
+ "D100", # undocumented-public-module
27
+ "D101", # undocumented-public-class
28
+ "D102", # undocumented-public-method
29
+ "D103", # undocumented-public-function
30
+ "D104", # undocumented-public-package
31
+ "D105", # undocumented-magic-method
32
+ "D107", # undocumented-public-init
33
+ "EM101", # raw-string-in-exception
34
+ "FBT001", # boolean-type-hint-positional-argument
35
+ "FBT002", # boolean-default-value-positional-argument
36
+ "PD901", # pandas-df-variable-name
37
+ "PGH003", # blanket-type-ignore
38
+ "PLR0913", # too-many-arguments
39
+ "PLR0915", # too-many-statements
40
+ "TRY003", # raise-vanilla-args
41
+ ]
42
+ unfixable = [
43
+ "F401", # unused-import
44
+ ]
45
+
46
+ [tool.ruff.lint.pydocstyle]
47
+ convention = "google"
48
+
49
+ [tool.ruff.lint.per-file-ignores]
50
+ "*.ipynb" = ["T201", "T203"]
51
+
52
+ [tool.ruff.format]
53
+ docstring-code-format = true
requirements.txt ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # mcp
12
+ # sse-starlette
13
+ # starlette
14
+ attrs==25.3.0
15
+ # via
16
+ # jsonschema
17
+ # referencing
18
+ certifi==2025.4.26
19
+ # via
20
+ # httpcore
21
+ # httpx
22
+ # requests
23
+ charset-normalizer==3.4.2
24
+ # via requests
25
+ click==8.2.1
26
+ # via
27
+ # typer
28
+ # uvicorn
29
+ coloredlogs==15.0.1
30
+ # via onnxruntime
31
+ exceptiongroup==1.3.0
32
+ # via anyio
33
+ fastapi==0.115.12
34
+ # via gradio
35
+ ffmpy==0.5.0
36
+ # via gradio
37
+ filelock==3.18.0
38
+ # via huggingface-hub
39
+ flatbuffers==25.2.10
40
+ # via onnxruntime
41
+ fsspec==2025.5.1
42
+ # via
43
+ # gradio-client
44
+ # huggingface-hub
45
+ gradio==5.31.0
46
+ # via rembg-space (pyproject.toml)
47
+ gradio-client==1.10.1
48
+ # via gradio
49
+ groovy==0.1.2
50
+ # via gradio
51
+ h11==0.16.0
52
+ # via
53
+ # httpcore
54
+ # uvicorn
55
+ hf-transfer==0.1.9
56
+ # via rembg-space (pyproject.toml)
57
+ hf-xet==1.1.2
58
+ # via huggingface-hub
59
+ httpcore==1.0.9
60
+ # via httpx
61
+ httpx==0.28.1
62
+ # via
63
+ # gradio
64
+ # gradio-client
65
+ # mcp
66
+ # safehttpx
67
+ httpx-sse==0.4.0
68
+ # via mcp
69
+ huggingface-hub==0.32.1
70
+ # via
71
+ # gradio
72
+ # gradio-client
73
+ humanfriendly==10.0
74
+ # via coloredlogs
75
+ idna==3.10
76
+ # via
77
+ # anyio
78
+ # httpx
79
+ # requests
80
+ imageio==2.37.0
81
+ # via scikit-image
82
+ jinja2==3.1.6
83
+ # via gradio
84
+ jsonschema==4.24.0
85
+ # via rembg
86
+ jsonschema-specifications==2025.4.1
87
+ # via jsonschema
88
+ lazy-loader==0.4
89
+ # via scikit-image
90
+ llvmlite==0.44.0
91
+ # via numba
92
+ markdown-it-py==3.0.0
93
+ # via rich
94
+ markupsafe==3.0.2
95
+ # via
96
+ # gradio
97
+ # jinja2
98
+ mcp==1.9.0
99
+ # via gradio
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 scikit-image
106
+ numba==0.61.2
107
+ # via pymatting
108
+ numpy==2.2.6
109
+ # via
110
+ # gradio
111
+ # imageio
112
+ # numba
113
+ # onnxruntime
114
+ # opencv-python-headless
115
+ # pandas
116
+ # pymatting
117
+ # rembg
118
+ # scikit-image
119
+ # scipy
120
+ # tifffile
121
+ onnxruntime==1.22.0
122
+ # via rembg-space (pyproject.toml)
123
+ opencv-python-headless==4.11.0.86
124
+ # via rembg
125
+ orjson==3.10.18
126
+ # via gradio
127
+ packaging==25.0
128
+ # via
129
+ # gradio
130
+ # gradio-client
131
+ # huggingface-hub
132
+ # lazy-loader
133
+ # onnxruntime
134
+ # pooch
135
+ # scikit-image
136
+ pandas==2.2.3
137
+ # via gradio
138
+ pillow==11.2.1
139
+ # via
140
+ # gradio
141
+ # imageio
142
+ # pymatting
143
+ # rembg
144
+ # scikit-image
145
+ platformdirs==4.3.8
146
+ # via pooch
147
+ pooch==1.8.2
148
+ # via rembg
149
+ protobuf==6.31.0
150
+ # via onnxruntime
151
+ pydantic==2.11.5
152
+ # via
153
+ # fastapi
154
+ # gradio
155
+ # mcp
156
+ # pydantic-settings
157
+ pydantic-core==2.33.2
158
+ # via pydantic
159
+ pydantic-settings==2.9.1
160
+ # via mcp
161
+ pydub==0.25.1
162
+ # via gradio
163
+ pygments==2.19.1
164
+ # via rich
165
+ pymatting==1.1.14
166
+ # via rembg
167
+ python-dateutil==2.9.0.post0
168
+ # via pandas
169
+ python-dotenv==1.1.0
170
+ # via pydantic-settings
171
+ python-multipart==0.0.20
172
+ # via
173
+ # gradio
174
+ # mcp
175
+ pytz==2025.2
176
+ # via pandas
177
+ pyyaml==6.0.2
178
+ # via
179
+ # gradio
180
+ # huggingface-hub
181
+ referencing==0.36.2
182
+ # via
183
+ # jsonschema
184
+ # jsonschema-specifications
185
+ rembg==2.0.66
186
+ # via rembg-space (pyproject.toml)
187
+ requests==2.32.3
188
+ # via
189
+ # huggingface-hub
190
+ # pooch
191
+ rich==14.0.0
192
+ # via typer
193
+ rpds-py==0.25.1
194
+ # via
195
+ # jsonschema
196
+ # referencing
197
+ ruff==0.11.11
198
+ # via gradio
199
+ safehttpx==0.1.6
200
+ # via gradio
201
+ scikit-image==0.25.2
202
+ # via rembg
203
+ scipy==1.15.3
204
+ # via
205
+ # pymatting
206
+ # rembg
207
+ # scikit-image
208
+ semantic-version==2.10.0
209
+ # via gradio
210
+ shellingham==1.5.4
211
+ # via typer
212
+ six==1.17.0
213
+ # via python-dateutil
214
+ sniffio==1.3.1
215
+ # via anyio
216
+ sse-starlette==2.3.5
217
+ # via mcp
218
+ starlette==0.46.2
219
+ # via
220
+ # fastapi
221
+ # gradio
222
+ # mcp
223
+ # sse-starlette
224
+ sympy==1.14.0
225
+ # via onnxruntime
226
+ tifffile==2025.5.10
227
+ # via scikit-image
228
+ tomlkit==0.13.2
229
+ # via gradio
230
+ tqdm==4.67.1
231
+ # via
232
+ # huggingface-hub
233
+ # rembg
234
+ typer==0.16.0
235
+ # via gradio
236
+ typing-extensions==4.13.2
237
+ # via
238
+ # anyio
239
+ # exceptiongroup
240
+ # fastapi
241
+ # gradio
242
+ # gradio-client
243
+ # huggingface-hub
244
+ # pydantic
245
+ # pydantic-core
246
+ # referencing
247
+ # rich
248
+ # typer
249
+ # typing-inspection
250
+ # uvicorn
251
+ typing-inspection==0.4.1
252
+ # via
253
+ # pydantic
254
+ # pydantic-settings
255
+ tzdata==2025.2
256
+ # via pandas
257
+ urllib3==2.4.0
258
+ # via requests
259
+ uvicorn==0.34.2
260
+ # via
261
+ # gradio
262
+ # mcp
263
+ websockets==15.0.1
264
+ # via gradio-client
style.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ h1 {
2
+ text-align: center;
3
+ display: block;
4
+ }
uv.lock ADDED
The diff for this file is too large to render. See raw diff