当前位置:   article > 正文

yolov8设置stream=True的时候,无法运行程序的方案_warning 鈿狅笍 inference results will accumulate in r

warning 鈿狅笍 inference results will accumulate in ram unless `stream=tru

STREAM_WARNING = “”"
WARNING ⚠️ inference results will accumulate in RAM unless stream=True is passed, causing potential out-of-memory
errors for large sources or long-running streams and videos. See https://docs.ultralytics.com/modes/predict/ for help.
当我们不做任何设置的时候,会有这样的一个提示。

我之前的yolov8代码是这样的,直接这样设置stream=True参数是无法运行程序的

from ultralytics import YOLO
import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"



if __name__ == '__main__':

    #预测结果
     model = YOLO('yolov8n-pose.pt')
     model.predict('0', save=True,stream=True)


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

需要把代码成下面的,这样运行摄像头检测,内存就不会一直上升,导致内存泄漏了。

import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"



from ultralytics import YOLO
model = YOLO("yolov8n-pose.pt")
results = model(source=0, stream=True,show=True)  # generator of Results objects
for r in results:
    boxes = r.boxes  # Boxes object for bbox outputs
    masks = r.masks  # Masks object for segment masks outputs
    probs = r.probs  # Class probabilities for classification outputs
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

本文章由微智启编写,转载标明出处。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/738159
推荐阅读
相关标签
  

闽ICP备14008679号