YOLOv8预测时报错ValueError

【问题描述】执行YOLOv8预测代码时:

# 导入训练好的权重文件做预测
from ultralytics import YOLO

# Load a pretrained YOLOv8n model
model = YOLO("/data/yolov8/runs/detect/train6/weights/best.pt")

# Run inference on 'bus.jpg' with arguments
model.predict("1.png", save=True, imgsz=640, conf=0.5)

报错:ValueError: AutoBatch with batch<1 not supported for Multi-GPU training, please specify a valid batch size, i.e. batch=16

【解决方案】

在执行model.predict时指定device:

# 导入训练好的权重文件做预测
from ultralytics import YOLO

# Load a pretrained YOLOv8n model
model = YOLO("/data/ctc/yolov8/runs/detect/train6/weights/best.pt")

# Run inference on 'bus.jpg' with arguments
model.predict("1.png", save=True, imgsz=640, conf=0.5, device='cpu')

问题成功解决。

相关推荐

  1. YOLOv8模型验证以及一些报

    2024-07-22 21:54:05       38 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 21:54:05       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 21:54:05       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 21:54:05       45 阅读
  4. Python语言-面向对象

    2024-07-22 21:54:05       55 阅读

热门阅读

  1. 优化ifelse语句

    2024-07-22 21:54:05       16 阅读
  2. redis常用指令

    2024-07-22 21:54:05       15 阅读
  3. 多站点环境下Memcached的配置与管理

    2024-07-22 21:54:05       18 阅读
  4. Vue3 深入组件

    2024-07-22 21:54:05       17 阅读
  5. Leetcode热题100 Day4

    2024-07-22 21:54:05       16 阅读
  6. Python每日学习

    2024-07-22 21:54:05       15 阅读
  7. web前端 React 框架面试200题(七)

    2024-07-22 21:54:05       15 阅读