Skip to content

Commit

Permalink
Enhance auto model configuration and improve utility functions
Browse files Browse the repository at this point in the history
- Added 'ultralytics' to the model type mapping in `auto_model.py`.
- Reordered import statements in `__init__.py` for clarity.
- Integrated `click` for improved console output in `utils.py`.
- Enhanced failure messages and provided formatting instructions in `validate_and_exit` function.

These changes improve the organization of model imports and enhance user feedback during script execution.
  • Loading branch information
fcakyon committed Dec 16, 2024
1 parent c1edea1 commit c8c9684
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions sahi/auto_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

ULTRALYTICS_MODEL_NAMES = ["yolov8", "yolov11", "yolo11", "ultralytics"]


class AutoDetectionModel:
@staticmethod
def from_pretrained(
Expand Down
2 changes: 1 addition & 1 deletion sahi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import base, detectron2, huggingface, mmdet, torchvision, yolov5, yolov8onnx, ultralytics
from . import base, detectron2, huggingface, mmdet, torchvision, ultralytics, yolov5, yolov8onnx
10 changes: 9 additions & 1 deletion scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import shutil
import sys

import click


def shell(command, exit_status=0):
"""
Expand Down Expand Up @@ -30,9 +32,15 @@ def validate_and_exit(expected_out_status=0, **kwargs):
fail_count = 0
for component, exit_status in kwargs.items():
if exit_status != expected_out_status:
print(f"{component} failed.")
click.secho(f"{component} failed.", fg="red")
fail_count += 1

print_console_centered(f"{len(kwargs)-fail_count} success, {fail_count} failure")
click.secho("\nTo fix formatting issues:", fg="yellow")
click.secho("1. Install development dependencies:", fg="cyan")
click.secho(' pip install -e ."[dev]"', fg="green")
click.secho("\n2. Run code formatting:", fg="cyan")
click.secho(" python -m scripts.run_code_style format", fg="green")
sys.exit(1)


Expand Down

0 comments on commit c8c9684

Please sign in to comment.