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.

fastai efficientdet fails on learn.validate() with AttributeError: 'NoneType' object has no attribute 'shape'

See original GitHub issue

🐛 Bug

when trying to simply validate metrics for an efficientdet model with fastai

KeyError: 'image_id'
AttributeError: 'NoneType' object has no attribute 'shape'

it fails when trying to read the batch size automatically: in accumulate, find_bs

class AvgLoss(Metric):
    "Average the losses taking into account potential different batch sizes"
    def reset(self):           self.total,self.count = 0.,0
    def accumulate(self, learn):
        bs = find_bs(learn.yb)
        self.total += learn.to_detach(learn.loss.mean())*bs
        self.count += bs
    @property
    def value(self): return self.total/self.count if self.count != 0 else None
    @property
    def name(self):  return "loss"

To Reproduce Steps to reproduce the behavior:

  1. Go to https://colab.research.google.com/drive/1i4aXYu4wIKA7eLUK86GwTm7lq7zku_oF?usp=sharing

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
potipotcommented, Feb 11, 2021

I found that applying a following patch:

from fastai.learner import AvgLoss
from fastai.torch_core import find_bs

@patch
def accumulate(self:AvgLoss, learn):
    #bs = find_bs(learn.yb)
    bs = find_bs(learn.xb)
    self.total += learn.to_detach(learn.loss.mean())*bs
    self.count += bs

fixes the issue. Im not sure though how should we store that patch in icevision. Anny suggestions?

0reactions
potipotcommented, Mar 6, 2021

The problem is that the test dataset (fridge_ds) has only 1 element in the validation set. Therefore I cannot test which list corresponds to the actual batch size, as it is always 1. 😄 I will increase the size of validation set to say 3 and then test again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'NoneType' object has no attribute 'shape'
My data is organised as: train:- containing folder for each class valid :- containing folder for each class test:- contains all test images ......
Read more >
Evaluate kitti--AttributeError: 'NoneType' object has no ...
When I try to evaluate the kitti dataset as is said in the GETTING_STARTED.MD , some problems occured during the running step just...
Read more >
NoneType' object has no attribute 'shape - Stack Overflow
I am trying to do my detection but dont know why this error is comming up dont know whats the issue with this...
Read more >
Attributeerror: 'nonetype' object has no attribute 'shape'
The error thus is a result of trying to access the 'shape' of an image that does not exist in the first value...
Read more >
AttributeError: 'NoneType' object has no attribute 'dtype'
When trying to start the Training, I get the following Error: AttributeError: 'NoneType' object has no attribute 'dtype'. You can find the code ......
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