useknockout 0.0.1__tar.gz → 0.0.2__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: useknockout
3
- Version: 0.0.1
3
+ Version: 0.0.2
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "useknockout"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  description = "Python SDK for useknockout — state-of-the-art background removal API."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -0,0 +1 @@
1
+ __version__ = "0.0.2"
@@ -323,3 +323,34 @@ class AsyncKnockout:
323
323
  "/estimate",
324
324
  json={"endpoint": endpoint, "width": width, "height": height},
325
325
  )
326
+
327
+ async def upscale(
328
+ self,
329
+ file: FileInput,
330
+ *,
331
+ scale: int = 4,
332
+ face_enhance: bool = False,
333
+ format: str = "png",
334
+ ) -> bytes:
335
+ if scale not in (2, 4):
336
+ raise ValueError("scale must be 2 or 4")
337
+ return await self._request_bytes(
338
+ "POST",
339
+ "/upscale",
340
+ files=_multipart_files(file),
341
+ data=_form({"scale": scale, "face_enhance": face_enhance, "format": format}),
342
+ )
343
+
344
+ async def face_restore(
345
+ self,
346
+ file: FileInput,
347
+ *,
348
+ only_center_face: bool = False,
349
+ format: str = "png",
350
+ ) -> bytes:
351
+ return await self._request_bytes(
352
+ "POST",
353
+ "/face-restore",
354
+ files=_multipart_files(file),
355
+ data=_form({"only_center_face": only_center_face, "format": format}),
356
+ )
@@ -352,3 +352,45 @@ class Knockout:
352
352
  "/estimate",
353
353
  json={"endpoint": endpoint, "width": width, "height": height},
354
354
  )
355
+
356
+ def upscale(
357
+ self,
358
+ file: FileInput,
359
+ *,
360
+ scale: int = 4,
361
+ face_enhance: bool = False,
362
+ format: str = "png",
363
+ ) -> bytes:
364
+ """POST /upscale — Real-ESRGAN x2/x4 super-resolution.
365
+
366
+ ``face_enhance=True`` routes through GFPGAN for sharper facial detail
367
+ (slower; use for portraits).
368
+ """
369
+ if scale not in (2, 4):
370
+ raise ValueError("scale must be 2 or 4")
371
+ return self._request_bytes(
372
+ "POST",
373
+ "/upscale",
374
+ files=_multipart_files(file),
375
+ data=_form({"scale": scale, "face_enhance": face_enhance, "format": format}),
376
+ )
377
+
378
+ def face_restore(
379
+ self,
380
+ file: FileInput,
381
+ *,
382
+ only_center_face: bool = False,
383
+ format: str = "png",
384
+ ) -> bytes:
385
+ """POST /face-restore — GFPGAN v1.4 portrait restoration.
386
+
387
+ Fixes blurry / damaged / low-res faces; background is 2x upscaled by
388
+ Real-ESRGAN. ``only_center_face=True`` restores just the most prominent
389
+ face (faster).
390
+ """
391
+ return self._request_bytes(
392
+ "POST",
393
+ "/face-restore",
394
+ files=_multipart_files(file),
395
+ data=_form({"only_center_face": only_center_face, "format": format}),
396
+ )
@@ -1 +0,0 @@
1
- __version__ = "0.0.1"
File without changes
File without changes
File without changes