ultralytics 8.0.191 fix yolo checks for missing packages (#5179)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Muhammad Rizwan Munawar <62513924+RizwanMunawar@users.noreply.github.com>
This commit is contained in:
parent
9aaa5d5ed0
commit
525c8b0294
17 changed files with 110 additions and 74 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = '8.0.190'
|
||||
__version__ = '8.0.191'
|
||||
|
||||
from ultralytics.models import RTDETR, SAM, YOLO
|
||||
from ultralytics.models.fastsam import FastSAM
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from pathlib import Path
|
|||
from types import SimpleNamespace
|
||||
from typing import Dict, List, Union
|
||||
|
||||
from ultralytics.utils import (ASSETS, DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_PATH, LOGGER, RANK, SETTINGS,
|
||||
SETTINGS_YAML, IterableSimpleNamespace, __version__, checks, colorstr, deprecation_warn,
|
||||
yaml_load, yaml_print)
|
||||
from ultralytics.utils import (ASSETS, DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_PATH, LOGGER, RANK, ROOT, SETTINGS,
|
||||
SETTINGS_YAML, TESTS_RUNNING, IterableSimpleNamespace, __version__, checks, colorstr,
|
||||
deprecation_warn, yaml_load, yaml_print)
|
||||
|
||||
# Define valid tasks and modes
|
||||
MODES = 'train', 'val', 'predict', 'export', 'track', 'benchmark'
|
||||
|
|
@ -153,7 +153,8 @@ def get_save_dir(args, name=None):
|
|||
else:
|
||||
from ultralytics.utils.files import increment_path
|
||||
|
||||
project = args.project or Path(SETTINGS['runs_dir']) / args.task
|
||||
project = args.project or (ROOT /
|
||||
'../tests/tmp/runs' if TESTS_RUNNING else Path(SETTINGS['runs_dir'])) / args.task
|
||||
name = name or args.name or f'{args.mode}'
|
||||
save_dir = increment_path(Path(project) / name, exist_ok=args.exist_ok if RANK in (-1, 0) else True)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,16 @@ def coco80_to_coco91_class(): #
|
|||
64, 65, 67, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90]
|
||||
|
||||
|
||||
def convert_coco(labels_dir='../coco/annotations/', use_segments=False, use_keypoints=False, cls91to80=True):
|
||||
def convert_coco(labels_dir='../coco/annotations/',
|
||||
save_dir='.',
|
||||
use_segments=False,
|
||||
use_keypoints=False,
|
||||
cls91to80=True):
|
||||
"""Converts COCO dataset annotations to a format suitable for training YOLOv5 models.
|
||||
|
||||
Args:
|
||||
labels_dir (str, optional): Path to directory containing COCO dataset annotation files.
|
||||
save_dir (str, optional): Path to directory to save results to.
|
||||
use_segments (bool, optional): Whether to include segmentation masks in the output.
|
||||
use_keypoints (bool, optional): Whether to include keypoint annotations in the output.
|
||||
cls91to80 (bool, optional): Whether to map 91 COCO class IDs to the corresponding 80 COCO class IDs.
|
||||
|
|
@ -67,7 +72,7 @@ def convert_coco(labels_dir='../coco/annotations/', use_segments=False, use_keyp
|
|||
"""
|
||||
|
||||
# Create dataset directory
|
||||
save_dir = Path('yolo_labels')
|
||||
save_dir = Path(save_dir)
|
||||
if save_dir.exists():
|
||||
shutil.rmtree(save_dir) # delete dir
|
||||
for p in save_dir / 'labels', save_dir / 'images':
|
||||
|
|
|
|||
|
|
@ -148,11 +148,12 @@ sam_model_map = {
|
|||
def build_sam(ckpt='sam_b.pt'):
|
||||
"""Build a SAM model specified by ckpt."""
|
||||
model_builder = None
|
||||
ckpt = str(ckpt) # to allow Path ckpt types
|
||||
for k in sam_model_map.keys():
|
||||
if ckpt.endswith(k):
|
||||
model_builder = sam_model_map.get(k)
|
||||
|
||||
if not model_builder:
|
||||
raise FileNotFoundError(f'{ckpt} is not a supported sam model. Available models are: \n {sam_model_map.keys()}')
|
||||
raise FileNotFoundError(f'{ckpt} is not a supported SAM model. Available models are: \n {sam_model_map.keys()}')
|
||||
|
||||
return model_builder(ckpt)
|
||||
|
|
|
|||
|
|
@ -917,6 +917,7 @@ def url2file(url):
|
|||
PREFIX = colorstr('Ultralytics: ')
|
||||
SETTINGS = SettingsManager() # initialize settings
|
||||
DATASETS_DIR = Path(SETTINGS['datasets_dir']) # global datasets directory
|
||||
WEIGHTS_DIR = Path(SETTINGS['weights_dir'])
|
||||
ENVIRONMENT = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter' if is_jupyter() else \
|
||||
'Docker' if is_docker() else platform.system()
|
||||
TESTS_RUNNING = is_pytest_running() or is_github_actions_ci()
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ import torch.cuda
|
|||
from ultralytics import YOLO
|
||||
from ultralytics.cfg import TASK2DATA, TASK2METRIC
|
||||
from ultralytics.engine.exporter import export_formats
|
||||
from ultralytics.utils import ASSETS, LINUX, LOGGER, MACOS, SETTINGS, TQDM
|
||||
from ultralytics.utils import ASSETS, LINUX, LOGGER, MACOS, TQDM, WEIGHTS_DIR
|
||||
from ultralytics.utils.checks import check_requirements, check_yolo
|
||||
from ultralytics.utils.files import file_size
|
||||
from ultralytics.utils.torch_utils import select_device
|
||||
|
||||
|
||||
def benchmark(model=Path(SETTINGS['weights_dir']) / 'yolov8n.pt',
|
||||
def benchmark(model=WEIGHTS_DIR / 'yolov8n.pt',
|
||||
data=None,
|
||||
imgsz=160,
|
||||
half=False,
|
||||
|
|
|
|||
|
|
@ -516,8 +516,12 @@ def collect_system_info():
|
|||
f"{'CUDA':<20}{torch.version.cuda if torch and torch.cuda.is_available() else None}\n")
|
||||
|
||||
for r in parse_requirements(package='ultralytics'):
|
||||
current = metadata.version(r.name)
|
||||
is_met = '✅ ' if check_version(current, str(r.specifier)) else '❌ '
|
||||
try:
|
||||
current = metadata.version(r.name)
|
||||
is_met = '✅ ' if check_version(current, str(r.specifier), hard=True) else '❌ '
|
||||
except metadata.PackageNotFoundError:
|
||||
current = '(not installed)'
|
||||
is_met = '❌ '
|
||||
LOGGER.info(f'{r.name:<20}{is_met}{current}{r.specifier}')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue