Plotting gluon hybrid network

Hi there,

I try to visualise an SSD network from GluonCV, using the function:
https://gluon-cv.mxnet.io/api/utils.html#gluoncv.utils.viz.plot_network

import gluoncv

net_name = 'ssd_512_resnet18_v1_voc'
net = gluoncv.model_zoo.get_model(net_name, pretrained_base=True)
gluoncv.utils.viz.plot_network(net, shape=(1, 3, 512, 512))

It gives an error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/gluoncv/utils/viz/network.py", line 32, in plot_network
    node_attrs={'shape':'rect', 'fixedsize':'false'})
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/mxnet/visualization.py", line 382, in plot_network
    shape = shape_dict[key][1:]
KeyError: 'ssd1_box_nms0_output'

The plot_network function exists since gluoncv version 0.5.0 (development). Is there something I do wrong or should I file a bug report on GitHub? Or is there another way to visualise the network?

Thanks,
Blake

I tried the advice written in this post:

but it does not work. I did:

import mxnet as mx

# After running code from initial post
net.hybridize()
net.collect_params().initialize(force_reinit=True)
x = mx.sym.var('data')
sym = net(x)
mx.viz.plot_network(sym)

This results in the error:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/mxnet/visualization.py", line 273, in plot_network
    raise TypeError("symbol must be a Symbol")
TypeError: symbol must be a Symbol

Indeed there seems to be an issue with the shape information, but you can get the graph like this

import mxnet as mx
import gluoncv

net_name = 'ssd_512_resnet18_v1_coco'
net = gluoncv.model_zoo.get_model(net_name)
mx.viz.plot_network(net(mx.sym.var('data'))[0], node_attrs={"shape":"oval","fixedsize":"false"})
2 Likes

Super big thank you Thomas. It works!