Loading .gitignore +1 −1 Original line number Diff line number Diff line Loading @@ -1205,7 +1205,7 @@ fabric.properties /docs/source/**/*.sh.err /docs/source/**/*.sh.exitcode /docs/source/**/*.dat.* !/docs/source/**/benchmark_*.dat.* !/docs/source/**/*.benchmark.py.* !/docs/source/_static/**/* /docs/source/**/*.result.ipynb /cartpole_dqn_* Loading docs/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -46,4 +46,4 @@ builddir: @echo $(shell readlink -f ${BUILDDIR}/html) cleanbm: @$(ALL) cleanbm $(ALL) cleanbm docs/source/_libs/benchmark.py +47 −40 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import warnings from multiprocessing import Process from typing import Tuple, List import click import matplotlib.pyplot as plt import numpy as np import psutil Loading Loading @@ -93,7 +94,7 @@ class BaseBenchmark: return final_mems, final_times, final_labels def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, def create_plot_cli(items: List[Tuple[str, BaseBenchmark]], title: str = 'Unnamed Benchmark Plot', run_times=15, try_times=10, mem_ylog: bool = False, time_ylog: bool = False, figsize=(720, 420), dpi: int = 300): Loading @@ -113,6 +114,10 @@ def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, else: return f'{x * 1.0:.1f}s' @click.command() @click.option('--output', '-o', 'save_as', type=click.Path(dir_okay=False), required=True, help='Output path of image file.', show_default=True) def _execute(save_as): fig, axes = plt.subplots(1, 2, figsize=(figsize[0] / INCHES_TO_PIXELS, figsize[1] / INCHES_TO_PIXELS)) if mem_ylog: Loading Loading @@ -149,3 +154,5 @@ def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, fig.tight_layout() plt.savefig(save_as, bbox_inches='tight', dpi=dpi, transparent=True) return _execute docs/source/all.mk +2 −0 Original line number Diff line number Diff line Loading @@ -45,3 +45,5 @@ clean: @$(DEMOS) clean @$(NOTEBOOK) clean cleanbm: @$(DEMOS) cleanbm docs/source/api_doc/detect/benchmark_face_detect.demo.py→docs/source/api_doc/detect/face_detect.benchmark.py +3 −4 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot from benchmark import BaseBenchmark, create_plot_cli from imgutils.detect import detect_faces Loading @@ -23,14 +23,13 @@ class FaceDetectBenchmark(BaseBenchmark): if __name__ == '__main__': create_plot( create_plot_cli( [ ('face (yolov8s)', FaceDetectBenchmark('s')), ('face (yolov8n)', FaceDetectBenchmark('n')), ], save_as='benchmark_face_detect.dat.svg', title='Benchmark for Anime Face Detections', run_times=10, try_times=5, figsize=(1080, 600) ) )() Loading
.gitignore +1 −1 Original line number Diff line number Diff line Loading @@ -1205,7 +1205,7 @@ fabric.properties /docs/source/**/*.sh.err /docs/source/**/*.sh.exitcode /docs/source/**/*.dat.* !/docs/source/**/benchmark_*.dat.* !/docs/source/**/*.benchmark.py.* !/docs/source/_static/**/* /docs/source/**/*.result.ipynb /cartpole_dqn_* Loading
docs/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -46,4 +46,4 @@ builddir: @echo $(shell readlink -f ${BUILDDIR}/html) cleanbm: @$(ALL) cleanbm $(ALL) cleanbm
docs/source/_libs/benchmark.py +47 −40 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import warnings from multiprocessing import Process from typing import Tuple, List import click import matplotlib.pyplot as plt import numpy as np import psutil Loading Loading @@ -93,7 +94,7 @@ class BaseBenchmark: return final_mems, final_times, final_labels def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, def create_plot_cli(items: List[Tuple[str, BaseBenchmark]], title: str = 'Unnamed Benchmark Plot', run_times=15, try_times=10, mem_ylog: bool = False, time_ylog: bool = False, figsize=(720, 420), dpi: int = 300): Loading @@ -113,6 +114,10 @@ def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, else: return f'{x * 1.0:.1f}s' @click.command() @click.option('--output', '-o', 'save_as', type=click.Path(dir_okay=False), required=True, help='Output path of image file.', show_default=True) def _execute(save_as): fig, axes = plt.subplots(1, 2, figsize=(figsize[0] / INCHES_TO_PIXELS, figsize[1] / INCHES_TO_PIXELS)) if mem_ylog: Loading Loading @@ -149,3 +154,5 @@ def create_plot(items: List[Tuple[str, BaseBenchmark]], save_as: str, fig.tight_layout() plt.savefig(save_as, bbox_inches='tight', dpi=dpi, transparent=True) return _execute
docs/source/all.mk +2 −0 Original line number Diff line number Diff line Loading @@ -45,3 +45,5 @@ clean: @$(DEMOS) clean @$(NOTEBOOK) clean cleanbm: @$(DEMOS) cleanbm
docs/source/api_doc/detect/benchmark_face_detect.demo.py→docs/source/api_doc/detect/face_detect.benchmark.py +3 −4 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot from benchmark import BaseBenchmark, create_plot_cli from imgutils.detect import detect_faces Loading @@ -23,14 +23,13 @@ class FaceDetectBenchmark(BaseBenchmark): if __name__ == '__main__': create_plot( create_plot_cli( [ ('face (yolov8s)', FaceDetectBenchmark('s')), ('face (yolov8n)', FaceDetectBenchmark('n')), ], save_as='benchmark_face_detect.dat.svg', title='Benchmark for Anime Face Detections', run_times=10, try_times=5, figsize=(1080, 600) ) )()