0chil/YOLO-TO-AUTOML

Conversion seems to break on locales using different decimal separator

Opened this issue · 2 comments

In my locale (German) comma is the decimal separator and a dot is a grouping separator. To give an example, 5001/4 evaluates to the string "1.250,25" or "1250,25" rather than "1,250.25" or "1250.25". I suspect somewhere in your code where the txt files are imported the current locale is applied to interpret floating point values. Thus the following annotation row in the yolo txt
0 0.47488839285714285 0.8655133928571429 0.13058035714285715 0.13504464285714285
seems to be converted to the csv line:
<...>,4,09598214285714E+16,1,90290178571429E+15,5,40178571428571E+16,1,90290178571429E+15,5,40178571428571E+16,1,54073660714286E+16,4,09598214285714E+16,1,54073660714286E+16

I found possible solutions on Stack Overflow:

NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
value.ToString(nfi);

https://stackoverflow.com/a/18377793/5773561

And to parse the value correctly from a string:

double someNumber = double.Parse(numberString,nfi);

A more general, imo not so nice, approach:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

https://stackoverflow.com/a/18424480/5773561

0chil commented

@Octribin Apologies for my insensibility and thank you so much for giving this old repository some detailed suggestions.
Actually, I was away from this repository and was not able to check its issues.
Even if it's quite late, I will take a look at your issues any time possible.