open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.43k stars 9.43k forks source link

How I can visualize the model graph? #5813

Closed stanislavkuskov closed 3 years ago

stanislavkuskov commented 3 years ago

Hello! How I can visualize the model graph? In tensorboardX for example. When i try to use model(x) its get me error _"forward() missing 1 required positional argument: 'imgmetas'" `

config = '/home/kuskov/sat/mmdetection/configs/res2net/faster_rcnn_r2_101_fpn_2x_coco.py' checkpoint = 'checkpoints/faster_rcnn_r2_101_fpn_2x_coco-175f1da6.pth' model = init_detector(config, checkpoint, device='cuda:0')

img = torch.zeros([1, 3, 224, 224]) with SummaryWriter(comment='MultipleOutput_shared') as w:

w.add_graph(model,` img, True)

`

RangiLyu commented 3 years ago

You need to set model.forward = model.forward_dummy because the detector's forward function is not the same as the default forward function of pytorch module.

stanislavkuskov commented 3 years ago

@RangiLyu Thank You, that works!