GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: v0.0.2 - add upscale() + face_restore() methods (sync + async) · useknockout/python@2c3308a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pyproject.toml
  • src/useknockout
    • _version.py
    • async_client.py
    • client.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pyproject.toml‎

Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "useknockout"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
description = "Python SDK for useknockout — state-of-the-art background removal API."
99
readme = "README.md"
1010
license = { text = "MIT" }
Collapse file

‎src/useknockout/_version.py‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.2"
Collapse file

‎src/useknockout/async_client.py‎

Copy file name to clipboardExpand all lines: src/useknockout/async_client.py
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,34 @@ async def estimate(self, endpoint: str, width: int, height: int) -> Dict[str, An
323323
"/estimate",
324324
json={"endpoint": endpoint, "width": width, "height": height},
325325
)
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+
)
Collapse file

‎src/useknockout/client.py‎

Copy file name to clipboardExpand all lines: src/useknockout/client.py
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,45 @@ def estimate(self, endpoint: str, width: int, height: int) -> Dict[str, Any]:
352352
"/estimate",
353353
json={"endpoint": endpoint, "width": width, "height": height},
354354
)
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+
)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.