补全yolov5的代码

This commit is contained in:
2025-03-13 17:48:59 +08:00
parent 6daea23f0a
commit 9d369b9898
42 changed files with 8571 additions and 171 deletions

View File

@ -35,9 +35,9 @@ except (ImportError, AssertionError):
from ultralytics.utils.plotting import Annotator, colors, save_one_box
from utils import TryExcept
from utils.dataloaders import exif_transpose, letterbox
from utils.general import (
from yolov5.utils import TryExcept
from yolov5.utils.dataloaders import exif_transpose, letterbox
from yolov5.utils.general import (
LOGGER,
ROOT,
Profile,
@ -54,7 +54,7 @@ from utils.general import (
xyxy2xywh,
yaml_load,
)
from utils.torch_utils import copy_attr, smart_inference_mode
from yolov5.utils.torch_utils import copy_attr, smart_inference_mode
def autopad(k, p=None, d=1):
@ -473,7 +473,7 @@ class DetectMultiBackend(nn.Module):
# TensorFlow Lite: *.tflite
# TensorFlow Edge TPU: *_edgetpu.tflite
# PaddlePaddle: *_paddle_model
from models.experimental import attempt_download, attempt_load # scoped to avoid circular import
from yolov5.models.experimental import attempt_download, attempt_load # scoped to avoid circular import
super().__init__()
w = str(weights[0] if isinstance(weights, list) else weights)
@ -661,7 +661,7 @@ class DetectMultiBackend(nn.Module):
elif triton: # NVIDIA Triton Inference Server
LOGGER.info(f"Using {w} as Triton Inference Server...")
check_requirements("tritonclient[all]")
from utils.triton import TritonRemoteModel
from yolov5.utils.triton import TritonRemoteModel
model = TritonRemoteModel(url=w)
nhwc = model.runtime.startswith("tensorflow")
@ -780,8 +780,8 @@ class DetectMultiBackend(nn.Module):
Example: path='path/to/model.onnx' -> type=onnx
"""
# types = [pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs, paddle]
from export import export_formats
from utils.downloads import is_url
from yolov5.export import export_formats
from yolov5.utils.downloads import is_url
sf = list(export_formats().Suffix) # export suffixes
if not is_url(p, check=False):

View File

@ -7,7 +7,7 @@ import numpy as np
import torch
import torch.nn as nn
from utils.downloads import attempt_download
from yolov5.utils.downloads import attempt_download
class Sum(nn.Module):
@ -91,7 +91,7 @@ def attempt_load(weights, device=None, inplace=True, fuse=True):
Example inputs: weights=[a,b,c] or a single model weights=[a] or weights=a.
"""
from models.yolo import Detect, Model
from yolov5.models.yolo import Detect, Model
model = Ensemble()
for w in weights if isinstance(weights, list) else [weights]: