Home

Awesome

ccrestoration

codecov CI-test Release-pypi PyPI version GitHub

an inference lib for image/video restoration with VapourSynth support, compatible with many community models

Install

Make sure you have Python >= 3.9 and PyTorch >= 1.13 installed

pip install ccrestoration

Start

cv2

a simple example to use the SISR (Single Image Super-Resolution) model to process an image (APISR)

import cv2
import numpy as np

from ccrestoration import AutoModel, ConfigType, SRBaseModel

model: SRBaseModel = AutoModel.from_pretrained(
    pretrained_model_name=ConfigType.RealESRGAN_APISR_RRDB_GAN_generator_2x,
)

img = cv2.imdecode(np.fromfile("test.jpg", dtype=np.uint8), cv2.IMREAD_COLOR)
img = model.inference_image(img)
cv2.imwrite("test_out.jpg", img)

VapourSynth

a simple example to use the VSR (Video Super-Resolution) model to process a video (AnimeSR)

import vapoursynth as vs
from vapoursynth import core

from ccrestoration import AutoModel, BaseModelInterface, ConfigType

model: BaseModelInterface = AutoModel.from_pretrained(
    pretrained_model_name=ConfigType.RealESRGAN_AnimeJaNai_HD_V3_Compact_2x,
    tile=None
)

clip = core.bs.VideoSource(source="s.mp4")
clip = core.resize.Bicubic(clip=clip, matrix_in_s="709", format=vs.RGBH)
clip = model.inference_video(clip)
clip = core.resize.Bicubic(clip=clip, matrix_s="709", format=vs.YUV420P16)
clip.set_output()

See more examples in the example directory, ccrestoration can register custom configurations and models to extend the functionality

Current Support

It still in development, the following models are supported:

Notice

Reference

License

This project is licensed under the MIT - see the LICENSE file for details.