Allow missing thop package (#19314)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-02-19 23:01:56 +08:00 committed by GitHub
parent b94dd87f9d
commit b50a327a04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -7,7 +7,6 @@ import types
from copy import deepcopy
from pathlib import Path
import thop
import torch
from ultralytics.nn.modules import (
@ -86,6 +85,11 @@ from ultralytics.utils.torch_utils import (
time_sync,
)
try:
import thop
except ImportError:
thop = None # conda support without 'ultralytics-thop' installed
class BaseModel(torch.nn.Module):
"""The BaseModel class serves as a base class for all the models in the Ultralytics YOLO family."""