facebookresearch / Detectron

FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.
Apache License 2.0
26.21k stars 5.45k forks source link

I can't export model to ONNX: "AttributeError: EXPORT_CAFFE2" #986

Closed joaobarros05 closed 4 years ago

joaobarros05 commented 4 years ago

I cannot generate ONNX model. The following error message appears: "AttributeError: EXPORT_CAFFE2".

`torch_model = build_model(cfg) DetectionCheckpointer(torch_model).resume_or_load(cfg.MODEL.WEIGHTS)

data_loader = build_detection_test_loader(cfg, cfg.DATASETS.TEST[0]) first_batch = next(iter(data_loader))

onnx_model = export_onnx_model(cfg, torch_model, first_batch) onnx_model.save_protobuf('./teste')`

/opt/conda/lib/python3.7/site-packages/detectron2/export/api.py in export_onnx_model(cfg, model, inputs) 80 assert isinstance(cfg, CN), cfg 81 C2MetaArch = META_ARCH_CAFFE2_EXPORT_TYPE_MAP[cfg.MODEL.META_ARCHITECTURE] ---> 82 c2_compatible_model = C2MetaArch(cfg, model) 83 c2_format_input = c2_compatible_model.get_caffe2_inputs(inputs) 84 return export_onnx_model_impl(c2_compatible_model, (c2_format_input,))

/opt/conda/lib/python3.7/site-packages/detectron2/export/caffe2_modeling.py in init(self, cfg, torch_model) 250 super().init(cfg, torch_model) 251 --> 252 self.roi_heads_patcher = ROIHeadsPatcher(cfg, self._wrapped_model.roi_heads) 253 254 def encode_additional_info(self, predict_net, init_net):

/opt/conda/lib/python3.7/site-packages/detectron2/export/patcher.py in init(self, cfg, heads) 117 self.heads = heads 118 --> 119 self.use_heatmap_max_keypoint = cfg.EXPORT_CAFFE2.USE_HEATMAP_MAX_KEYPOINT 120 121 @contextlib.contextmanager

/opt/conda/lib/python3.7/site-packages/yacs/config.py in getattr(self, name) 139 return self[name] 140 else: --> 141 raise AttributeError(name) 142 143 def setattr(self, name, value):

AttributeError: EXPORT_CAFFE2`

Does anyone have any idea what that is?

groumpfette commented 4 years ago

Hi, same problem here, did you solve it?

ppwwyyxx commented 4 years ago

Unrelated to Detectron.