mmdetection
mmdetection copied to clipboard
TypeError: forward() missing 1 required positional argument: 'img_metas'
I am using mmdetection version 2.28.2. I am currently using the Mask2Former model. When I use the trained model to calculate flops, params (using the thop library), or visualize using gradcam, I get an error.
I don't know why this error occurs. I also get this error when using tools/get_flops.py. I hope an expert can answer this question.
I have the same issue. I want to calculate FLOPs for model.
I have the same issue.
I have the same issue,I want to count FLOPs with my own models.
I have the same issue,I want to count FLOPs with my own models.
I found that the reason may be that the parameter img_metas is required for forward inference of the model. There are examples of preparing img_metas in mmdet/apis/inference.py in mmdetection framework. It can be analogous to preparing forward inference data according to data preparation in inference.py.
my mmdet version is 2.28.2
@wxmchgithub suppose I want to inference an image, how do I prepare data[img_metas] ? Thanks!!!
suppose I want to inference an image, how do I prepare data[img_metas] ? Thanks!!!
If you only want to perform inference on the image, you don't need to prepare img_metas yourself. demo/image_demo.py demonstrates how to perform inference on images.
@wxmchgithub I want to inference an image then calculate the FLOPs of model based on it.
@wxmchgithub I want to inference an image then calculate the FLOPs of model based on it.
@wxmchgithub I want to inference an image then calculate the FLOPs of model based on it.
You can refer to inference_detector under inference.py. It contains the preparation of img_metas.