Skip to content

Commit

Permalink
dev(narugo): add many diff benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Jan 15, 2025
1 parent 1fc3912 commit 3caa469
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 0 deletions.
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/rtdetr_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('rtdetr')
],
title='Benchmark for RT-DETR Models',
run_times=10,
try_times=20,
)()
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/yolo11_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('yolo11')
],
title='Benchmark for YOLO11 Models',
run_times=10,
try_times=20,
)()
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/yolov10_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('yolov10')
],
title='Benchmark for YOLOv10 Models',
run_times=10,
try_times=20,
)()
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/yolov5_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('yolov5')
],
title='Benchmark for YOLOv5 Models',
run_times=10,
try_times=20,
)()
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/yolov8_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('yolov8')
],
title='Benchmark for YOLOv8 Models',
run_times=10,
try_times=20,
)()
39 changes: 39 additions & 0 deletions docs/source/api_doc/detect/yolov9_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random

from imgutils.generic.yolo import _open_models_for_repo_id

from benchmark import BaseBenchmark, create_plot_cli
from realutils.detect.yolo import detect_by_yolo, _REPO_ID

_MODELS = _open_models_for_repo_id(_REPO_ID).model_names


class YOLOBenchmark(BaseBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_ = _open_models_for_repo_id(_REPO_ID)._open_model(self.model_name)

def unload(self):
from imgutils.generic.yolo import _open_models_for_repo_id
_open_models_for_repo_id.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = detect_by_yolo(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
(model_name, YOLOBenchmark(model_name))
for model_name in _MODELS
if model_name.startswith('yolov9')
],
title='Benchmark for YOLOv9 Models',
run_times=10,
try_times=20,
)()

0 comments on commit 3caa469

Please sign in to comment.