Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use caffe2_converter.py change the model to caffe2 #18

Open
XUDINGYI312 opened this issue Mar 19, 2021 · 2 comments
Open

use caffe2_converter.py change the model to caffe2 #18

XUDINGYI312 opened this issue Mar 19, 2021 · 2 comments

Comments

@XUDINGYI312
Copy link

the error is :

File "F:\BMaskR-CNN\projects\BMaskR-CNN\bmaskrcnn\mask_head.py", line 278, in forward
mask_rcnn_inference(mask_logits, instances)
File "f:\bmaskr-cnn\detectron2\modeling\roi_heads\mask_head.py", line 146, in mask_rcnn_inference
mask_probs_pred = pred_mask_logits[indices, class_pred][:, None].sigmoid()
IndexError: tensors used as indices must be long, byte or bool tensors

than change the mask_head.py ;
def mask_rcnn_inference(pred_mask_logits, pred_instances):
class_pred = cat([i.pred_classes for i in pred_instances]).type(torch.long)

the error is :
return cm_exit(cm, *exc_details)
File "D:\Anaconda3\envs\NBMASK\lib\contextlib.py", line 88, in exit
next(self.gen)
File "f:\bmaskr-cnn\detectron2\export\patcher.py", line 101, in mock_mask_rcnn_inference
assert mocked_func.call_count > 0
AssertionError

I want to know how to change myself model to caffe2 model.

@XdpAreKid
Copy link

@XUDINGYI312 HI,how did you fix this problem?

@XUDINGYI312
Copy link
Author

XUDINGYI312 commented Apr 19, 2021

@XdpAreKid
change the

if getattr(self.heads, "mask_on", False):
mock_ctx_managers += [mock_mask_rcnn_inference(tensor_mode, mask_head_mod,False)]

at F:\BMaskR-CNN\detectron2\export \caff2_patch.py or patcher.py

And can need to change the mask_head.py at
F:\BMaskR-CNN\detectron2\modeling\roi_heads\mask_head.py

def mask_rcnn_inference(pred_mask_logits, pred_instances):
cls_agnostic_mask = pred_mask_logits.size(1) == 1
if cls_agnostic_mask:

      mask_probs_pred = pred_mask_logits.sigmoid()

  else:
  
      mask_probs_pred = pred_mask_logits.sigmoid()
      mask_probs_pred = alias(mask_probs_pred, "mask_fcn_probs")
  pred_instances[0].pred_masks = mask_probs_pred

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants