Skip to main content

Single-line inference of SOTA deep learning models

Project description

tests Documentation Status

Single-Line Deep Learning

Most of the practicle tasks that require the usage of deep learning models can be simplified to "just do the thing", e.g., "just upscale the image". On the other hand, official repositories of the state-of-the-art methods are dedicated to provide a way to reproduce experiments presented in the paper. These two different tasks require different code structure, so I made this library that provides an ultimative single-line solution for practical tasks solved by the SOTA methods. For instance, to "just upscale the image" you can just run the following code:

from PIL import Image
from sldl.image import ImageSR

sr = ImageSR('BSRGAN')

img = Image.open('test.png')
upscaled = sr(img)

Installation

The project is available on PyPI, just run

pip install sldl

Overview

SLDL is written in PyTorch and tries not to change the original author's implementation and, at the same time, provide the fastest inference and the most convinient interface. Note that SLDL doesn't provide any interface to train or fine-tune the models.

Each method is a torch.nn.Module that has a __call__ method that solves your task. The library tries to provide the most practical interface, so it operates with Pillow images and video files in order to use the upscaler in your program and to just upscale your video.

Currently two types of tasks are supported.

Images

  • Denoising: SwinIR
  • Super-resolution: BSRGAN, RealESRGAN, SwinIR

Videos

  • Denoising: SwinIR
  • Super-resolution: BSRGAN, RealESRGAN, SwinIR, VRT
  • Interpolation: IFRNet

Usage

For images, run this

from PIL import Image
from sldl.image import ImageSR

img = Image.open('test.png')
sr = ImageSR('BSRGAN')  # or 'SwinIR-M', 'SwinIR-L', 'BSRGANx2'
# sr = sr.cuda() if you have a GPU

upscaled = sr(img)

For videos, run this

from sldl.video import VideoSR

sr = VideoSR('BSRGAN')
sr('your_video.mp4', 'upscaled_video.mp4')

Plans

  • Add image deblurring, face generation, machine translation, etc
  • Make inference optimizations like torch.compile and TensorRT
  • CLI tool and Docker image
  • Ready-to-go REST API deployment

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

sldl-0.0.3.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

sldl-0.0.3-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file sldl-0.0.3.tar.gz.

File metadata

  • Download URL: sldl-0.0.3.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for sldl-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e46baca134f10ae232047d8a6903f8f1fe33d1ed9edc1b1b51159f7b60451f1b
MD5 bdef862daa696f9eed149e1cc7e45b3f
BLAKE2b-256 6592458bb2f0fb128adc7bb4e1ab6d13a7a5f3c11e11ed3ee32e4554f535713a

See more details on using hashes here.

File details

Details for the file sldl-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sldl-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for sldl-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cdab7ffc5f2a6fe89b2f7b46d578d9e372a6a387b9a61fc38bd2af015dbe44ed
MD5 e897e3bdd010eec01429aceb25031434
BLAKE2b-256 030e6b363e08a3b817e5b5fec851591fab70dbc6f03ce49f663fe1339c338f35

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