I want to export the model of DeFCN to onnx to better see the details of this model,so i try to export with add some code ,but get error.
DeFCN/playground/detection/coco/poto.res50.fpn.coco.800size.3x_ms.3dmf_wo_gn.aux/net.py
i modify poto.res50.fpn.coco.800size.3x_ms.3dmf_wo_gn.aux as poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux for import,
add some code and run:
from cvpods.engine import default_argument_parser, default_setup
from DeFCN.playground.detection.coco.poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux.config import config
args = default_argument_parser().parse_args()
print("Command Line Args:", args)
config.link_log()
print("soft link to {}".format(config.OUTPUT_DIR))
cfg,logger=default_setup(config,args)
model=build_model(cfg)
model.eval()
input=torch.randn((1,3,48,48))
input=torch.rand(1)
output=model(input)
print(output.shape)
input_names=['input']
output_names=['output']
torch.onnx.export(model,input,'1.onnx',input_names=input_names,output_names=output_names,verbose=True,opset_version=11)
but get error as follows:
[09/22 11:36:18 c2.utils.env.env]: Using a generated random seed 18403068
Traceback (most recent call last):
File "/media/liang/linux_data/github_download/cvpods-master/DeFCN/playground/detection/coco/poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux/net.py", line 66, in
output=model(input)
File "/home/liang/miniconda3/envs/mmdet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/media/liang/linux_data/github_download/cvpods-master/DeFCN/playground/detection/coco/poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux/fcos.py", line 117, in forward
images = self.preprocess_image(batched_inputs)
File "/media/liang/linux_data/github_download/cvpods-master/DeFCN/playground/detection/coco/poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux/fcos.py", line 546, in preprocess_image
images = [x["image"].to(self.device) for x in batched_inputs]
File "/media/liang/linux_data/github_download/cvpods-master/DeFCN/playground/detection/coco/poto_res50_fpn_coco_800size_3x_ms_3dmf_wo_gn_aux/fcos.py", line 546, in
images = [x["image"].to(self.device) for x in batched_inputs]
IndexError: too many indices for tensor of dimension 0
Process finished with exit code 1