question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: forward() missing 1 required positional argument: 'img_metas'

See original GitHub issue

Sorry for this basic doubt. I am trying to worl with the SWIN transformer backbone and need to do a forward pass for the model in order to achieve quantization with the help of the Tensor-RT library .I am trying to do so using: model('img_path'). However, I get the following error : TypeError: forward() missing 1 required positional argument: 'img_metas'

I am not really sure what exactly does the method exactly expects as img_metas. If I am wrong in trying to do a forward pass with this, Is there a better or a different way to do this?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:12

github_iconTop GitHub Comments

1reaction
psychomugscommented, Mar 31, 2022

Assuming all your input data is uniformly formatted, you can manually create the dict and construct your own img_metas list. I set a breakpoint in a function containing img_metas and copied one of the results.

_img_metas = {
    'ori_shape': (480, 640, 3),
    'img_shape': (480, 640, 3),
    'pad_shape': (480, 640, 3),
    'scale_factor': [1., 1., 1., 1.],
    'flip': True,
    'flip_direction': 'horizontal',
    'img_norm_cfg': {
        'mean': [123.675, 116.28 , 103.53 ],
        'std': [58.395, 57.12 , 57.375],
        'to_rgb': True
    },
    'batch_input_shape': (480, 640)
    }

img_metas = [_img_metas] * number_of_inputs

I haven’t tested if the augmentation parameters (e.g. flip, flip_direction) affect the results.

1reaction
SourabhRanadecommented, Mar 4, 2022

@dnth I am trying to use a MASK RCNN model with a SWIN transformer backbone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

using torch.jit.trace() and it goes TypeError: forward() missing ...
using torch.jit.trace() and it goes TypeError: forward() missing 1 required positional argument: 'img_metas' #7988.
Read more >
TypeError: forward() missing 1 required positional argument ...
I think the error message is pretty straight forward. You have two positional arguments input_tokens and hidden for your forward() .
Read more >
forward() missing 1 required positional argument - Xilinx Support
I changed resnet18_quant.py to quantize my model?the .py file like this: import osimport argparseimport randomfrom pytorch_nndct.apis import ...
Read more >
forward() missing 1 required positional argument: 'target' when ...
I am trying to build a next word prediction model with pytorch in google colab. As my vocabulary size is over 1.5 million,...
Read more >
TypeError: forward() missing 1 required positional argument: 'x'
TypeError : forward() missing 1 required positional argument: 'x' ... 1 frames <ipython-input-13-3ff21b7150f2> in run_train_test() ---> 17 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found