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: object of type 'DataContainer' has no len()

See original GitHub issue

I installed the Docker image as mentioned in install.md and then tried testing the Faster RCNN model using the instructions provided in Getting_started.md

I ran the following code

python tools/test.py configs/faster_rcnn_r50_fpn_1x.py checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth --show

I got the following output

loading annotations into memory...
Done (t=0.59s)
creating index...
index created!
[                                                  ] 0/5000, elapsed: 0s, ETA:Traceback (most recent call last):
  File "tools/test.py", line 224, in <module>
    main()
  File "tools/test.py", line 184, in main
    outputs = single_gpu_test(model, data_loader, args.show)
  File "tools/test.py", line 26, in single_gpu_test
    result = model(return_loss=False, rescale=not show, **data)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 140, in forward
    return self.module(*inputs, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/mmdetection/mmdet/core/fp16/decorators.py", line 49, in new_func
    return old_func(*args, **kwargs)
  File "/mmdetection/mmdet/models/detectors/base.py", line 88, in forward
    return self.forward_test(img, img_meta, **kwargs)
  File "/mmdetection/mmdet/models/detectors/base.py", line 79, in forward_test
    return self.simple_test(imgs[0], img_metas[0], **kwargs)
  File "/mmdetection/mmdet/models/detectors/two_stage.py", line 231, in simple_test
    x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
  File "/mmdetection/mmdet/models/detectors/test_mixins.py", line 10, in simple_test_rpn
    proposal_list = self.rpn_head.get_bboxes(*proposal_inputs)
  File "/mmdetection/mmdet/core/fp16/decorators.py", line 127, in new_func
    return old_func(*args, **kwargs)
  File "/mmdetection/mmdet/models/anchor_heads/anchor_head.py", line 216, in get_bboxes
    for img_id in range(len(img_metas)):
TypeError: object of type 'DataContainer' has no len()

I have downloaded the checkpoint file and saved it in the checkpoints folder as mentioned above. I have also downloaded the COCO data and placed it in the directory as instructed in install.md

I am not able to understand the exact reason of the error. What I can say is that this term is causing the error,

len(img_metas)

So I just printed the object right before where the error is caused

print(img_metas)

and I got the output

DataContainer([[{'filename': 'data/coco/val2017/000000397133.jpg', 'ori_shape': (427, 640, 3), 'img_shape': (800, 1199, 3), 'pad_shape': (800, 1216, 3), 'scale_factor': 1.873536299765808, 'flip': False, 'img_norm_cfg': {'mean': array([123.675, 116.28 , 103.53 ], dtype=float32), 'std': array([58.395, 57.12 , 57.375], dtype=float32), 'to_rgb': True}}]])

if this helps in any way.

Please help me understand the error. Thank you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
Yang-Parkycommented, Jul 17, 2021

I have the same problem, and I solved it. just update mmcv to the latest version. pip uninstall mmcv-full pip install mmcv-full

modify mmdet/__init__.py mmcv_maximum_version = '1.3.6'

Perfect~

0reactions
wpc2333commented, Jun 1, 2021

I have the same problem, and I solved it. just update mmcv to the latest version. pip uninstall mmcv-full pip install mmcv-full

modify mmdet/__init__.py mmcv_maximum_version = '1.3.6'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange error, TypeError: object of type 'method' has no len()
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >
3 Using built-in data containers - Python How-To MEAP V07
Every modern language has data containers as their core data models, ... 'tuple' object has no attribute 'append' integers_tuple[0] = 'zero' #B #...
Read more >
pypeit.datamodel module - Read the Docs
Implements classes and function for the PypeIt data model. DataContainer . DataContainer objects provide a utility for enforcing a specific datamodel on an ......
Read more >
Ensembles — icet documentation
Attaches an observer to the ensemble. If the observer does not have an observation interval, then it will be set to the default_interval...
Read more >
Source code for odl.space.npy_tensors
For non-numeric data type like ``object``, the range of valid operations is ... This option has no impact if either ``dist``, ``norm`` or...
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