OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.49k stars 2.18k forks source link

DetectionModelTrainer obj['xmax'] - obj['xmin']) / float(max_anchor.xmax)) # t_w ZeroDivisionError: float division by zero #674

Open lovisio opened 3 years ago

lovisio commented 3 years ago

Hello, I use this https://imageai.readthedocs.io/en/latest/customdetection/index.html to create a new detection. Using Hololens library from example the DetectionModelTrainer working. But using my own data generate from LabelImg, i have this error. " File "C:\Python38\lib\site-packages\imageai\Detection\Custom\generator.py", line 106, in getitem w = np.log((obj['xmax'] - obj['xmin']) / float(max_anchor.xmax)) # t_w ZeroDivisionError: float division by zero"

Do you from where to problem could be ? My data are using only one image ( a plan ) , but with more than 200 markers on it.

ekesdf commented 3 years ago

Can you send in youre annotation file you used for that picture thy

Just rename it as a *.txt and upload it via drag and drop

lovisio commented 3 years ago

I tried even with just one object and i have the error. map-schema19.txt

ekesdf commented 3 years ago

@ehiaig I have found the issue :tada:

The issue is that your bboxes are to small compared to your image size. The ratio is like 0,001801106 for the x_value which is way too small so the custom anchor calculation your model anchors are [0,0,0,0] but it should be more like [50,10,150,110] for example, but tit depends on the ration between the object and the actual image size.

So to accommodate for that you will have to cut your original images in smaller pieces, so the ratio will rise to something around 0.01 a like 832x832 pixel image would be a good size for an image tile for that size of object you want to detect

ekesdf commented 3 years ago

@lovisio did it worked ?