serhankilicarslan / labelImg-to-csv

LabelImg Data To Automl Vision CSV
GNU General Public License v3.0
4 stars 2 forks source link

Invalid conversion output in large images with small labels #2

Open m0-n opened 4 years ago

m0-n commented 4 years ago

Hi,

first of all, great idea, really like it.

However, I ran into the problem below:

When I import the output CSV to the Google Cloud Vision API, I get the following error, for most - nearly all - lines:

Error: gs://pbottles/labelImg.csv line 70: The bounding box cannot represent a rectangle. Error: gs://pbottles/labelImg.csv line 1037: The bounding box cannot represent a rectangle. Error: gs://pbottles/labelImg.csv line 1165: The bounding box cannot represent a rectangle. ...

The issue seems to be the conversion from absolute pixel values to 0-1 relative values in the script.

For example, this row:

TRAIN,gs://pbottles/013/20200220_164351.jpg,Plastic Bottle,1.00,0.93,,,1.00,0.98,,

Is considered invalid, since 1.0/0.93 and 1.0/0.98 do not form a normal rectangle. Sometimes, the images are very large and the labeled area relatively small, which may have led to the problem.

What to do - maybe add more digits of accuracy e.g. 0.998 instead of 1.00 - what do you think

m0-n commented 4 years ago

I just changed "toFixed(2)" to "toFixed(4)", which now generates correct rectangles. Also did some path fixes/changes in the script. The Vision API is currently reading it in, let us see if it works. Thanks again, that script saved my day :D

serhankilicarslan commented 4 years ago

Hi,

Thanks for your comment. If you pull-request to me for your changes, I can accept it.

Good luck in ai project :)