mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-07-07 22:04:53 +08:00
ultralytics 8.1.3
ResNet models and lighter dependencies (#7700)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Vivek Malvi <vivekmalvi@raoinformationtechnology.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: iscyy <wenvoi@163.com> Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> Co-authored-by: Prince kumar <85225054+prince0310@users.noreply.github.com>
This commit is contained in:
parent
c13315bbf8
commit
fcc4496b12
@ -71,40 +71,40 @@ extra: # version:
|
|||||||
analytics:
|
analytics:
|
||||||
provider: google
|
provider: google
|
||||||
property: G-2M5EHKC0BH
|
property: G-2M5EHKC0BH
|
||||||
# alternate: # language drop-down
|
# alternate: # language drop-down
|
||||||
# - name: 🇬🇧 English
|
# - name: 🇬🇧 English
|
||||||
# link: /
|
# link: /
|
||||||
# lang: en
|
# lang: en
|
||||||
# - name: 🇨🇳 简体中文
|
# - name: 🇨🇳 简体中文
|
||||||
# link: /zh/
|
# link: /zh/
|
||||||
# lang: zh
|
# lang: zh
|
||||||
# - name: 🇰🇷 한국어
|
# - name: 🇰🇷 한국어
|
||||||
# link: /ko/
|
# link: /ko/
|
||||||
# lang: ko
|
# lang: ko
|
||||||
# - name: 🇯🇵 日本語
|
# - name: 🇯🇵 日本語
|
||||||
# link: /ja/
|
# link: /ja/
|
||||||
# lang: ja
|
# lang: ja
|
||||||
# - name: 🇷🇺 Русский
|
# - name: 🇷🇺 Русский
|
||||||
# link: /ru/
|
# link: /ru/
|
||||||
# lang: ru
|
# lang: ru
|
||||||
# - name: 🇩🇪 Deutsch
|
# - name: 🇩🇪 Deutsch
|
||||||
# link: /de/
|
# link: /de/
|
||||||
# lang: de
|
# lang: de
|
||||||
# - name: 🇫🇷 Français
|
# - name: 🇫🇷 Français
|
||||||
# link: /fr/
|
# link: /fr/
|
||||||
# lang: fr
|
# lang: fr
|
||||||
# - name: 🇪🇸 Español
|
# - name: 🇪🇸 Español
|
||||||
# link: /es/
|
# link: /es/
|
||||||
# lang: es
|
# lang: es
|
||||||
# - name: 🇵🇹 Português
|
# - name: 🇵🇹 Português
|
||||||
# link: /pt/
|
# link: /pt/
|
||||||
# lang: pt
|
# lang: pt
|
||||||
# - name: 🇮🇳 हिन्दी
|
# - name: 🇮🇳 हिन्दी
|
||||||
# link: /hi/
|
# link: /hi/
|
||||||
# lang: hi
|
# lang: hi
|
||||||
# - name: 🇸🇦 العربية
|
# - name: 🇸🇦 العربية
|
||||||
# link: /ar/
|
# link: /ar/
|
||||||
# lang: ar
|
# lang: ar
|
||||||
social:
|
social:
|
||||||
- icon: fontawesome/brands/github
|
- icon: fontawesome/brands/github
|
||||||
link: https://github.com/ultralytics
|
link: https://github.com/ultralytics
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
|
||||||
__version__ = "8.1.2"
|
__version__ = "8.1.3"
|
||||||
|
|
||||||
from ultralytics.data.explorer.explorer import Explorer
|
from ultralytics.data.explorer.explorer import Explorer
|
||||||
from ultralytics.models import RTDETR, SAM, YOLO
|
from ultralytics.models import RTDETR, SAM, YOLO
|
||||||
|
25
ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml
Normal file
25
ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
# YOLOv8-cls image classification model. For Usage examples see https://docs.ultralytics.com/tasks/classify
|
||||||
|
|
||||||
|
# Parameters
|
||||||
|
nc: 1000 # number of classes
|
||||||
|
scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n'
|
||||||
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 1024]
|
||||||
|
l: [1.00, 1.00, 1024]
|
||||||
|
x: [1.00, 1.25, 1024]
|
||||||
|
|
||||||
|
# YOLOv8.0n backbone
|
||||||
|
backbone:
|
||||||
|
# [from, repeats, module, args]
|
||||||
|
- [-1, 1, ResNetLayer, [3, 64, 1, True, 1]] # 0-P1/2
|
||||||
|
- [-1, 1, ResNetLayer, [64, 64, 1, False, 3]] # 1-P2/4
|
||||||
|
- [-1, 1, ResNetLayer, [256, 128, 2, False, 4]] # 2-P3/8
|
||||||
|
- [-1, 1, ResNetLayer, [512, 256, 2, False, 23]] # 3-P4/16
|
||||||
|
- [-1, 1, ResNetLayer, [1024, 512, 2, False, 3]] # 4-P5/32
|
||||||
|
|
||||||
|
# YOLOv8.0n head
|
||||||
|
head:
|
||||||
|
- [-1, 1, Classify, [nc]] # Classify
|
25
ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml
Normal file
25
ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
# YOLOv8-cls image classification model. For Usage examples see https://docs.ultralytics.com/tasks/classify
|
||||||
|
|
||||||
|
# Parameters
|
||||||
|
nc: 1000 # number of classes
|
||||||
|
scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n'
|
||||||
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 1024]
|
||||||
|
l: [1.00, 1.00, 1024]
|
||||||
|
x: [1.00, 1.25, 1024]
|
||||||
|
|
||||||
|
# YOLOv8.0n backbone
|
||||||
|
backbone:
|
||||||
|
# [from, repeats, module, args]
|
||||||
|
- [-1, 1, ResNetLayer, [3, 64, 1, True, 1]] # 0-P1/2
|
||||||
|
- [-1, 1, ResNetLayer, [64, 64, 1, False, 3]] # 1-P2/4
|
||||||
|
- [-1, 1, ResNetLayer, [256, 128, 2, False, 4]] # 2-P3/8
|
||||||
|
- [-1, 1, ResNetLayer, [512, 256, 2, False, 6]] # 3-P4/16
|
||||||
|
- [-1, 1, ResNetLayer, [1024, 512, 2, False, 3]] # 4-P5/32
|
||||||
|
|
||||||
|
# YOLOv8.0n head
|
||||||
|
head:
|
||||||
|
- [-1, 1, Classify, [nc]] # Classify
|
@ -52,13 +52,14 @@ class Model(nn.Module):
|
|||||||
list(ultralytics.engine.results.Results): The prediction results.
|
list(ultralytics.engine.results.Results): The prediction results.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, model: Union[str, Path] = "yolov8n.pt", task=None) -> None:
|
def __init__(self, model: Union[str, Path] = "yolov8n.pt", task=None, verbose=False) -> None:
|
||||||
"""
|
"""
|
||||||
Initializes the YOLO model.
|
Initializes the YOLO model.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
model (Union[str, Path], optional): Path or name of the model to load or create. Defaults to 'yolov8n.pt'.
|
model (Union[str, Path], optional): Path or name of the model to load or create. Defaults to 'yolov8n.pt'.
|
||||||
task (Any, optional): Task type for the YOLO model. Defaults to None.
|
task (Any, optional): Task type for the YOLO model. Defaults to None.
|
||||||
|
verbose (bool, optional): Whether to enable verbose mode.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.callbacks = callbacks.get_default_callbacks()
|
self.callbacks = callbacks.get_default_callbacks()
|
||||||
@ -77,6 +78,7 @@ class Model(nn.Module):
|
|||||||
# Check if Ultralytics HUB model from https://hub.ultralytics.com
|
# Check if Ultralytics HUB model from https://hub.ultralytics.com
|
||||||
if self.is_hub_model(model):
|
if self.is_hub_model(model):
|
||||||
# Fetch model from HUB
|
# Fetch model from HUB
|
||||||
|
checks.check_requirements("hub-sdk>0.0.2")
|
||||||
self.session = self._get_hub_session(model)
|
self.session = self._get_hub_session(model)
|
||||||
model = self.session.model_file
|
model = self.session.model_file
|
||||||
|
|
||||||
@ -89,9 +91,9 @@ class Model(nn.Module):
|
|||||||
# Load or create new YOLO model
|
# Load or create new YOLO model
|
||||||
model = checks.check_model_file_from_stem(model) # add suffix, i.e. yolov8n -> yolov8n.pt
|
model = checks.check_model_file_from_stem(model) # add suffix, i.e. yolov8n -> yolov8n.pt
|
||||||
if Path(model).suffix in (".yaml", ".yml"):
|
if Path(model).suffix in (".yaml", ".yml"):
|
||||||
self._new(model, task)
|
self._new(model, task=task, verbose=verbose)
|
||||||
else:
|
else:
|
||||||
self._load(model, task)
|
self._load(model, task=task)
|
||||||
|
|
||||||
self.model_name = model
|
self.model_name = model
|
||||||
|
|
||||||
@ -126,7 +128,7 @@ class Model(nn.Module):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _new(self, cfg: str, task=None, model=None, verbose=True):
|
def _new(self, cfg: str, task=None, model=None, verbose=False):
|
||||||
"""
|
"""
|
||||||
Initializes a new model and infers the task type from the model definitions.
|
Initializes a new model and infers the task type from the model definitions.
|
||||||
|
|
||||||
@ -381,8 +383,8 @@ class Model(nn.Module):
|
|||||||
# Check model was created
|
# Check model was created
|
||||||
if not getattr(self.session.model, "id", None):
|
if not getattr(self.session.model, "id", None):
|
||||||
self.session = None
|
self.session = None
|
||||||
except PermissionError:
|
except (PermissionError, ModuleNotFoundError):
|
||||||
# Ignore permission error
|
# Ignore PermissionError and ModuleNotFoundError which indicates hub-sdk not installed
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.trainer.hub_session = self.session # attach optional HUB session
|
self.trainer.hub_session = self.session # attach optional HUB session
|
||||||
|
@ -42,8 +42,8 @@ class HUBTrainingSession:
|
|||||||
Raises:
|
Raises:
|
||||||
ValueError: If the provided model identifier is invalid.
|
ValueError: If the provided model identifier is invalid.
|
||||||
ConnectionError: If connecting with global API key is not supported.
|
ConnectionError: If connecting with global API key is not supported.
|
||||||
|
ModuleNotFoundError: If hub-sdk package is not installed.
|
||||||
"""
|
"""
|
||||||
checks.check_requirements("hub-sdk>=0.0.2")
|
|
||||||
from hub_sdk import HUBClient
|
from hub_sdk import HUBClient
|
||||||
|
|
||||||
self.rate_limits = {
|
self.rate_limits = {
|
||||||
|
@ -256,7 +256,7 @@ class Annotator:
|
|||||||
# Convert to numpy first
|
# Convert to numpy first
|
||||||
self.im = np.asarray(self.im).copy()
|
self.im = np.asarray(self.im).copy()
|
||||||
nkpt, ndim = kpts.shape
|
nkpt, ndim = kpts.shape
|
||||||
is_pose = nkpt == 17 and ndim == 3
|
is_pose = nkpt == 17 and ndim in {2, 3}
|
||||||
kpt_line &= is_pose # `kpt_line=True` for now only supports human pose plotting
|
kpt_line &= is_pose # `kpt_line=True` for now only supports human pose plotting
|
||||||
for i, k in enumerate(kpts):
|
for i, k in enumerate(kpts):
|
||||||
color_k = [int(x) for x in self.kpt_color[i]] if is_pose else colors(i)
|
color_k = [int(x) for x in self.kpt_color[i]] if is_pose else colors(i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user