Loading docs/source/api_doc/validate/monochrome.benchmark.py 0 → 100644 +36 −0 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot_cli from imgutils.validate import get_monochrome_score from imgutils.validate.monochrome import _MODELS class MonochromeBenchmark(BaseBenchmark): def __init__(self, safe=0): BaseBenchmark.__init__(self) self.safe = safe def load(self): from imgutils.validate.monochrome import _monochrome_validate_model _ = _monochrome_validate_model(_MODELS[self.safe]) def unload(self): from imgutils.validate.monochrome import _monochrome_validate_model _monochrome_validate_model.cache_clear() def run(self): image_file = random.choice(self.all_images) _ = get_monochrome_score(image_file, safe=self.safe) if __name__ == '__main__': create_plot_cli( [ ('monochrome', MonochromeBenchmark()), ('monochrome (safe 2)', MonochromeBenchmark(2)), ('monochrome (safe 4)', MonochromeBenchmark(4)), ], title='Benchmark for Monochrome Check Models', run_times=10, try_times=20, )() docs/source/api_doc/validate/monochrome.benchmark.py.svg 0 → 100644 +2315 −0 File added.Preview size limit exceeded, changes collapsed. Show changes imgutils/validate/monochrome.py +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,11 @@ Overview: .. image:: monochrome.dat.svg :align: center This is an overall benchmark of all the monochrome validation models: .. image:: monochrome.benchmark.py.svg :align: center """ from functools import lru_cache from typing import Optional, Tuple, Mapping Loading Loading
docs/source/api_doc/validate/monochrome.benchmark.py 0 → 100644 +36 −0 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot_cli from imgutils.validate import get_monochrome_score from imgutils.validate.monochrome import _MODELS class MonochromeBenchmark(BaseBenchmark): def __init__(self, safe=0): BaseBenchmark.__init__(self) self.safe = safe def load(self): from imgutils.validate.monochrome import _monochrome_validate_model _ = _monochrome_validate_model(_MODELS[self.safe]) def unload(self): from imgutils.validate.monochrome import _monochrome_validate_model _monochrome_validate_model.cache_clear() def run(self): image_file = random.choice(self.all_images) _ = get_monochrome_score(image_file, safe=self.safe) if __name__ == '__main__': create_plot_cli( [ ('monochrome', MonochromeBenchmark()), ('monochrome (safe 2)', MonochromeBenchmark(2)), ('monochrome (safe 4)', MonochromeBenchmark(4)), ], title='Benchmark for Monochrome Check Models', run_times=10, try_times=20, )()
docs/source/api_doc/validate/monochrome.benchmark.py.svg 0 → 100644 +2315 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
imgutils/validate/monochrome.py +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,11 @@ Overview: .. image:: monochrome.dat.svg :align: center This is an overall benchmark of all the monochrome validation models: .. image:: monochrome.benchmark.py.svg :align: center """ from functools import lru_cache from typing import Optional, Tuple, Mapping Loading