detecto icon indicating copy to clipboard operation
detecto copied to clipboard

All bounding boxes should have positive height and width

Open ghost opened this issue 5 years ago • 6 comments

Describe the bug I created a dataset that already worked with TensorFlow. For some reason, it raises this error when trying to train a model.

Code and Data `from detecto import core, utils, visualize

dataset = core.Dataset('analyzepage/') model = core.Model(['taskRegion', 'pageCount', 'infoText', 'separateImage', 'element'])

model.fit(dataset)`

Environment:

  • OS: Windows 10
  • Python version: 3.6
  • Detecto version: 1.1.6
  • torch version: -
  • torchvision version: -

Additional context Add any other context about the problem here.

ghost avatar Oct 23 '20 12:10 ghost

Could you take a look at #56 and let me know if that helps fix the issue?

alankbi avatar Oct 24 '20 03:10 alankbi

i have the same error and checked the data that xmin<xmax and ymin<ymax but the error still exist ask2 ask51

Esraanageh22 avatar Mar 18 '22 19:03 Esraanageh22

The error in the image you shared seems to suggest there's a box with a width of 0, which would be invalid. If you modify your script to only print when an invalid box is found, do you get any output? It's possible that the box causing the error is getting buried behind the "all data is fine" messages.

for i in range(len(dataset)):
    image, target = dataset[i]
    box = target['boxes']
    if box[0] >= box[2] or box[1] >= box[3]: # min x > max x or min y > max y
        print(i, box)

alankbi avatar Mar 20 '22 17:03 alankbi

the output of width with 0 was nothing that no image with width 0 . there is the output : aee

Esraanageh22 avatar Mar 22 '22 16:03 Esraanageh22

Looks like I made a mistake in my script, my bad - try this instead:

for i in range(len(dataset)):
    image, target = dataset[i]
    boxes = target['boxes']
    for box in boxes:
        if box[0] >= box[2] or box[1] >= box[3]: # min x > max x or min y > max y
            print(i, box)

alankbi avatar Mar 23 '22 02:03 alankbi

oh finally it worked thank you!

Esraanageh22 avatar Mar 23 '22 21:03 Esraanageh22