-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from deepghs/dev/cdc
dev(narugo): add support for cdc upscaler
- Loading branch information
Showing
27 changed files
with
4,155 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
)() |
Oops, something went wrong.