useknockout 0.6.0__tar.gz → 0.8.0__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.
- useknockout-0.8.0/.remember/.gitignore +1 -0
- useknockout-0.8.0/.remember/logs/hook-errors.log +0 -0
- useknockout-0.8.0/.remember/logs/memory-2026-07-30.log +8 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/PKG-INFO +2 -2
- {useknockout-0.6.0 → useknockout-0.8.0}/pyproject.toml +60 -60
- useknockout-0.8.0/src/useknockout/_version.py +1 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/src/useknockout/async_client.py +99 -9
- {useknockout-0.6.0 → useknockout-0.8.0}/src/useknockout/client.py +114 -11
- useknockout-0.6.0/src/useknockout/_version.py +0 -1
- {useknockout-0.6.0 → useknockout-0.8.0}/.gitignore +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/LICENSE +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/README.md +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/SERVICES.md +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/TECHSTACK.md +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/src/useknockout/__init__.py +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/src/useknockout/_helpers.py +0 -0
- {useknockout-0.6.0 → useknockout-0.8.0}/src/useknockout/errors.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
01:27:19 [hook] session-start: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
2
|
+
01:29:21 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
3
|
+
01:29:24 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
4
|
+
01:29:35 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
5
|
+
01:29:46 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
6
|
+
01:30:06 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
7
|
+
01:30:12 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
8
|
+
01:30:33 [hook] post-tool: PROJECT_DIR=C:/Users/Troy/projects/useknockout-python PIPELINE_DIR=C:/Users/Troy/.claude/plugins/cache/claude-plugins-official/remember/0.8.3 PYTHON=python REMEMBER_DIR=C:/Users/Troy/projects/useknockout-python/.remember
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: useknockout
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
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,60 +1,60 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
3
|
-
build-backend = "hatchling.build"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "useknockout"
|
|
7
|
-
version = "0.
|
|
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.8.0"
|
|
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"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0"
|
|
@@ -88,11 +88,13 @@ class AsyncKnockout:
|
|
|
88
88
|
data=None,
|
|
89
89
|
json=None,
|
|
90
90
|
params=None,
|
|
91
|
+
timeout=None,
|
|
91
92
|
) -> Any:
|
|
92
93
|
try:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
kwargs = {"files": files, "data": data, "json": json, "params": params}
|
|
95
|
+
if timeout is not None:
|
|
96
|
+
kwargs["timeout"] = timeout
|
|
97
|
+
r = await self._http.request(method, path, **kwargs)
|
|
96
98
|
except httpx.RequestError as e:
|
|
97
99
|
raise KnockoutError(f"network error: {e}", code="unknown") from e
|
|
98
100
|
if r.status_code >= 400:
|
|
@@ -108,20 +110,47 @@ class AsyncKnockout:
|
|
|
108
110
|
async def stats(self) -> Dict[str, Any]:
|
|
109
111
|
return await self._request_json("GET", "/stats")
|
|
110
112
|
|
|
111
|
-
async def remove(
|
|
112
|
-
|
|
113
|
+
async def remove(
|
|
114
|
+
self,
|
|
115
|
+
file: FileInput,
|
|
116
|
+
*,
|
|
117
|
+
format: str = "png",
|
|
118
|
+
edge: str = "soft",
|
|
119
|
+
detect: str = "standard",
|
|
120
|
+
decontaminate: bool = False,
|
|
121
|
+
) -> bytes:
|
|
122
|
+
# All params are Form fields — they must ride in the multipart body.
|
|
113
123
|
return await self._request_bytes(
|
|
114
124
|
"POST",
|
|
115
125
|
"/remove",
|
|
116
126
|
files=_multipart_files(file),
|
|
117
|
-
|
|
127
|
+
data=_form({
|
|
128
|
+
"format": format,
|
|
129
|
+
"edge": edge,
|
|
130
|
+
"detect": detect,
|
|
131
|
+
"decontaminate": decontaminate,
|
|
132
|
+
}),
|
|
118
133
|
)
|
|
119
134
|
|
|
120
|
-
async def remove_url(
|
|
135
|
+
async def remove_url(
|
|
136
|
+
self,
|
|
137
|
+
url: str,
|
|
138
|
+
*,
|
|
139
|
+
format: str = "png",
|
|
140
|
+
edge: str = "soft",
|
|
141
|
+
detect: str = "standard",
|
|
142
|
+
decontaminate: bool = False,
|
|
143
|
+
) -> bytes:
|
|
121
144
|
return await self._request_bytes(
|
|
122
145
|
"POST",
|
|
123
146
|
"/remove-url",
|
|
124
|
-
json={
|
|
147
|
+
json={
|
|
148
|
+
"url": url,
|
|
149
|
+
"format": format,
|
|
150
|
+
"edge": edge,
|
|
151
|
+
"detect": detect,
|
|
152
|
+
"decontaminate": decontaminate,
|
|
153
|
+
},
|
|
125
154
|
)
|
|
126
155
|
|
|
127
156
|
async def replace_background(
|
|
@@ -179,12 +208,20 @@ class AsyncKnockout:
|
|
|
179
208
|
padding: int = 24,
|
|
180
209
|
transparent: bool = True,
|
|
181
210
|
format: str = "png",
|
|
211
|
+
detect: str = "standard",
|
|
212
|
+
decontaminate: bool = False,
|
|
182
213
|
) -> bytes:
|
|
183
214
|
return await self._request_bytes(
|
|
184
215
|
"POST",
|
|
185
216
|
"/smart-crop",
|
|
186
217
|
files=_multipart_files(file),
|
|
187
|
-
data=_form({
|
|
218
|
+
data=_form({
|
|
219
|
+
"padding": padding,
|
|
220
|
+
"transparent": transparent,
|
|
221
|
+
"format": format,
|
|
222
|
+
"detect": detect,
|
|
223
|
+
"decontaminate": decontaminate,
|
|
224
|
+
}),
|
|
188
225
|
)
|
|
189
226
|
|
|
190
227
|
async def shadow(
|
|
@@ -264,6 +301,8 @@ class AsyncKnockout:
|
|
|
264
301
|
enhance: bool = False,
|
|
265
302
|
enhance_strength: float = 0.15,
|
|
266
303
|
format: str = "jpg",
|
|
304
|
+
detect: str = "standard",
|
|
305
|
+
decontaminate: bool = False,
|
|
267
306
|
) -> bytes:
|
|
268
307
|
return await self._request_bytes(
|
|
269
308
|
"POST",
|
|
@@ -279,6 +318,8 @@ class AsyncKnockout:
|
|
|
279
318
|
"enhance": enhance,
|
|
280
319
|
"enhance_strength": enhance_strength,
|
|
281
320
|
"format": format,
|
|
321
|
+
"detect": detect,
|
|
322
|
+
"decontaminate": decontaminate,
|
|
282
323
|
}
|
|
283
324
|
),
|
|
284
325
|
)
|
|
@@ -315,6 +356,55 @@ class AsyncKnockout:
|
|
|
315
356
|
timeout=45.0 + len(files) * 20.0,
|
|
316
357
|
)
|
|
317
358
|
|
|
359
|
+
async def video_remove(
|
|
360
|
+
self,
|
|
361
|
+
file: FileInput,
|
|
362
|
+
*,
|
|
363
|
+
format: str = "prores4444",
|
|
364
|
+
bg_color: Optional[str] = None,
|
|
365
|
+
smoothing: int = 30,
|
|
366
|
+
) -> Dict[str, Any]:
|
|
367
|
+
"""POST /video/remove — async video background removal. Returns the job
|
|
368
|
+
dict; poll with get_job() or use video_remove_and_wait(). Paid tiers,
|
|
369
|
+
$0.05/output-second, 30s/200MB caps."""
|
|
370
|
+
return await self._request_json(
|
|
371
|
+
"POST",
|
|
372
|
+
"/video/remove",
|
|
373
|
+
files=_multipart_files(file),
|
|
374
|
+
data=_form({"format": format, "bg_color": bg_color, "smoothing": smoothing}),
|
|
375
|
+
timeout=300.0,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
async def get_job(self, job_id: str) -> Dict[str, Any]:
|
|
379
|
+
"""GET /jobs/{job_id} — poll a video job once."""
|
|
380
|
+
return await self._request_json("GET", f"/jobs/{job_id}")
|
|
381
|
+
|
|
382
|
+
async def video_remove_and_wait(
|
|
383
|
+
self,
|
|
384
|
+
file: FileInput,
|
|
385
|
+
*,
|
|
386
|
+
format: str = "prores4444",
|
|
387
|
+
bg_color: Optional[str] = None,
|
|
388
|
+
smoothing: int = 30,
|
|
389
|
+
poll_interval: float = 5.0,
|
|
390
|
+
timeout: float = 900.0,
|
|
391
|
+
) -> Dict[str, Any]:
|
|
392
|
+
"""Submit a video and await completion. Returns the final job dict;
|
|
393
|
+
raises KnockoutError on job failure or wait timeout."""
|
|
394
|
+
import asyncio as _asyncio
|
|
395
|
+
import time as _time
|
|
396
|
+
|
|
397
|
+
job = await self.video_remove(file, format=format, bg_color=bg_color, smoothing=smoothing)
|
|
398
|
+
deadline = _time.monotonic() + timeout
|
|
399
|
+
while job.get("status") in ("queued", "processing"):
|
|
400
|
+
if _time.monotonic() > deadline:
|
|
401
|
+
raise KnockoutError(f"video job {job.get('job_id')} still running after {timeout}s", code="timeout")
|
|
402
|
+
await _asyncio.sleep(poll_interval)
|
|
403
|
+
job = await self.get_job(job["job_id"])
|
|
404
|
+
if job.get("status") == "error":
|
|
405
|
+
raise KnockoutError(f"video job {job.get('job_id')} failed: {job.get('error')}", code="job_error")
|
|
406
|
+
return job
|
|
407
|
+
|
|
318
408
|
async def compare(self, file: FileInput, *, format: str = "png") -> bytes:
|
|
319
409
|
return await self._request_bytes(
|
|
320
410
|
"POST",
|
|
@@ -98,11 +98,13 @@ class Knockout:
|
|
|
98
98
|
data=None,
|
|
99
99
|
json=None,
|
|
100
100
|
params=None,
|
|
101
|
+
timeout=None,
|
|
101
102
|
) -> Any:
|
|
102
103
|
try:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
kwargs = {"files": files, "data": data, "json": json, "params": params}
|
|
105
|
+
if timeout is not None:
|
|
106
|
+
kwargs["timeout"] = timeout
|
|
107
|
+
r = self._http.request(method, path, **kwargs)
|
|
106
108
|
except httpx.RequestError as e:
|
|
107
109
|
raise KnockoutError(f"network error: {e}", code="unknown") from e
|
|
108
110
|
if r.status_code >= 400:
|
|
@@ -122,23 +124,58 @@ class Knockout:
|
|
|
122
124
|
"""GET /stats — public usage counter (total + today + last 7 days)."""
|
|
123
125
|
return self._request_json("GET", "/stats")
|
|
124
126
|
|
|
125
|
-
def remove(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
def remove(
|
|
128
|
+
self,
|
|
129
|
+
file: FileInput,
|
|
130
|
+
*,
|
|
131
|
+
format: str = "png",
|
|
132
|
+
edge: str = "soft",
|
|
133
|
+
detect: str = "standard",
|
|
134
|
+
decontaminate: bool = False,
|
|
135
|
+
) -> bytes:
|
|
136
|
+
"""POST /remove — remove background, return transparent PNG/WebP bytes.
|
|
137
|
+
|
|
138
|
+
edge: "soft" (default) or "hard" — hard commits ambiguous edge pixels
|
|
139
|
+
for a crisp product cut; keep soft for hair and fur.
|
|
140
|
+
detect: "standard" (default) or "high_recall" — second pass recovers
|
|
141
|
+
low-contrast product edges. Paid tiers; roughly 2x latency.
|
|
142
|
+
decontaminate: remove background-colored contamination at mask edges.
|
|
143
|
+
"""
|
|
144
|
+
# NOTE: the API reads ALL of these as Form fields — they must go in the
|
|
145
|
+
# multipart body. (A previous version sent format as a query param,
|
|
146
|
+
# which the API silently ignored.)
|
|
129
147
|
return self._request_bytes(
|
|
130
148
|
"POST",
|
|
131
149
|
"/remove",
|
|
132
150
|
files=_multipart_files(file),
|
|
133
|
-
|
|
151
|
+
data=_form({
|
|
152
|
+
"format": format,
|
|
153
|
+
"edge": edge,
|
|
154
|
+
"detect": detect,
|
|
155
|
+
"decontaminate": decontaminate,
|
|
156
|
+
}),
|
|
134
157
|
)
|
|
135
158
|
|
|
136
|
-
def remove_url(
|
|
159
|
+
def remove_url(
|
|
160
|
+
self,
|
|
161
|
+
url: str,
|
|
162
|
+
*,
|
|
163
|
+
format: str = "png",
|
|
164
|
+
edge: str = "soft",
|
|
165
|
+
detect: str = "standard",
|
|
166
|
+
decontaminate: bool = False,
|
|
167
|
+
) -> bytes:
|
|
137
168
|
"""POST /remove-url — fetch remote image, return transparent PNG/WebP."""
|
|
138
169
|
return self._request_bytes(
|
|
139
170
|
"POST",
|
|
140
171
|
"/remove-url",
|
|
141
|
-
json={
|
|
172
|
+
json={
|
|
173
|
+
"url": url,
|
|
174
|
+
"format": format,
|
|
175
|
+
"edge": edge,
|
|
176
|
+
"detect": detect,
|
|
177
|
+
"decontaminate": decontaminate,
|
|
178
|
+
},
|
|
142
179
|
)
|
|
143
180
|
|
|
144
181
|
def replace_background(
|
|
@@ -200,13 +237,21 @@ class Knockout:
|
|
|
200
237
|
padding: int = 24,
|
|
201
238
|
transparent: bool = True,
|
|
202
239
|
format: str = "png",
|
|
240
|
+
detect: str = "standard",
|
|
241
|
+
decontaminate: bool = False,
|
|
203
242
|
) -> bytes:
|
|
204
243
|
"""POST /smart-crop — crop to subject bbox + padding."""
|
|
205
244
|
return self._request_bytes(
|
|
206
245
|
"POST",
|
|
207
246
|
"/smart-crop",
|
|
208
247
|
files=_multipart_files(file),
|
|
209
|
-
data=_form({
|
|
248
|
+
data=_form({
|
|
249
|
+
"padding": padding,
|
|
250
|
+
"transparent": transparent,
|
|
251
|
+
"format": format,
|
|
252
|
+
"detect": detect,
|
|
253
|
+
"decontaminate": decontaminate,
|
|
254
|
+
}),
|
|
210
255
|
)
|
|
211
256
|
|
|
212
257
|
def shadow(
|
|
@@ -289,6 +334,8 @@ class Knockout:
|
|
|
289
334
|
enhance: bool = False,
|
|
290
335
|
enhance_strength: float = 0.15,
|
|
291
336
|
format: str = "jpg",
|
|
337
|
+
detect: str = "standard",
|
|
338
|
+
decontaminate: bool = False,
|
|
292
339
|
) -> bytes:
|
|
293
340
|
"""POST /studio-shot — e-commerce preset (cutout + crop + center + shadow).
|
|
294
341
|
|
|
@@ -313,6 +360,8 @@ class Knockout:
|
|
|
313
360
|
"enhance": enhance,
|
|
314
361
|
"enhance_strength": enhance_strength,
|
|
315
362
|
"format": format,
|
|
363
|
+
"detect": detect,
|
|
364
|
+
"decontaminate": decontaminate,
|
|
316
365
|
}
|
|
317
366
|
),
|
|
318
367
|
)
|
|
@@ -357,6 +406,60 @@ class Knockout:
|
|
|
357
406
|
timeout=45.0 + len(files) * 20.0,
|
|
358
407
|
)
|
|
359
408
|
|
|
409
|
+
def video_remove(
|
|
410
|
+
self,
|
|
411
|
+
file: FileInput,
|
|
412
|
+
*,
|
|
413
|
+
format: str = "prores4444",
|
|
414
|
+
bg_color: Optional[str] = None,
|
|
415
|
+
smoothing: int = 30,
|
|
416
|
+
) -> Dict[str, Any]:
|
|
417
|
+
"""POST /video/remove — async video background removal. Returns the job
|
|
418
|
+
dict immediately ({job_id, status, seconds, ...}); poll with get_job()
|
|
419
|
+
or use video_remove_and_wait().
|
|
420
|
+
|
|
421
|
+
format: 'prores4444' (MOV, real 10-bit alpha), 'webm' (VP9 alpha), or
|
|
422
|
+
'mp4' (H.264 — requires bg_color). Paid tiers only, $0.05 per output
|
|
423
|
+
second, billed on success. Caps: 30s clip, 30fps, 200MB.
|
|
424
|
+
"""
|
|
425
|
+
return self._request_json(
|
|
426
|
+
"POST",
|
|
427
|
+
"/video/remove",
|
|
428
|
+
files=_multipart_files(file),
|
|
429
|
+
data=_form({"format": format, "bg_color": bg_color, "smoothing": smoothing}),
|
|
430
|
+
timeout=300.0, # uploads up to 200MB + server-side probe
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
def get_job(self, job_id: str) -> Dict[str, Any]:
|
|
434
|
+
"""GET /jobs/{job_id} — poll a video job once."""
|
|
435
|
+
return self._request_json("GET", f"/jobs/{job_id}")
|
|
436
|
+
|
|
437
|
+
def video_remove_and_wait(
|
|
438
|
+
self,
|
|
439
|
+
file: FileInput,
|
|
440
|
+
*,
|
|
441
|
+
format: str = "prores4444",
|
|
442
|
+
bg_color: Optional[str] = None,
|
|
443
|
+
smoothing: int = 30,
|
|
444
|
+
poll_interval: float = 5.0,
|
|
445
|
+
timeout: float = 900.0,
|
|
446
|
+
) -> Dict[str, Any]:
|
|
447
|
+
"""Submit a video and block until it finishes. Returns the final job
|
|
448
|
+
dict (status 'done', result_url set). Raises KnockoutError on job
|
|
449
|
+
failure or wait timeout."""
|
|
450
|
+
import time as _time
|
|
451
|
+
|
|
452
|
+
job = self.video_remove(file, format=format, bg_color=bg_color, smoothing=smoothing)
|
|
453
|
+
deadline = _time.monotonic() + timeout
|
|
454
|
+
while job.get("status") in ("queued", "processing"):
|
|
455
|
+
if _time.monotonic() > deadline:
|
|
456
|
+
raise KnockoutError(f"video job {job.get('job_id')} still running after {timeout}s", code="timeout")
|
|
457
|
+
_time.sleep(poll_interval)
|
|
458
|
+
job = self.get_job(job["job_id"])
|
|
459
|
+
if job.get("status") == "error":
|
|
460
|
+
raise KnockoutError(f"video job {job.get('job_id')} failed: {job.get('error')}", code="job_error")
|
|
461
|
+
return job
|
|
462
|
+
|
|
360
463
|
def compare(self, file: FileInput, *, format: str = "png") -> bytes:
|
|
361
464
|
"""POST /compare — side-by-side before/after image."""
|
|
362
465
|
return self._request_bytes(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.6.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|