WongKinYiu / yolov9

Implementation of paper - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
GNU General Public License v3.0
8.89k stars 1.4k forks source link

'WARNING TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be' Warning İssue #195

Open berkakyildizz opened 7 months ago

berkakyildizz commented 7 months ago

Starting training for 50 epochs...

  Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
   0/49      18.4G       1.92      3.782      2.399         38        640:   0%|          | 0/130 00:46WARNING  TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be 

output from traced functions 0/49 18.5G 1.634 2.721 1.957 41 640: 29%|██▉ | 38/130 19:30

'WARNING TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be'

What is this Warning, I don't understand what I need to do to solve this, can you help me?

moding977 commented 7 months ago

same question. It keeps running when I don't care about it. 1709989519539

darkstar1227 commented 6 months ago

I have same problem. I just ignored it.

KNzzzzzzzzzz commented 5 months ago

Do you solve the problem?

darkstar1227 commented 5 months ago

Well, actually, I just ignored it. The reason is I found out that is not the problem for yolov9, it is the old problem from yolov5. And it might figure out by ultralistics, in my memory, in the new version of yolov5.

KNzzzzzzzzzz commented 5 months ago

Thanks!

202211010629 commented 5 months ago

有人解决了问题吗

RifHut commented 3 months ago

I have same problem. I just ignored it.

I can ask , there's no problem when ignore it ?

KNzzzzzzzzzz commented 3 months ago

I have same problem. I just ignored it.

I can ask , there's no problem when ignore it ?

No problem

tson122556 commented 3 months ago

忽略之后没办法加载计算图该怎么办

darkstar1227 commented 3 months ago

忽略之后没办法加载计算图该怎么办

I don't have this problem.

tson122556 commented 3 months ago

忽略后用tensoboard 做过程监控时看不到graph,你们有这个情况吗

KNzzzzzzzzzz commented 3 months ago

有这个问题,但是可以正常训练

tson122556 commented 3 months ago

有这个问题,但是可以正常训练

有没有办法解决掉这个警告,然后加载出graph呢

tson122556 commented 3 months ago

忽略之后没办法加载计算图该怎么办

I don't have this problem.

Can you load the computation graph correctly?

ankandrew commented 3 months ago

You can tweak the utils.loggers.log_tensorboard_graph with the following code to display properly the arch:

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)
        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}')

Inspired by ultralytics ultralytics.utils.callbacks.tensorboard._log_tensorboard_graph:

https://github.com/ultralytics/ultralytics/blob/e30b7c24f22b98dcf30ca5d23871659f861acadd/ultralytics/utils/callbacks/tensorboard.py#L57-L66

berkakyildizz commented 3 months ago

You can tweak the utils.loggers.log_tensorboard_graph with the following code to display properly the arch:

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)
        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}')

Inspired by ultralytics ultralytics.utils.callbacks.tensorboard._log_tensorboard_graph:

https://github.com/ultralytics/ultralytics/blob/e30b7c24f22b98dcf30ca5d23871659f861acadd/ultralytics/utils/callbacks/tensorboard.py#L57-L66

Thanks for your code. The code is successfully run.

tson122556 commented 3 months ago

You can tweak the utils.loggers.log_tensorboard_graph with the following code to display properly the arch:

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)
        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}')

Inspired by ultralytics ultralytics.utils.callbacks.tensorboard._log_tensorboard_graph:

https://github.com/ultralytics/ultralytics/blob/e30b7c24f22b98dcf30ca5d23871659f861acadd/ultralytics/utils/callbacks/tensorboard.py#L57-L66

Thank you very much for your high-quality reply. It has been loaded successfully.