useknockout 0.0.2__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,32 @@
1
- # Python
2
- __pycache__/
3
- *.py[cod]
4
- *$py.class
5
- *.egg-info/
6
- *.egg
7
- build/
8
- dist/
9
- .eggs/
10
- .venv/
11
- venv/
12
- env/
13
- .python-version
14
-
15
- # Tests / coverage
16
- .pytest_cache/
17
- .coverage
18
- htmlcov/
19
- .mypy_cache/
20
- .ruff_cache/
21
-
22
- # IDE
23
- .vscode/
24
- .idea/
25
- *.swp
26
- .DS_Store
27
-
28
- # Demo outputs
29
- out-*.png
30
- out-*.jpg
31
- demo-*.png
32
- demo-*.jpg
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ build/
8
+ dist/
9
+ .eggs/
10
+ .venv/
11
+ venv/
12
+ env/
13
+ .python-version
14
+
15
+ # Tests / coverage
16
+ .pytest_cache/
17
+ .coverage
18
+ htmlcov/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+
22
+ # IDE
23
+ .vscode/
24
+ .idea/
25
+ *.swp
26
+ .DS_Store
27
+
28
+ # Demo outputs
29
+ out-*.png
30
+ out-*.jpg
31
+ demo-*.png
32
+ demo-*.jpg
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 useknockout
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 useknockout
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: useknockout
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Python SDK for useknockout — state-of-the-art background removal API.
5
5
  Project-URL: Homepage, https://useknockout.com
6
6
  Project-URL: Documentation, https://github.com/useknockout/python
@@ -1,159 +1,159 @@
1
- <div align="center">
2
-
3
- # 🥊 useknockout
4
-
5
- **State-of-the-art background removal API — Python SDK.**
6
-
7
- [![PyPI](https://img.shields.io/pypi/v/useknockout.svg)](https://pypi.org/project/useknockout/)
8
- [![Python](https://img.shields.io/pypi/pyversions/useknockout.svg)](https://pypi.org/project/useknockout/)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
10
-
11
- [Website](https://useknockout.com) ·
12
- [API repo](https://github.com/useknockout/api) ·
13
- [Node SDK](https://github.com/useknockout/node) ·
14
- [React SDK](https://github.com/useknockout/react) ·
15
- [CLI](https://github.com/useknockout/cli)
16
-
17
- <img src="https://raw.githubusercontent.com/useknockout/api/main/docs/banner.png" width="800" alt="useknockout — background removal API for developers" />
18
-
19
- *Background removal, 40× cheaper than remove.bg. MIT licensed. Self-hostable.*
20
-
21
- </div>
22
-
23
- ---
24
-
25
- ## Install
26
-
27
- ```bash
28
- pip install useknockout
29
- ```
30
-
31
- ## Quickstart
32
-
33
- ```python
34
- from useknockout import Knockout
35
-
36
- client = Knockout() # uses public beta token by default
37
- png = client.remove("photo.jpg")
38
-
39
- with open("out.png", "wb") as f:
40
- f.write(png)
41
- ```
42
-
43
- That's it. Free during the public beta.
44
-
45
- ## Async
46
-
47
- ```python
48
- import asyncio
49
- from useknockout import AsyncKnockout
50
-
51
- async def main():
52
- async with AsyncKnockout() as client:
53
- png = await client.remove("photo.jpg")
54
- open("out.png", "wb").write(png)
55
-
56
- asyncio.run(main())
57
- ```
58
-
59
- ## Authentication
60
-
61
- The client falls back through three sources in order:
62
-
63
- 1. The `token=` argument
64
- 2. The `KNOCKOUT_TOKEN` environment variable
65
- 3. The public beta token (free, rate-limited, in the README of the API repo)
66
-
67
- Get your own token by emailing `troy@useknockout.com` (paid tier launches at $0.005/image — 40× cheaper than remove.bg).
68
-
69
- ## All endpoints
70
-
71
- ```python
72
- from useknockout import Knockout
73
-
74
- c = Knockout()
75
-
76
- # Remove background
77
- c.remove("photo.jpg") # returns PNG bytes
78
- c.remove_url("https://example.com/photo.jpg")
79
- c.remove_batch(["a.jpg", "b.jpg", "c.jpg"]) # up to 10
80
- c.remove_batch_url(["https://...", "https://..."])
81
-
82
- # Replace background
83
- c.replace_background("photo.jpg", bg_color="#000000")
84
- c.replace_background("photo.jpg", bg_url="https://example.com/bg.jpg")
85
-
86
- # Mask only
87
- c.mask("photo.jpg") # returns grayscale PNG
88
-
89
- # Crop to subject
90
- c.smart_crop("photo.jpg", padding=24)
91
-
92
- # Effects
93
- c.shadow("photo.jpg", shadow_blur=14, shadow_opacity=0.45)
94
- c.sticker("photo.jpg", stroke_width=20) # WhatsApp-style
95
- c.outline("photo.jpg", outline_color="#000000", outline_width=4)
96
-
97
- # Presets
98
- c.studio_shot("photo.jpg", aspect="1:1", shadow=True) # e-commerce
99
- c.headshot("photo.jpg", bg_color="#FFFFFF") # LinkedIn 4:5 portrait
100
- c.headshot("photo.jpg", bg_blur=True, blur_radius=24) # blurred original bg
101
-
102
- # Marketing
103
- c.compare("photo.jpg") # before/after side-by-side
104
-
105
- # UX helpers
106
- c.preview("photo.jpg", max_dim=512) # ~80ms warm
107
- c.estimate("remove", width=1024, height=1024) # predict latency + cost
108
-
109
- # Telemetry
110
- c.health()
111
- c.stats() # public usage counter
112
- ```
113
-
114
- Every method that returns an image returns raw bytes. Pipe to `open(path, "wb").write(...)`, `BytesIO`, `PIL.Image.open(BytesIO(...))`, `numpy`, S3 — anywhere bytes go.
115
-
116
- ## Errors
117
-
118
- All errors inherit from `KnockoutError`:
119
-
120
- ```python
121
- from useknockout import Knockout
122
- from useknockout.errors import (
123
- AuthError, # 401 / 403
124
- BadRequestError, # 400
125
- PayloadTooLargeError,# 413 (>25 MB)
126
- RateLimitError, # 429
127
- ServerError, # 5xx
128
- KnockoutError, # base class / network errors
129
- )
130
-
131
- try:
132
- png = client.remove("photo.jpg")
133
- except AuthError:
134
- ... # bad token
135
- except RateLimitError:
136
- ... # back off
137
- except KnockoutError as e:
138
- print(f"{e.code} ({e.status}): {e.message}")
139
- ```
140
-
141
- ## Self-host
142
-
143
- The API is open source and runs on Modal. Deploy your own copy:
144
-
145
- ```bash
146
- git clone https://github.com/useknockout/api
147
- cd api
148
- modal deploy main.py
149
- ```
150
-
151
- Then point the SDK at your deployment:
152
-
153
- ```python
154
- client = Knockout(token="your-token", base_url="https://your-deploy.modal.run")
155
- ```
156
-
157
- ## License
158
-
159
- MIT. Use it however you want.
1
+ <div align="center">
2
+
3
+ # 🥊 useknockout
4
+
5
+ **State-of-the-art background removal API — Python SDK.**
6
+
7
+ [![PyPI](https://img.shields.io/pypi/v/useknockout.svg)](https://pypi.org/project/useknockout/)
8
+ [![Python](https://img.shields.io/pypi/pyversions/useknockout.svg)](https://pypi.org/project/useknockout/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
10
+
11
+ [Website](https://useknockout.com) ·
12
+ [API repo](https://github.com/useknockout/api) ·
13
+ [Node SDK](https://github.com/useknockout/node) ·
14
+ [React SDK](https://github.com/useknockout/react) ·
15
+ [CLI](https://github.com/useknockout/cli)
16
+
17
+ <img src="https://raw.githubusercontent.com/useknockout/api/main/docs/banner.png" width="800" alt="useknockout — background removal API for developers" />
18
+
19
+ *Background removal, 40× cheaper than remove.bg. MIT licensed. Self-hostable.*
20
+
21
+ </div>
22
+
23
+ ---
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install useknockout
29
+ ```
30
+
31
+ ## Quickstart
32
+
33
+ ```python
34
+ from useknockout import Knockout
35
+
36
+ client = Knockout() # uses public beta token by default
37
+ png = client.remove("photo.jpg")
38
+
39
+ with open("out.png", "wb") as f:
40
+ f.write(png)
41
+ ```
42
+
43
+ That's it. Free during the public beta.
44
+
45
+ ## Async
46
+
47
+ ```python
48
+ import asyncio
49
+ from useknockout import AsyncKnockout
50
+
51
+ async def main():
52
+ async with AsyncKnockout() as client:
53
+ png = await client.remove("photo.jpg")
54
+ open("out.png", "wb").write(png)
55
+
56
+ asyncio.run(main())
57
+ ```
58
+
59
+ ## Authentication
60
+
61
+ The client falls back through three sources in order:
62
+
63
+ 1. The `token=` argument
64
+ 2. The `KNOCKOUT_TOKEN` environment variable
65
+ 3. The public beta token (free, rate-limited, in the README of the API repo)
66
+
67
+ Get your own token by emailing `troy@useknockout.com` (paid tier launches at $0.005/image — 40× cheaper than remove.bg).
68
+
69
+ ## All endpoints
70
+
71
+ ```python
72
+ from useknockout import Knockout
73
+
74
+ c = Knockout()
75
+
76
+ # Remove background
77
+ c.remove("photo.jpg") # returns PNG bytes
78
+ c.remove_url("https://example.com/photo.jpg")
79
+ c.remove_batch(["a.jpg", "b.jpg", "c.jpg"]) # up to 10
80
+ c.remove_batch_url(["https://...", "https://..."])
81
+
82
+ # Replace background
83
+ c.replace_background("photo.jpg", bg_color="#000000")
84
+ c.replace_background("photo.jpg", bg_url="https://example.com/bg.jpg")
85
+
86
+ # Mask only
87
+ c.mask("photo.jpg") # returns grayscale PNG
88
+
89
+ # Crop to subject
90
+ c.smart_crop("photo.jpg", padding=24)
91
+
92
+ # Effects
93
+ c.shadow("photo.jpg", shadow_blur=14, shadow_opacity=0.45)
94
+ c.sticker("photo.jpg", stroke_width=20) # WhatsApp-style
95
+ c.outline("photo.jpg", outline_color="#000000", outline_width=4)
96
+
97
+ # Presets
98
+ c.studio_shot("photo.jpg", aspect="1:1", shadow=True) # e-commerce
99
+ c.headshot("photo.jpg", bg_color="#FFFFFF") # LinkedIn 4:5 portrait
100
+ c.headshot("photo.jpg", bg_blur=True, blur_radius=24) # blurred original bg
101
+
102
+ # Marketing
103
+ c.compare("photo.jpg") # before/after side-by-side
104
+
105
+ # UX helpers
106
+ c.preview("photo.jpg", max_dim=512) # ~80ms warm
107
+ c.estimate("remove", width=1024, height=1024) # predict latency + cost
108
+
109
+ # Telemetry
110
+ c.health()
111
+ c.stats() # public usage counter
112
+ ```
113
+
114
+ Every method that returns an image returns raw bytes. Pipe to `open(path, "wb").write(...)`, `BytesIO`, `PIL.Image.open(BytesIO(...))`, `numpy`, S3 — anywhere bytes go.
115
+
116
+ ## Errors
117
+
118
+ All errors inherit from `KnockoutError`:
119
+
120
+ ```python
121
+ from useknockout import Knockout
122
+ from useknockout.errors import (
123
+ AuthError, # 401 / 403
124
+ BadRequestError, # 400
125
+ PayloadTooLargeError,# 413 (>25 MB)
126
+ RateLimitError, # 429
127
+ ServerError, # 5xx
128
+ KnockoutError, # base class / network errors
129
+ )
130
+
131
+ try:
132
+ png = client.remove("photo.jpg")
133
+ except AuthError:
134
+ ... # bad token
135
+ except RateLimitError:
136
+ ... # back off
137
+ except KnockoutError as e:
138
+ print(f"{e.code} ({e.status}): {e.message}")
139
+ ```
140
+
141
+ ## Self-host
142
+
143
+ The API is open source and runs on Modal. Deploy your own copy:
144
+
145
+ ```bash
146
+ git clone https://github.com/useknockout/api
147
+ cd api
148
+ modal deploy main.py
149
+ ```
150
+
151
+ Then point the SDK at your deployment:
152
+
153
+ ```python
154
+ client = Knockout(token="your-token", base_url="https://your-deploy.modal.run")
155
+ ```
156
+
157
+ ## License
158
+
159
+ MIT. Use it however you want.
@@ -1,60 +1,60 @@
1
- [build-system]
2
- requires = ["hatchling"]
3
- build-backend = "hatchling.build"
4
-
5
- [project]
6
- name = "useknockout"
7
- version = "0.0.2"
8
- description = "Python SDK for useknockout — state-of-the-art background removal API."
9
- readme = "README.md"
10
- license = { text = "MIT" }
11
- requires-python = ">=3.9"
12
- authors = [{ name = "useknockout" }]
13
- keywords = [
14
- "background-removal",
15
- "remove-background",
16
- "birefnet",
17
- "ai",
18
- "image-processing",
19
- "useknockout",
20
- ]
21
- classifiers = [
22
- "Development Status :: 4 - Beta",
23
- "Intended Audience :: Developers",
24
- "License :: OSI Approved :: MIT License",
25
- "Programming Language :: Python :: 3",
26
- "Programming Language :: Python :: 3.9",
27
- "Programming Language :: Python :: 3.10",
28
- "Programming Language :: Python :: 3.11",
29
- "Programming Language :: Python :: 3.12",
30
- "Programming Language :: Python :: 3.13",
31
- "Topic :: Multimedia :: Graphics",
32
- "Topic :: Scientific/Engineering :: Image Processing",
33
- ]
34
- dependencies = [
35
- "httpx>=0.27.0",
36
- ]
37
-
38
- [project.optional-dependencies]
39
- dev = [
40
- "pytest>=8.0",
41
- "pytest-asyncio>=0.23",
42
- "ruff>=0.6.0",
43
- "mypy>=1.10",
44
- ]
45
-
46
- [project.urls]
47
- Homepage = "https://useknockout.com"
48
- Documentation = "https://github.com/useknockout/python"
49
- Repository = "https://github.com/useknockout/python"
50
- Issues = "https://github.com/useknockout/python/issues"
51
-
52
- [tool.hatch.build.targets.wheel]
53
- packages = ["src/useknockout"]
54
-
55
- [tool.ruff]
56
- line-length = 100
57
- target-version = "py39"
58
-
59
- [tool.ruff.lint]
60
- select = ["E", "F", "I", "W", "UP"]
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "useknockout"
7
+ version = "0.0.4"
8
+ description = "Python SDK for useknockout — state-of-the-art background removal API."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "useknockout" }]
13
+ keywords = [
14
+ "background-removal",
15
+ "remove-background",
16
+ "birefnet",
17
+ "ai",
18
+ "image-processing",
19
+ "useknockout",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 4 - Beta",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.9",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Multimedia :: Graphics",
32
+ "Topic :: Scientific/Engineering :: Image Processing",
33
+ ]
34
+ dependencies = [
35
+ "httpx>=0.27.0",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ dev = [
40
+ "pytest>=8.0",
41
+ "pytest-asyncio>=0.23",
42
+ "ruff>=0.6.0",
43
+ "mypy>=1.10",
44
+ ]
45
+
46
+ [project.urls]
47
+ Homepage = "https://useknockout.com"
48
+ Documentation = "https://github.com/useknockout/python"
49
+ Repository = "https://github.com/useknockout/python"
50
+ Issues = "https://github.com/useknockout/python/issues"
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["src/useknockout"]
54
+
55
+ [tool.ruff]
56
+ line-length = 100
57
+ target-version = "py39"
58
+
59
+ [tool.ruff.lint]
60
+ select = ["E", "F", "I", "W", "UP"]
@@ -1,47 +1,47 @@
1
- """
2
- useknockout — state-of-the-art background removal API.
3
-
4
- Quickstart:
5
-
6
- from useknockout import Knockout
7
-
8
- client = Knockout(token="kno_public_beta_4d7e9f1a3c5b2e8d6a9f7c1b3e5d8a2f")
9
- png_bytes = client.remove("photo.jpg")
10
- open("out.png", "wb").write(png_bytes)
11
-
12
- Async:
13
-
14
- import asyncio
15
- from useknockout import AsyncKnockout
16
-
17
- async def main():
18
- async with AsyncKnockout(token="...") as client:
19
- png = await client.remove("photo.jpg")
20
- open("out.png", "wb").write(png)
21
-
22
- asyncio.run(main())
23
- """
24
-
25
- from useknockout._version import __version__
26
- from useknockout.client import Knockout
27
- from useknockout.async_client import AsyncKnockout
28
- from useknockout.errors import (
29
- KnockoutError,
30
- AuthError,
31
- BadRequestError,
32
- PayloadTooLargeError,
33
- RateLimitError,
34
- ServerError,
35
- )
36
-
37
- __all__ = [
38
- "__version__",
39
- "Knockout",
40
- "AsyncKnockout",
41
- "KnockoutError",
42
- "AuthError",
43
- "BadRequestError",
44
- "PayloadTooLargeError",
45
- "RateLimitError",
46
- "ServerError",
47
- ]
1
+ """
2
+ useknockout — state-of-the-art background removal API.
3
+
4
+ Quickstart:
5
+
6
+ from useknockout import Knockout
7
+
8
+ client = Knockout(token="kno_public_beta_4d7e9f1a3c5b2e8d6a9f7c1b3e5d8a2f")
9
+ png_bytes = client.remove("photo.jpg")
10
+ open("out.png", "wb").write(png_bytes)
11
+
12
+ Async:
13
+
14
+ import asyncio
15
+ from useknockout import AsyncKnockout
16
+
17
+ async def main():
18
+ async with AsyncKnockout(token="...") as client:
19
+ png = await client.remove("photo.jpg")
20
+ open("out.png", "wb").write(png)
21
+
22
+ asyncio.run(main())
23
+ """
24
+
25
+ from useknockout._version import __version__
26
+ from useknockout.client import Knockout
27
+ from useknockout.async_client import AsyncKnockout
28
+ from useknockout.errors import (
29
+ KnockoutError,
30
+ AuthError,
31
+ BadRequestError,
32
+ PayloadTooLargeError,
33
+ RateLimitError,
34
+ ServerError,
35
+ )
36
+
37
+ __all__ = [
38
+ "__version__",
39
+ "Knockout",
40
+ "AsyncKnockout",
41
+ "KnockoutError",
42
+ "AuthError",
43
+ "BadRequestError",
44
+ "PayloadTooLargeError",
45
+ "RateLimitError",
46
+ "ServerError",
47
+ ]