Skip to main content

end-to-end super resolution toolkit

Project description

ddddsr

A python library for end-to-end image super-resolution.

Install

pip install ddddsr

Features

  • End-to-end super resolution in one package (currently support waifu2x models).

  • (experimental) OCR for better text super resolution quality.

Usage

import ddddsr

# read input.jpg and write to output.png
# default is 2x upscaling on CPU using waifu2x cunet.
ddddsr.SR()('input.jpg', 'output.png')

API reference:

sr = ddddsr.SR( 
    # models: currently supports ['waifu2x_art', 'waifu2x_photo']
    model: str = 'waifu2x_art', 
    # scale
    scale: Optional[float] = None, 
    # output size (omitted if scale is set, if both scale and size are None, use scale = 2)
    size: Optional[Union[int, List[int], Tuple[int]]] = None, 
    # denoise level: range in [-1, 3], -1 means no denoising.
    denoise_level: int =  2, 
    # whether to use gpu
    use_gpu: bool = False, 
    # if use gpu, set the device id
    device_id: int = 0,
    # (experimental) use OCR for better text quality
    ocr_text: bool = False,
    # (experimental) OCR related configurations
    ocr_font_size: int = 28,
    ocr_font_color: Union[Tuple[int], List[int]] = (0, 0, 0),
    ocr_background_color: Union[Tuple[int], List[int]] = (255, 255, 255),
    ocr_font_ttf: Optional[str] = None, # path for ttf font file
    # verbose 
    verbose: bool = False,
)

sr(
    # image, support array of [H, W, 3] or [H, W, 4], or the file path.
    image: Union[np.ndarray, str],
    # output_path, output file path, if is None, will return the ndarray.
    output_path: str = None,
    # slide window size, -1 means no slide window.
    window: int = 256,
)

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ddddsr-0.1.6.tar.gz (40.8 MB view details)

Uploaded Source

File details

Details for the file ddddsr-0.1.6.tar.gz.

File metadata

  • Download URL: ddddsr-0.1.6.tar.gz
  • Upload date:
  • Size: 40.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4

File hashes

Hashes for ddddsr-0.1.6.tar.gz
Algorithm Hash digest
SHA256 43e686b1368e9ddcefcecafb4905519ea0d0ec7bcc748677b556e6a96c76d3c4
MD5 1a4bf85e106f353a8142b831c8321e1c
BLAKE2b-256 0dad856f87fac7f7c96fdab639b62f37e5409af7ff4c2421ed9e26af5b9c6185

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page