Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when training custom detection: bounding box values should be in the range 0 - 1 #815

Closed
toolhater opened this issue Jun 7, 2023 · 1 comment

Comments

@toolhater
Copy link

toolhater commented Jun 7, 2023

I'm trying to use the something similar to the example that was given for training a model for custom image detection. I annotate the files in Label Studio and export in yolo format. If I just have one class I dont have a problem. However when I add more than one class, even after update the object_names_array, I get the error in the subject line.

Before we get too far into the weeds I should mention that some of the images I have have more than one class inside them. So if I open the annotation for an image I might see something like this:

1 0.5884861407249463 0.6983273596176822 0.823027718550106 0.4074074074074073
0 0.5127931769722814 0.5173237753882914 0.9744136460554371 0.9653524492234169

The first number is the I think represents a mapping to the classes. Indeed, there is a notes.json file that has this info:

{
"categories": [
{
"id": 0,
"name": "dogs"
},
{
"id": 1,
"name": "cats"
},
{
"id": 2,
"name": "birds"
}
],
"info": {
"year": 2023,
"version": "1.0",
"contributor": "Label Studio"
}
}

Should I be trying to export this in another format or does imageAI only expect one class per annotation file? Also ran a loop and read all the annotations and didn't find one value in the box, not the class, that had a value less than 0 or greater than 1.

Any help would be appreciated.

@toolhater
Copy link
Author

I've found the error. After taking out some of the code and running it against the list of items I was trying to load, I found two items that had values =1. In those cases, when I looked at the labeling, the line was exactly on the end of the image, Once I closed the rectangle a tad the problem was fixed.

Looping through the folder where my annotations were I used this code:

l = np.loadtxt(f'{directory}{file_name}').reshape(-1, 5)

#     try:
#         assert (l[:, 1:] <= 1).all(), f"bounding box values should be in the range 0 - 1 {file_name}"
#     except AssertionError as ex:
#         print(file_name)
#         print(l)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant