microsoft / FocalNet

[NeurIPS 2022] Official code for "Focal Modulation Networks"
MIT License
682 stars 61 forks source link

FocalNet onnx conversion #26

Closed Simardeep27 closed 1 year ago

Simardeep27 commented 1 year ago

Hi,

I am trying to convert FocalNet model to onnx using mmdeploy. However, I am running into an error due to size mismatch.

Config being used: cascade_mask_rcnn_focalnet_tiny_patch4_mstrain_480-800_adamw_3x_coco_lrf.py Weights: focalnet_tiny_lrf_cascade_maskrcnn_3x.pth

The error I am encountering:

File "/DATA/scratch/FocalNet-MMDetection/tools/mmdeploy/mmdeploy/codebase/mmdet/models/roi_heads/cascade_roi_head.py", line 66, in cascade_roi_head__simple_test bbox_pred = bbox_pred.reshape(batch_size, num_proposals_per_img, 4) RuntimeError: shape '[1, 1000, 4]' is invalid for input of size 8000

Can you please point out what could be the reason for this error?

jwyang commented 1 year ago

I did not encounter this error before but did you check whether you can run the inference code with the ckpt?

Simardeep27 commented 1 year ago

Yes, I was able to run the inference code successfully on this ckpt file.

jwyang commented 1 year ago

Interesting, probably you need to debug a bit, because it seems that your bbox_pred does not match the reshape size, are you using batch size 1 or 2?

Simardeep27 commented 1 year ago

I'm using batch size as 1

jwyang commented 1 year ago

a bit weird then you might want to debug with some breakpoints, maybe caused by different versions of mmdet?

Simardeep27 commented 1 year ago

Which mmdet version do you suggest?