Skip to main content

an inference lib for image/video restoration and video frame interpolation with VapourSynth support

Project description

cccv

codecov CI-test Release PyPI version GitHub

an inference lib for image/video restoration and video frame interpolation with VapourSynth support

Install

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

pip install cccv
  • Install VapourSynth (optional)

Start

cv2

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

import cv2
import numpy as np

from cccv import AutoModel, ConfigType, SRBaseModel

model: SRBaseModel = AutoModel.from_pretrained(
    pretrained_model_name=ConfigType.RealESRGAN_AnimeJaNai_HD_V3_Compact_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 VapourSynth to process a video

import vapoursynth as vs
from vapoursynth import core

from cccv import AutoModel, VSRBaseModel, ConfigType

model: VSRBaseModel = 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, cccv can register custom configurations and models to extend the functionality

Current Support

It still in development, the following models are supported:

Notice

  • All the architectures have been edited to normalize input and output, and automatic padding is applied. The input and output tensor shapes may differ from the original architectures. For SR models, the input and output are both 4D tensors in the shape of (b, c, h, w). For VSR models, the input and output are both 5D tensors in the shape of (b, l, c, h, w).

  • For VSR models with equal l in input and output (f1, f2, f3, f4 -> f1', f2', f3', f4'), you can directly extend from class VSRBaseModel. For VSR models that output only one frame (f-2, f-1, f0, f1, f2 -> f0'), you also need to set self.one_frame_out = True.

Reference

License

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cccv-0.0.2-py3-none-any.whl (85.2 kB view details)

Uploaded Python 3

File details

Details for the file cccv-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cccv-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 85.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cccv-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2cbca8db53452e36a8581177acf2339b0b99470752cc5e11c216f2eb5ec9f2e9
MD5 0b4c30d2c96d5e7289a46a83e5ffa7c5
BLAKE2b-256 71932ee9e0aadb4e963b2c424e0f737410cf6ad4afb2f31d4ff723cba28e812a

See more details on using hashes here.

Supported by

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