ccrestoration


Nameccrestoration JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/TensoRaws/ccrestoration
Summaryan inference lib for image/video restoration with VapourSynth support
upload_time2024-12-12 18:11:51
maintainerNone
docs_urlNone
authorTohrusky
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ccrestoration

[![codecov](https://codecov.io/gh/TensoRaws/ccrestoration/graph/badge.svg?token=VK0BHDUXAI)](https://codecov.io/gh/TensoRaws/ccrestoration)
[![CI-test](https://github.com/TensoRaws/ccrestoration/actions/workflows/CI-test.yml/badge.svg)](https://github.com/TensoRaws/ccrestoration/actions/workflows/CI-test.yml)
[![Release-pypi](https://github.com/TensoRaws/ccrestoration/actions/workflows/Release.yml/badge.svg)](https://github.com/TensoRaws/ccrestoration/actions/workflows/Release.yml)
[![PyPI version](https://badge.fury.io/py/ccrestoration.svg)](https://badge.fury.io/py/ccrestoration)
![GitHub](https://img.shields.io/github/license/TensoRaws/ccrestoration)

an inference lib for image/video restoration with VapourSynth support, compatible with [many community models](https://openmodeldb.info/)

### Install

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

```bash
pip install ccrestoration
```

- Install VapourSynth (optional)

### Start

#### cv2

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

```python
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)

```python
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](./example) directory, ccrestoration can register custom configurations and models to extend the functionality

### Current Support

It still in development, the following models are supported:

- [Architecture](./ccrestoration/type/arch.py)

- [Model](./ccrestoration/type/model.py)

- [Weight(Config)](./ccrestoration/type/config.py)

### 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

- [PyTorch](https://github.com/pytorch/pytorch)
- [BasicSR](https://github.com/XPixelGroup/BasicSR)
- [mmcv](https://github.com/open-mmlab/mmcv)
- [huggingface transformers](https://github.com/huggingface/transformers)
- [VapourSynth](https://www.vapoursynth.com/)
- [HolyWu's functions](https://github.com/HolyWu)

### License

This project is licensed under the MIT - see
the [LICENSE file](https://github.com/TensoRaws/ccrestoration/blob/main/LICENSE) for details.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TensoRaws/ccrestoration",
    "name": "ccrestoration",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Tohrusky",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# ccrestoration\n\n[![codecov](https://codecov.io/gh/TensoRaws/ccrestoration/graph/badge.svg?token=VK0BHDUXAI)](https://codecov.io/gh/TensoRaws/ccrestoration)\n[![CI-test](https://github.com/TensoRaws/ccrestoration/actions/workflows/CI-test.yml/badge.svg)](https://github.com/TensoRaws/ccrestoration/actions/workflows/CI-test.yml)\n[![Release-pypi](https://github.com/TensoRaws/ccrestoration/actions/workflows/Release.yml/badge.svg)](https://github.com/TensoRaws/ccrestoration/actions/workflows/Release.yml)\n[![PyPI version](https://badge.fury.io/py/ccrestoration.svg)](https://badge.fury.io/py/ccrestoration)\n![GitHub](https://img.shields.io/github/license/TensoRaws/ccrestoration)\n\nan inference lib for image/video restoration with VapourSynth support, compatible with [many community models](https://openmodeldb.info/)\n\n### Install\n\nMake sure you have Python >= 3.9 and PyTorch >= 1.13 installed\n\n```bash\npip install ccrestoration\n```\n\n- Install VapourSynth (optional)\n\n### Start\n\n#### cv2\n\na simple example to use the SISR (Single Image Super-Resolution) model to process an image (APISR)\n\n```python\nimport cv2\nimport numpy as np\n\nfrom ccrestoration import AutoModel, ConfigType, SRBaseModel\n\nmodel: SRBaseModel = AutoModel.from_pretrained(\n    pretrained_model_name=ConfigType.RealESRGAN_APISR_RRDB_GAN_generator_2x,\n)\n\nimg = cv2.imdecode(np.fromfile(\"test.jpg\", dtype=np.uint8), cv2.IMREAD_COLOR)\nimg = model.inference_image(img)\ncv2.imwrite(\"test_out.jpg\", img)\n```\n\n#### VapourSynth\n\na simple example to use the VSR (Video Super-Resolution) model to process a video (AnimeSR)\n\n```python\nimport vapoursynth as vs\nfrom vapoursynth import core\n\nfrom ccrestoration import AutoModel, BaseModelInterface, ConfigType\n\nmodel: BaseModelInterface = AutoModel.from_pretrained(\n    pretrained_model_name=ConfigType.RealESRGAN_AnimeJaNai_HD_V3_Compact_2x,\n    tile=None\n)\n\nclip = core.bs.VideoSource(source=\"s.mp4\")\nclip = core.resize.Bicubic(clip=clip, matrix_in_s=\"709\", format=vs.RGBH)\nclip = model.inference_video(clip)\nclip = core.resize.Bicubic(clip=clip, matrix_s=\"709\", format=vs.YUV420P16)\nclip.set_output()\n```\n\nSee more examples in the [example](./example) directory, ccrestoration can register custom configurations and models to extend the functionality\n\n### Current Support\n\nIt still in development, the following models are supported:\n\n- [Architecture](./ccrestoration/type/arch.py)\n\n- [Model](./ccrestoration/type/model.py)\n\n- [Weight(Config)](./ccrestoration/type/config.py)\n\n### Notice\n\n- 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)`.\n\n- 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`.\n\n### Reference\n\n- [PyTorch](https://github.com/pytorch/pytorch)\n- [BasicSR](https://github.com/XPixelGroup/BasicSR)\n- [mmcv](https://github.com/open-mmlab/mmcv)\n- [huggingface transformers](https://github.com/huggingface/transformers)\n- [VapourSynth](https://www.vapoursynth.com/)\n- [HolyWu's functions](https://github.com/HolyWu)\n\n### License\n\nThis project is licensed under the MIT - see\nthe [LICENSE file](https://github.com/TensoRaws/ccrestoration/blob/main/LICENSE) for details.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "an inference lib for image/video restoration with VapourSynth support",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/TensoRaws/ccrestoration",
        "Repository": "https://github.com/TensoRaws/ccrestoration"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77ae103cf92d2f4bc17b89adeb4fce1249014f30a948b6de23b42ea125ef646f",
                "md5": "311a5b22c3a28e8ba0d25d7007279f6e",
                "sha256": "c698d2bd1cec686ee96205bd7726e1011ad59416bda57c52ca1a0e22004c890b"
            },
            "downloads": -1,
            "filename": "ccrestoration-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "311a5b22c3a28e8ba0d25d7007279f6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 97876,
            "upload_time": "2024-12-12T18:11:51",
            "upload_time_iso_8601": "2024-12-12T18:11:51.800618Z",
            "url": "https://files.pythonhosted.org/packages/77/ae/103cf92d2f4bc17b89adeb4fce1249014f30a948b6de23b42ea125ef646f/ccrestoration-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 18:11:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TensoRaws",
    "github_project": "ccrestoration",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ccrestoration"
}
        
Elapsed time: 0.41384s