yolov9训练出现WARNING TensorBoard graph visualization failure Only tensors,可视化没有结构图解决方法(亲测有效)

28 篇文章 3 订阅 ¥49.90 ¥99.00

问题

yolov9训练出现下面警告:
WARNING TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions
这句话意思就是:警告:TensorBoard图形可视化失败,仅允许从跟踪函数输出张量、张量列表、张量元组或张量字典。简单来说打开的tensorboard中的仪表盘中没有graphs。
在这里插入图片描述


解决方法

1.打开utils/loggers/init.py
在这里插入图片描述
2.找到log_tensorboard_graph方法,大概381行,注释该方法,换成新的,新的代码如下:

def log_tensorboard_graph(tb, model, imgsz=(640, 640)):
    # Log model graph to TensorBoard
    try:
        p = next(model.parameters())  # for device, type
        imgsz = (imgsz, imgsz) if isinstance(imgsz, int) else imgsz  # expand
        im = torch.zeros((1, 3, *imgsz), device=p.device, dtype=p.dtype)  # input image (WARNING: must be zeros, not empty)
        from copy import deepcopy
        model = deepcopy(de_parallel(model))
        model.eval()
        model = model.fuse()
        for m in model.modules():
            if hasattr(m, "export"):
                m.export = True
                m.format = "torchscript"
        model(im)  # dry run
        tb.add_graph(torch.jit.trace(model, im, strict=False), [])
        LOGGER.info(f"Model graph visualization added ✅")
    except Exception as e:
        LOGGER.warning(f'WARNING ⚠️ TensorBoard graph visualization failure {e}')

在这里插入图片描述


验证

终端TensorBoard看看是否有结构图,命令如下

tensorboard --logdir=runs/train

在这里插入图片描述
成功显示
在这里插入图片描述


总结

创作不易,对你有帮助点个小爱心,谢谢

  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

挂科边缘(毕业版)

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值