Skip to content

Commit

Permalink
dev(narugo): add new benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Oct 12, 2023
1 parent 083a37c commit 38e8253
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/source/api_doc/restore/scunet_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import random

from benchmark import BaseBenchmark, create_plot_cli
from imgutils.restore.scunet import SCUNetModelTyping, restore_with_scunet


class SCUNetBenchmark(BaseBenchmark):
def __init__(self, model: SCUNetModelTyping):
BaseBenchmark.__init__(self)
self.model = model

def load(self):
from imgutils.restore.scunet import _open_scunet_model
_open_scunet_model(self.model)

def unload(self):
from imgutils.restore.scunet import _open_scunet_model
_open_scunet_model.cache_clear()

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


if __name__ == '__main__':
create_plot_cli(
[
('SCUNet-GAN', SCUNetBenchmark('GAN')),
('SCUNet-PSNR', SCUNetBenchmark('PSNR')),
],
title='Benchmark for SCUNet Models',
run_times=5,
try_times=10,
)()
17 changes: 17 additions & 0 deletions imgutils/restore/nafnet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
"""
Overview:
Restore the images using `NafNet <https://github.com/megvii-research/NAFNet>`_.
.. image:: nafnet_demo.plot.py.svg
:align: center
This is an overall benchmark of all the NafNet models:
.. image:: nafnet_benchmark.plot.py.svg
:align: center
.. warning::
Currently, we've identified a significant issue with NafNet when images contain gaussian noise.
To ensure your code functions correctly, please ensure the credibility of
your image source or preprocess them using SCUNet.
"""
from functools import lru_cache
from typing import Literal

Check warning on line 19 in imgutils/restore/nafnet.py

View check run for this annotation

Codecov / codecov/patch

imgutils/restore/nafnet.py#L18-L19

Added lines #L18 - L19 were not covered by tests

Expand Down
13 changes: 13 additions & 0 deletions imgutils/restore/scunet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
"""
Overview:
Restore the images using `SCUNet <https://github.com/cszn/SCUNet>`_.
.. image:: scunet_demo.plot.py.svg
:align: center
This is an overall benchmark of all the SCUNet models:
.. image:: scunet_benchmark.plot.py.svg
:align: center
"""
from functools import lru_cache
from typing import Literal

Check warning on line 15 in imgutils/restore/scunet.py

View check run for this annotation

Codecov / codecov/patch

imgutils/restore/scunet.py#L14-L15

Added lines #L14 - L15 were not covered by tests

Expand Down

0 comments on commit 38e8253

Please sign in to comment.