transfiner
transfiner copied to clipboard
how to export trained weights to onnx
have tried detectron export script but failed.
File "/workspace/transfiner/detectron2/export/caffe2_modeling.py", line 274, in forward
detector_results, _ = self._wrapped_model.roi_heads(images, features, proposals)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 725, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward
result = self.forward(*input, **kwargs)
File "/workspace/transfiner/detectron2/modeling/roi_heads/roi_heads.py", line 752, in forward
pred_instances = self.forward_with_given_boxes(features, pred_instances)
File "/workspace/transfiner/detectron2/modeling/roi_heads/roi_heads.py", line 778, in forward_with_given_boxes
instances = self._forward_mask(features, instances)
File "/workspace/transfiner/detectron2/modeling/roi_heads/roi_heads.py", line 852, in _forward_mask
features = self.mask_pooler(features, boxes)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 725, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward
result = self.forward(*input, **kwargs)
File "/workspace/transfiner/detectron2/export/c10.py", line 360, in forward
assert roi_feat_shuffled.numel() > 0 and rois_idx_restore_int32.numel() > 0, (
AssertionError: Caffe2 export requires tracing with a model checkpoint + input that can produce valid detections. But no detections were obtained with the given checkpoint and input!
Set weights path in configs/transfiner/xxxx.yaml,then use tools/deploy/export_model.py to deploy onnx.
I found another thing may cause this error, your input image must contain at least one object.I generate some images with np.random and it looks like a big noise with no object.The script cannot export model.