Ssd.pytorch: got this Error while training on standard data

Created on 3 Apr 2018  路  13Comments  路  Source: amdegroot/ssd.pytorch

got this Error while training in the 510 iteration:
""" File "train.py", line 255, in
train()
File "train.py", line 165, in train
images, targets = next(batch_iterator)
File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 271, in __next__
raise StopIteration
StopIteration
"""
what may be causing it?

Most helpful comment

Iteration is supposed to go to 120000.
My "fix" was stopping after 510 iterations

Hence I have now changed line in train.py from:
    images, targets = next(batch_iterator)
to:
    try:
        images, targets = next(batch_iterator)
    except StopIteration:
        batch_iterator = iter(data_loader)
        images, targets = next(batch_iterator)

Will see if the evaluation improves...

All 13 comments

I met the same problem

I met the same problem

I have the same problem.
Please note: I am a bit of a novice at this - I have never tried to "fix" anything before...
Also had one other issue, had to copy ssd.pytorch-master/data/coco/coco_labels.txt to data/coco/
(who knows what that did)

I tried this, and it seems to work (maybe):
I altered line in file train.py:
images, targets = next(batch_iterator)
to:
try:
images, targets = next(batch_iterator)
except StopIteration:
print('Batch complete')
break

To my surprise it created weights/VOC.pth file!!!
Then I merrily ran: python3 eval.py --trained_model weights/VOC.pth
It takes a while to plough through 4952 images...

I got: Mean AP = 0.0112
I think that is too low - hence I don't think I created a "fix"...
So I downloaded weights/ssd300_mAP_77.43_v2.pth
And ran: python3 eval.py
It runs quite a bit faster...
It got: Mean AP = 0.7749
Conclusion: My "fix" did not work, but it was fun while it lasted...

Now we wait for someone that knows something to help us...

Iteration is supposed to go to 120000.
My "fix" was stopping after 510 iterations

Hence I have now changed line in train.py from:
    images, targets = next(batch_iterator)
to:
    try:
        images, targets = next(batch_iterator)
    except StopIteration:
        batch_iterator = iter(data_loader)
        images, targets = next(batch_iterator)

Will see if the evaluation improves...

The problem is not to iterate data_loader.
For the time being, you could fix it with

  batch_iterator = None
  for iteration in range(args.start_iter, cfg['max_iter']):
        if (not batch_iterator) or (iteration % epoch_size ==0):
            batch_iterator = iter(data_loader)
            loc_loss = 0
            conf_loss = 0
            epoch += 1

@rbackman22 YEAH!! it works for me .I am waiting for the result.

it's work for me too.Thank you very much!

This also solve my problem. You are awesome man!

@rbackman22 @Usernamezhx Hey guys, how is it going? Did you guys get better results and faster inference speed after change the try expect part?

"""
I got: Mean AP = 0.0112
I think that is too low - hence I don't think I created a "fix"...
"""

@rbackman22 It works! thank you

The problem is not to iterate data_loader.
For the time being, you could fix it with

  batch_iterator = None
  for iteration in range(args.start_iter, cfg['max_iter']):
        if (not batch_iterator) or (iteration % epoch_size ==0):
            batch_iterator = iter(data_loader)
            loc_loss = 0
            conf_loss = 0
            epoch += 1

This should be the correct answer

I have the same problem.
Please note: I am a bit of a novice at this - I have never tried to "fix" anything before...
Also had one other issue, had to copy ssd.pytorch-master/data/coco/coco_labels.txt to data/coco/
(who knows what that did)

I tried this, and it seems to work (maybe):
I altered line in file train.py:
images, targets = next(batch_iterator)
to:
try:
images, targets = next(batch_iterator)
except StopIteration:
print('Batch complete')
break

To my surprise it created weights/VOC.pth file!!!
Then I merrily ran: python3 eval.py --trained_model weights/VOC.pth
It takes a while to plough through 4952 images...

I got: Mean AP = 0.0112
I think that is too low - hence I don't think I created a "fix"...
So I downloaded weights/ssd300_mAP_77.43_v2.pth
And ran: python3 eval.py
It runs quite a bit faster...
It got: Mean AP = 0.7749
Conclusion: My "fix" did not work, but it was fun while it lasted...

Now we wait for someone that knows something to help us...

HEY,did you work out it? I got the same problem and cannot found some wrong with it?

@small-mayfly HEY,have you solved it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oarriaga picture oarriaga  路  4Comments

luhc15 picture luhc15  路  6Comments

oarriaga picture oarriaga  路  4Comments

LAWSSSS picture LAWSSSS  路  4Comments

DHZS picture DHZS  路  5Comments