YOLO训练产出warning: NMS time limit 1.060s exceeded原因与解决办法

这篇具有很好参考价值的文章主要介绍了YOLO训练产出warning: NMS time limit 1.060s exceeded原因与解决办法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在进行模型训练结束后,模型代码会执行

Python val.py

对模型进行map准确率的验证,使用时候出现

YOLO训练产出warning: NMS time limit 1.060s exceeded原因与解决办法
talk is cheap ,show me the code.
找到warning的代码出处:

def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False,
                        labels=(), max_det=300):
    """Runs Non-Maximum Suppression (NMS) on inference results
    Returns:
         list of detections, on (n,6) tensor per image [xyxy, conf, cls]
    """

    nc = prediction.shape[2] - 5  # number of classes
    xc = prediction[..., 4] > conf_thres  # candidates

    # Checks
    assert 0 <= conf_thres <= 1, f'Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0'
    assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'

    # Settings
    min_wh, max_wh = 2, 4096  # (pixels) minimum and maximum box width and height
    max_nms = 30000  # maximum number of boxes into torchvision.ops.nms()
    time_limit = 10.0  # seconds to quit after
    redundant = True  # require redundant detections
    multi_label &= nc > 1  # multiple labels per box (adds 0.5ms/img)
    merge = False  # use merge-NMS

    t = time.time()
    output = [torch.zeros((0, 6), device=prediction.device)] * prediction.shape[0]
    for xi, x in enumerate(prediction):  # image index, image inference
        # Apply constraints
        # x[((x[..., 2:4] < min_wh) | (x[..., 2:4] > max_wh)).any(1), 4] = 0  # width-height
        x = x[xc[xi]]  # confidence

        # Cat apriori labels if autolabelling
        if labels and len(labels[xi]):
            l = labels[xi]
            v = torch.zeros((len(l), nc + 5), device=x.device)
            v[:, :4] = l[:, 1:5]  # box
            v[:, 4] = 1.0  # conf
            v[range(len(l)), l[:, 0].long() + 5] = 1.0  # cls
            x = torch.cat((x, v), 0)

        # If none remain process next image
        if not x.shape[0]:
            continue

        # Compute conf
        x[:, 5:] *= x[:, 4:5]  # conf = obj_conf * cls_conf

        # Box (center x, center y, width, height) to (x1, y1, x2, y2)
        box = xywh2xyxy(x[:, :4])

        # Detections matrix nx6 (xyxy, conf, cls)
        if multi_label:
            i, j = (x[:, 5:] > conf_thres).nonzero(as_tuple=False).T
            x = torch.cat((box[i], x[i, j + 5, None], j[:, None].float()), 1)
        else:  # best class only
            conf, j = x[:, 5:].max(1, keepdim=True)
            x = torch.cat((box, conf, j.float()), 1)[conf.view(-1) > conf_thres]

        # Filter by class
        if classes is not None:
            x = x[(x[:, 5:6] == torch.tensor(classes, device=x.device)).any(1)]

        # Apply finite constraint
        # if not torch.isfinite(x).all():
        #     x = x[torch.isfinite(x).all(1)]

        # Check shape
        n = x.shape[0]  # number of boxes
        if not n:  # no boxes
            continue
        elif n > max_nms:  # excess boxes
            x = x[x[:, 4].argsort(descending=True)[:max_nms]]  # sort by confidence

        # Batched NMS
        c = x[:, 5:6] * (0 if agnostic else max_wh)  # classes
        boxes, scores = x[:, :4] + c, x[:, 4]  # boxes (offset by class), scores
        i = torchvision.ops.nms(boxes, scores, iou_thres)  # NMS
        if i.shape[0] > max_det:  # limit detections
            i = i[:max_det]
        if merge and (1 < n < 3E3):  # Merge NMS (boxes merged using weighted mean)
            # update boxes as boxes(i,4) = weights(i,n) * boxes(n,4)
            iou = box_iou(boxes[i], boxes) > iou_thres  # iou matrix
            weights = iou * scores[None]  # box weights
            x[i, :4] = torch.mm(weights, x[:, :4]).float() / weights.sum(1, keepdim=True)  # merged boxes
            if redundant:
                i = i[iou.sum(1) > 1]  # require redundancy

        output[xi] = x[i]
        if (time.time() - t) > time_limit:
            print(f'WARNING: NMS time limit {time_limit}s exceeded')
            break  # time limit exceeded

    return output

以上是NMS非极大值抑制代码实现过程,其原理也很简单,解决的是多个锚框重叠的问题。

其实原因来看,进行NMS的时间断点太长了,将阈值也调大

    #time_limit = 10.0  # seconds to quit after
    time_limit = 20.0  # seconds to quit after

同时这个warning只会存在与前几轮,原因是模型加载同时模型还没有学到特征,进行模型推理速度太慢,训练几轮后,模型的提取特征能力增强,推理图片数据的性能自然会提升,警告也就消失了。文章来源地址https://www.toymoban.com/news/detail-509853.html

到了这里,关于YOLO训练产出warning: NMS time limit 1.060s exceeded原因与解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • java.lang.OutOfMemoryError: GC overhead limit exceeded问题分析及解决

    出现该问题的原因:当GC为释放很小空间占用大量时间时会抛出此异常,即(Sun 官方对此的定义,超过98%的时间用来做GC并且回收了不到2%的堆内存时会抛出此异常)。一般是因为堆太小,导致异常的原因:没有足够的内存。 对于该项目我的启动命令如下:堆内存空间开辟的

    2024年01月21日
    浏览(40)
  • 微信小程序报错“navigateTo:fail webview count limit exceed”

    今天在开发微信小程序时遇到一个不常见的报错,今天教大家如何一分钟解决下图报错。 当微信小程序中使用了过多的 webview 组件时,会导致报错 “navigateTo:fail webview count limit exceed” 。这是因为微信小程序对 webview 组件的数量有限制,超过限制就会报错。具体的限制数量可

    2024年02月11日
    浏览(41)
  • idea maven 打包 内存溢出 报 GC overhead limit exceeded -> [Help 1]

    idea 使用maven打包 报GC overhead limit exceeded - [Help 1] 解决方法: 打开settings - 点开如同所示 将 vm Options 参数 设为 -Xmx8g 

    2024年04月10日
    浏览(36)
  • elasticsearch查询出现Limit of total fields 1000 has been exceeded

    在项目中使用elasticsearch保存日志等相关数据,查询页面查询这些日志数据 提示:这里描述项目中遇到的问题: 今天在检查日志数据时,发现数据出不来,检查后端日志,发现一直在报Limit of total fields 1000 has been exceeded的问题 提示:这里填写问题的分析: 经过问题排查,发现

    2024年02月04日
    浏览(30)
  • 解决GateWay报错:Exceeded limit on max bytes to buffer : 262144

    场景: 前端传来了一个大的字符串 发现请求不通 一番调试发现SpringGateway 默认内存缓冲区262144字节 网上查了很多种常见的解决方案无效之后 直接重写底层 网友的解决方案 方案1(无效) 直接修改缓冲区大小 方案2(无效) 方案3 无效 gateway-2.2.3以上版本修复了该bug,在Gat

    2024年02月04日
    浏览(37)
  • Time to live exceeded

    Time to live exceeded的原因:数据包未上传成功,形成路由环路。 当对网络上的主机进行ping操作的时候,本地机器会发出一个数据包,数据包经过一定数量的路由器传送到目的主机,但是由于很多的原因,一些数据包不能正常传送到目的主机,如果不给这些数据包一个生存时间

    2024年02月14日
    浏览(25)
  • elasticsearch报错:exceeds the [index.highlight.max_analyzed_offset] limit [1000000]

    The length [27277624] of field [content] in doc[2]/index[1234567890abcdefg] exceeds the [index.highlight.max_analyzed_offset] limit [1000000]. To avoid this error, set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them. ********************************************

    2023年04月25日
    浏览(32)
  • 记录Flink 线上碰到java.lang.OutOfMemoryError: GC overhead limit exceeded如何处理?

    这个问题是Flink TM内存中我们常见的,看到这个问题我们就要想到下面这句话: 程序在垃圾回收上花了很多时间,却收集一点点内存,伴随着会出现CPU的升高。 是不是大家出现这个问题都会出现上面这种情况呢。那我的问题出现如下: 发现JVM Heap堆内存过高。那么堆内存包含

    2024年02月03日
    浏览(27)
  • 解决Error:java: java.lang.OutOfMemoryError: WrappedJavaFileObject...GC overhead limit exceeded的错误

    今天在启动项目时,报出如下错误: 即 Error:java: java.lang.OutOfMemoryError: WrappedJavaFileObject[org.jetbrains.jps.javac.InputFileObject[file:xxx.java]]@pos242:@pos242: GC overhead limit exceeded 将错误 Error:java: java.lang.OutOfMemoryError: WrappedJavaFileObject[org.jetbrains.jps.javac.InputFileObject[file:xxx.java]]@pos242:@pos242: GC

    2024年02月04日
    浏览(30)
  • 解决Elasticsearch索引报错问题之Limit of total fields 1000 has been exceeded ...

    在Kibana上查询生产环境的日志时,发现某个一直无法查询到,怀疑想要的日志被丢弃了,遂登录服务器查询原始日志,果然发现日志存在被丢弃的问题。经定位,在Logstash的日志中发现问题所在: Elasticsearch的Mapping做了映射保护,为了防止索引中错误的内容导致Mapping

    2024年02月11日
    浏览(28)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包