Simplify thop imports (#18717)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-01-16 22:27:27 +01:00 committed by GitHub
parent c6dd277493
commit daaebba220
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 17 deletions

View file

@ -1131,7 +1131,7 @@ class TorchVision(nn.Module):
def __init__(self, c1, c2, model, weights="DEFAULT", unwrap=True, truncate=2, split=False):
"""Load the model and weights from torchvision."""
import torchvision
import torchvision # scope for faster 'import ultralytics'
super().__init__()
if hasattr(torchvision.models, "get_model"):

View file

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