Skip to content

Commit

Permalink
Merge pull request #88 from deepghs/dev/cdc
Browse files Browse the repository at this point in the history
dev(narugo): add support for cdc upscaler
  • Loading branch information
narugo1992 authored May 10, 2024
2 parents 5de99ab + 09a2b03 commit f72c4f4
Show file tree
Hide file tree
Showing 27 changed files with 4,155 additions and 8 deletions.
15 changes: 15 additions & 0 deletions docs/source/api_doc/upscale/cdc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
imgutils.upscale.cdc
====================================

.. currentmodule:: imgutils.upscale.cdc

.. automodule:: imgutils.upscale.cdc


upscale_with_cdc
---------------------------

.. autofunction:: upscale_with_cdc



44 changes: 44 additions & 0 deletions docs/source/api_doc/upscale/cdc_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os.path
import random

from huggingface_hub import HfFileSystem

from benchmark import BaseBenchmark, create_plot_cli
from imgutils.upscale.cdc import upscale_with_cdc

hf_fs = HfFileSystem()
repository = 'deepghs/cdc_anime_onnx'
_CDC_MODELS = [
os.path.splitext(os.path.relpath(file, repository))[0]
for file in hf_fs.glob(f'{repository}/*.onnx')
]


class CDCUpscalerBenchmark(BaseBenchmark):
def __init__(self, model: str):
BaseBenchmark.__init__(self)
self.model = model

def load(self):
from imgutils.upscale.cdc import _open_cdc_upscaler_model
_open_cdc_upscaler_model(self.model)

def unload(self):
from imgutils.upscale.cdc import _open_cdc_upscaler_model
_open_cdc_upscaler_model.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = upscale_with_cdc(image_file, model=self.model)


if __name__ == '__main__':
create_plot_cli(
[
(model, CDCUpscalerBenchmark(model))
for model in _CDC_MODELS
],
title='Benchmark for CDCUpscaler Models',
run_times=3,
try_times=3,
)()
Loading

0 comments on commit f72c4f4

Please sign in to comment.