VDIGPKU / M2Det

M2Det: A Single-Shot Object Detector based on Multi-Level Feature Pyramid Network
MIT License
1.45k stars 318 forks source link

Has anyone use tensorboardX to visualize network structure? Some problem about the process of visualizing. #49

Open chr10003566 opened 5 years ago

chr10003566 commented 5 years ago

I want to visualize the M2Det network, using the following code.

from configs.CC import Config
from layers.functions import Detect, PriorBox
from m2det import build_net
from tensorboardX import SummaryWriter
from torch.autograd import Variable
from utils.core import *

cfg = Config.fromfile('configs/m2det512_vgg.py')
net = build_net('test',
                size = cfg.model.input_size,
                config = cfg.model.m2det_config)
dummy_input = torch.rand(13, 3, 512, 512)
with SummaryWriter(comment='M2Det') as w:
   w.add_graph(net, (dummy_input, ))

It would raise the error TypeError: conv2d(): argument 'input' (position 1) must be Tensor, not tuple

but when I change the last line to w.add_graph(net, dummy_input)

it would raiseValueError: Auto nesting doesn't know how to process an input object of type str. Accepted types: Tensors, or lists/tuples of them

Anyone have the experience to visualize the network structure? Please help me , Thx

YongshengDong commented 5 years ago

hi, You can modify some codes in m2det.py to solve this problem. From: self.leach = nn.ModuleList([BasicConv( deep_out+shallow_out, self.planes//2, kernel_size=(1, 1), stride=(1, 1))]*self.num_levels) To: self.leach = nn.ModuleList([BasicConv( deep_out+shallow_out, self.planes//2, kernelsize=(1, 1), stride=(1, 1)) for in range(self.num_levels)])