2025-简单点-ultralytics之LetterBox

LetterBox源码

class LetterBox:
    """
    Resize image and padding for detection, instance segmentation, pose.

    This class resizes and pads images to a specified shape while preserving aspect ratio. It also updates
    corresponding labels and bounding boxes.

    Attributes:
        new_shape (tuple): Target shape (height, width) for resizing.
        auto (bool): Whether to use minimum rectangle.
        scaleFill (bool): Whether to stretch the image to new_shape.
        scaleup (bool): Whether to allow scaling up. If False, only scale down.
        stride (int): Stride for rounding padding.
        center (bool): Whether to center the image or align to top-left.

    Methods:
        __call__: Resize and pad image, update labels and bounding boxes.

    Examples:
        >>> transform = LetterBox(new_shape=(640, 640))
        >>> result = transform(labels)
        >>> resized_img = result["img"]
        >>> updated_instances = result["instances"]
    """

    def __init__(self, new_shape=(640, 640), auto=False, scaleFill=False, scaleup=True, center=True, stride=32):
        """
        Initialize LetterBox object for resizing and padding images.

        This class is designed to resize and pad images for object detection, instance segmentation, and pose estimation
        tasks. It supports various resizing modes including auto-sizing, scale-fill, and letterboxing.

        Args:
            new_shape (Tuple[int, int]): Target size (height, width) for the resized image.
            auto (bool): If True, use minimum rectangle to resize. If False, use new_shape directly.
            scaleFill (bool): If True, stretch the image to new_shape without padding.
            scaleup (bool): If True, allow scaling up. If False, only scale down.
            center (bool): If True, center the placed image. If False, place image in top-left corner.
            stride (int): Stride of the model (e.g., 32 for YOLOv5).

        Attributes:
            new_shape (Tuple[int, int]): Target size for the resized image.
            auto (bool): Flag for using minimum rectangle resizing.
            scaleFill (bool): Flag for stretching image without padding.
            scaleup (bool): Flag for allowing upscaling.
            stride (int): Stride value for ensuring image size is divisible by stride.

        Examples:
            >>> letterbox = LetterBox(new_shape=(640, 640), auto=False, scaleFill=False, scaleup=True, stride=32)
            >>> resized_img = letterbox(original_img)
        """
        self.new_shape = new_shape
        self.auto = auto
        self.scaleFill = scaleFill
        self.scaleup = scaleup
        self.stride = stride
        self.center = center  # Put the image in the middle or top-left

    def __call__(self, labels=None, image=None):
        """
        Resizes and pads an image for object detection, instance segmentation, or pose estimation tasks.

        This method applies letterboxing to the input image, which involves resizing the image while maintaining its
        aspect ratio and adding padding to fit the new shape. It also updates any associated labels accordingly.

        Args:
            labels (Dict | None): A dictionary containing image data and associated labels, or empty dict if None.
            image (np.ndarray | None): The input image as a numpy array. If None, the image is taken from 'labels'.

        Returns:
            (Dict | Tuple): If 'labels' is provided, returns an updated dictionary with the resized and padded image,
                updated labels, and additional metadata. If 'labels' is empty, returns a tuple containing the resized
                and padded image, and a tuple of (ratio, (left_pad, top_pad)).

        Examples:
            >>> letterbox = LetterBox(new_shape=(640, 640))
            >>> result = letterbox(labels={"img": np.zeros((480, 640, 3)), "instances": Instances(...)})
            >>> resized_img = result["img"]
            >>> updated_instances = result["instances"]
        """
        if labels is None:
            labels = {}
        img = labels.get("img") if image is None else image
        shape = img.shape[:2]  # current shape [height, width]
        new_shape = labels.pop("rect_shape", self.new_shape)
        if isinstance(new_shape, int):
            new_shape = (new_shape, new_shape)

        # Scale ratio (new / old)
        r = min(new_shape[0] / shape[0], new_shape[1] / shape[1])
        if not self.scaleup:  # only scale down, do not scale up (for better val mAP)
            r = min(r, 1.0)

        # Compute padding
        ratio = r, r  # width, height ratios
        new_unpad = int(round(shape[1] * r)), int(round(shape[0] * r))
        dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1]  # wh padding
        if self.auto:  # minimum rectangle
            dw, dh = np.mod(dw, self.stride), np.mod(dh, self.stride)  # wh padding
        elif self.scaleFill:  # stretch
            dw, dh = 0.0, 0.0
            new_unpad = (new_shape[1], new_shape[0])
            ratio = new_shape[1] / shape[1], new_shape[0] / shape[0]  # width, height ratios

        if self.center:
            dw /= 2  # divide padding into 2 sides
            dh /= 2

        if shape[::-1] != new_unpad:  # resize
            img = cv2.resize(img, new_unpad, interpolation=cv2.INTER_LINEAR)
        top, bottom = int(round(dh - 0.1)) if self.center else 0, int(round(dh + 0.1))
        left, right = int(round(dw - 0.1)) if self.center else 0, int(round(dw + 0.1))
        img = cv2.copyMakeBorder(
            img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=(114, 114, 114)
        )  # add border
        if labels.get("ratio_pad"):
            labels["ratio_pad"] = (labels["ratio_pad"], (left, top))  # for evaluation

        if len(labels):
            labels = self._update_labels(labels, ratio, left, top)
            labels["img"] = img
            labels["resized_shape"] = new_shape
            return labels
        else:
            return img

    @staticmethod
    def _update_labels(labels, ratio, padw, padh):
        """
        Updates labels after applying letterboxing to an image.

        This method modifies the bounding box coordinates of instances in the labels
        to account for resizing and padding applied during letterboxing.

        Args:
            labels (Dict): A dictionary containing image labels and instances.
            ratio (Tuple[float, float]): Scaling ratios (width, height) applied to the image.
            padw (float): Padding width added to the image.
            padh (float): Padding height added to the image.

        Returns:
            (Dict): Updated labels dictionary with modified instance coordinates.

        Examples:
            >>> letterbox = LetterBox(new_shape=(640, 640))
            >>> labels = {"instances": Instances(...)}
            >>> ratio = (0.5, 0.5)
            >>> padw, padh = 10, 20
            >>> updated_labels = letterbox._update_labels(labels, ratio, padw, padh)
        """
        labels["instances"].convert_bbox(format="xyxy")
        labels["instances"].denormalize(*labels["img"].shape[:2][::-1])
        labels["instances"].scale(*ratio)
        labels["instances"].add_padding(padw, padh)
        return labels

解析

类文档字符串解释了 LetterBox 的主要功能:在保持宽高比的同时调整图像尺寸添加填充,同时更新相应的标签和边界框。它还列出了类的属性和主要方法。

def init(self, new_shape=(640, 640), auto=False, scaleFill=False, scaleup=True, center=True, stride=32):

在这里插入图片描述

def call(self, labels=None, image=None):

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
什么是top,bottom,left和right:
在这里插入图片描述

在这里插入图片描述

辅助方法

    @staticmethod
    def _update_labels(labels, ratio, padw, padh):

定义静态方法 _update_labels,用于在应用 letterboxing 后更新标签。
在这里插入图片描述

设计思路总结

保持宽高比:LetterBox 的核心功能是在调整图像尺寸时保持原始宽高比,避免图像变形,这对目标检测任务至关重要。

灵活的填充策略:

auto=True:确保填充尺寸是模型步幅的倍数
scaleFill=True:直接拉伸图像,不保持宽高比
center=True:图像居中,填充均匀分布
标签同步更新:在调整图像的同时,相应地更新边界框坐标,确保标注数据与图像匹配。

多任务支持:适用于目标检测、实例分割和姿态估计等多种计算机视觉任务。

高效实现:使用 OpenCV 进行图像处理,确保预处理速度高效。

这种预处理方法在 YOLO 系列模型中被广泛使用,是确保模型在不同尺寸输入上保持高性能的关键技术之一。

--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from ultralytics import YOLO File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\__init__.py:11 8 if not os.environ.get("OMP_NUM_THREADS"): 9 os.environ["OMP_NUM_THREADS"] = "1" # default for reduced CPU utilization during training ---> 11 from ultralytics.models import NAS, RTDETR, SAM, YOLO, YOLOE, FastSAM, YOLOWorld 12 from ultralytics.utils import ASSETS, SETTINGS 13 from ultralytics.utils.checks import check_yolo as checks File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\models\__init__.py:3 1 # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license ----> 3 from .fastsam import FastSAM 4 from .nas import NAS 5 from .rtdetr import RTDETR File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\models\fastsam\__init__.py:3 1 # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license ----> 3 from .model import FastSAM 4 from .predict import FastSAMPredictor 5 from .val import FastSAMValidator File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\models\fastsam\model.py:5 1 # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license 3 from pathlib import Path ----> 5 from ultralytics.engine.model import Model 7 from .predict import FastSAMPredictor 8 from .val import FastSAMValidator File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\model.py:12 9 from PIL import Image 11 from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir ---> 12 from ultralytics.engine.results import Results 13 from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, yaml_model_load 14 from ultralytics.utils import ( 15 ARGV, 16 ASSETS, (...) 23 checks, 24 ) File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\results.py:15 12 import numpy as np 13 import torch ---> 15 from ultralytics.data.augment import LetterBox 16 from ultralytics.utils import LOGGER, SimpleClass, ops 17 from ultralytics.utils.checks import check_requirements File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\data\__init__.py:3 1 # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license ----> 3 from .base import BaseDataset 4 from .build import build_dataloader, build_grounding, build_yolo_dataset, load_inference_source 5 from .dataset import ( 6 ClassificationDataset, 7 GroundingDataset, (...) 11 YOLOMultiModalDataset, 12 ) File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\data\base.py:16 13 import numpy as np 14 from torch.utils.data import Dataset ---> 16 from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS, check_file_speeds 17 from ultralytics.utils import DEFAULT_CFG, LOCAL_RANK, LOGGER, NUM_THREADS, TQDM 18 from ultralytics.utils.patches import imread File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\data\utils.py:17 14 import numpy as np 15 from PIL import Image, ImageOps ---> 17 from ultralytics.nn.autobackend import check_class_names 18 from ultralytics.utils import ( 19 DATASETS_DIR, 20 LOGGER, (...) 30 is_dir_writeable, 31 ) 32 from ultralytics.utils.checks import check_file, check_font, is_ascii File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\nn\__init__.py:3 1 # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license ----> 3 from .tasks import ( 4 BaseModel, 5 ClassificationModel, 6 DetectionModel, 7 SegmentationModel, 8 attempt_load_one_weight, 9 attempt_load_weights, 10 guess_model_scale, 11 guess_model_task, 12 parse_model, 13 torch_safe_load, 14 yaml_model_load, 15 ) 17 __all__ = ( 18 "attempt_load_one_weight", 19 "attempt_load_weights", (...) 28 "BaseModel", 29 ) File c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\nn\tasks.py:70 15 from ultralytics.nn.modules import ( 16 AIFI, 17 C1, (...) 67 v10Detect, 68 ) 69 from ultralytics.nn.MHSA import MHSA ---> 70 from ultralytics.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, colorstr, emojis, yaml_load 71 from ultralytics.utils.checks import check_requirements, check_suffix, check_yaml 72 from ultralytics.utils.loss import ( 73 E2EDetectLoss, 74 v8ClassificationLoss, (...) 78 v8SegmentationLoss, 79 ) ImportError: cannot import name 'yaml_load' from 'ultralytics.utils' (c:\Users\lenovo\miniconda3\envs\yolov8\lib\site-packages\ultralytics\utils\__init__.py)
05-15
使用anaconda管理yolo项目,File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\train.py", line 1, in <module> from ultralytics import YOLO File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\__init__.py", line 11, in <module> from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\models\__init__.py", line 3, in <module> from .fastsam import FastSAM File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\models\fastsam\__init__.py", line 3, in <module> from .model import FastSAM File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\models\fastsam\model.py", line 5, in <module> from ultralytics.engine.model import Model File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\engine\model.py", line 12, in <module> from ultralytics.engine.results import Results File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\engine\results.py", line 15, in <module> from ultralytics.data.augment import LetterBox File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\data\__init__.py", line 3, in <module> from .base import BaseDataset File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\data\base.py", line 17, in <module> from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\data\utils.py", line 18, in <module> from ultralytics.nn.autobackend import check_class_names File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\nn\__init__.py", line 3, in <module> from .tasks import ( File "F:\project\YOLOv8-Magic-8.3.12\YOLOv8-Magic\ultralytics-8.3.12\ultralytics\nn\tasks.py", line 67, in <module> from ultralytics.nn.modul
04-02
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "F:\ultralytics-8.3.89\train.py", line 1, in <module> from ultralytics import YOLO File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\__init__.py", line 11, in <module> from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\models\__init__.py", line 3, in <module> from .fastsam import FastSAM File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\models\fastsam\model.py", line 5, in <module> from ultralytics.engine.model import Model File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\model.py", line 12, in <module> from ultralytics.engine.results import Results File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\results.py", line 15, in <module> from ultralytics.data.augment import LetterBox File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\data\__init__.py", line 3, in <module> from .base import BaseDataset File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\data\base.py", line 17, in <module> from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\data\utils.py", line 18, in <module> from ultralytics.nn.autobackend import check_class_names File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\nn\autobackend.py", line 54, in <module> class AutoBackend(nn.Module): File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\nn\autobackend.py", line 89, in AutoBackend device=torch.device("cpu"), F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\nn\autobackend.py:89: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.) device=torch.device("cpu"), New https://pypi.org/project/ultralytics/8.3.165 available 😃 Update with 'pip install -U ultralytics' Ultralytics 8.3.89 🚀 Python-3.11.13 torch-2.3.1+cu121 CUDA:0 (NVIDIA GeForce RTX 4080 Laptop GPU, 12282MiB) engine\trainer: task=detect, mode=train, model=yolo11n.pt, data=data.yaml, epochs=200, time=None, patience=100, batch=20, imgsz=640, save=True, save_period=-1, cache=False, device=0, workers=8, project=None, name=train2, exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=True, opset=None, workspace=None, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, copy_paste_mode=flip, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=runs\detect\train2 Overriding model.yaml nc=80 with nc=1 from n params module arguments 0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2] 1 -1 1 4672 ultralytics.nn.modules.conv.Conv [16, 32, 3, 2] 2 -1 1 6640 ultralytics.nn.modules.block.C3k2 [32, 64, 1, False, 0.25] 3 -1 1 36992 ultralytics.nn.modules.conv.Conv [64, 64, 3, 2] 4 -1 1 26080 ultralytics.nn.modules.block.C3k2 [64, 128, 1, False, 0.25] 5 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2] 6 -1 1 87040 ultralytics.nn.modules.block.C3k2 [128, 128, 1, True] 7 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2] 8 -1 1 346112 ultralytics.nn.modules.block.C3k2 [256, 256, 1, True] 9 -1 1 164608 ultralytics.nn.modules.block.SPPF [256, 256, 5] 10 -1 1 249728 ultralytics.nn.modules.block.C2PSA [256, 256, 1] 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 12 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1] 13 -1 1 111296 ultralytics.nn.modules.block.C3k2 [384, 128, 1, False] 14 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 15 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1] 16 -1 1 32096 ultralytics.nn.modules.block.C3k2 [256, 64, 1, False] 17 -1 1 36992 ultralytics.nn.modules.conv.Conv [64, 64, 3, 2] 18 [-1, 13] 1 0 ultralytics.nn.modules.conv.Concat [1] 19 -1 1 86720 ultralytics.nn.modules.block.C3k2 [192, 128, 1, False] 20 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2] 21 [-1, 10] 1 0 ultralytics.nn.modules.conv.Concat [1] 22 -1 1 378880 ultralytics.nn.modules.block.C3k2 [384, 256, 1, True] 23 [16, 19, 22] 1 430867 ultralytics.nn.modules.head.Detect [1, [64, 128, 256]] YOLO11n summary: 181 layers, 2,590,035 parameters, 2,590,019 gradients, 6.4 GFLOPs Transferred 448/499 items from pretrained weights Freezing layer 'model.23.dfl.conv.weight' AMP: running Automatic Mixed Precision (AMP) checks... Traceback (most recent call last): File "F:\ultralytics-8.3.89\train.py", line 20, in <module> main() File "F:\ultralytics-8.3.89\train.py", line 8, in main results = model.train( ^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\model.py", line 810, in train self.trainer.train() File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\trainer.py", line 208, in train self._do_train(world_size) File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\trainer.py", line 323, in _do_train self._setup_train(world_size) File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\trainer.py", line 265, in _setup_train self.amp = torch.tensor(check_amp(self.model), device=self.device) ^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\utils\checks.py", line 698, in check_amp assert amp_allclose(YOLO("yolo11n.pt"), im) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\utils\checks.py", line 686, in amp_allclose a = m(batch, imgsz=imgsz, device=device, verbose=False)[0].boxes.data # FP32 inference ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\model.py", line 182, in __call__ return self.predict(source, stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\model.py", line 560, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\predictor.py", line 175, in __call__ return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\anaconda\envs\model\Lib\site-packages\torch\utils\_contextlib.py", line 35, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\predictor.py", line 257, in stream_inference im = self.preprocess(im0s) ^^^^^^^^^^^^^^^^^^^^^ File "F:\ultralytics-8.3.89\ultralytics-8.1.0\ultralytics\engine\predictor.py", line 130, in preprocess im = torch.from_numpy(im) ^^^^^^^^^^^^^^^^^^^^ RuntimeError: Numpy is not available
07-13
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

万物琴弦光锥之外

给个0.1,恭喜老板发财

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值