You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

YOLO NAS预测报错:save参数不存在,求解决方案及文档指引

YOLO NAS预测保存坐标及参数查询问题解决办法

一、解决save参数报错及保存TXT坐标的方法

YOLO NAS的predict方法不支持YOLOv8中的save、save_txt参数,要保存预测坐标为TXT文件,需手动处理预测结果:

  1. 执行预测获取结果:
results = yolo_nas_l.predict(url, conf=0.70)
  1. 提取检测框信息并写入TXT文件(以单张图片为例):
detections = results[0].predictions
# 写入YOLO格式的TXT文件
with open("detection_results.txt", "w") as txt_file:
    for det in detections:
        # 计算归一化后的YOLO格式坐标
        img_w, img_h = det.image_width, det.image_height
        x_center = (det.xmin + det.xmax) / 2 / img_w
        y_center = (det.ymin + det.ymax) / 2 / img_h
        bbox_w = (det.xmax - det.xmin) / img_w
        bbox_h = (det.ymax - det.ymin) / img_h
        # 写入内容:类别索引 中心x 中心y 宽 高 置信度
        txt_file.write(f"{det.class_id} {x_center:.6f} {y_center:.6f} {bbox_w:.6f} {bbox_h:.6f} {det.confidence:.6f}\n")
  1. 若需保存预测后的可视化图片,调用结果对象的save方法:
results.save("output_directory")

二、查询YOLO NAS函数及参数的渠道

  • 用Python内置help()函数:在代码中执行help(yolo_nas_l.predict)或help(CustomizableDetector),直接获取方法/类的参数、功能说明
  • 查看本地源码注释:找到YOLO NAS所属库(如SuperGradients)中CustomizableDetector类的定义文件,查看方法的参数注释
  • 参考库的官方API文档:查阅对应机器学习库的官方API参考章节,获取完整的函数、参数说明

内容的提问来源于stack exchange,提问作者hamza masri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 18:24:57