imglab icon indicating copy to clipboard operation
imglab copied to clipboard

Issues with generated XML file

Open offchan42 opened this issue 6 years ago • 19 comments

  1. Output from your software is floating point values for x,y but dlib requires them to be integers.
  2. Encoding of the file does not match dlib. You output UTF-8 and the first line of the XML is buggy (dlib yelled error at the first line of the XML when training). But dlib requires encoding of ISO-xxxxx

Please fix this if possible.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

offchan42 avatar Jun 30 '18 12:06 offchan42

Thanks to report an issue. Can you please confirm which version of imglab are you trying?

amitguptagwl avatar Jun 30 '18 12:06 amitguptagwl

https://naturalintelligence.github.io/imglab/

offchan42 avatar Jun 30 '18 12:06 offchan42

this is v1. We're no longer doing any change on v1. All the bugs will be fixed at v2

https://naturalintelligence.github.io/imglab/v2.html

I most probably will make it live on Monday. And will also fix your bug there.

amitguptagwl avatar Jun 30 '18 13:06 amitguptagwl

Is v2 usable now?

On Sat, Jun 30, 2018 at 8:08 PM Amit Gupta [email protected] wrote:

this is v1. We're no longer doing any change on v1. All the bugs will be fixed at v2

https://naturalintelligence.github.io/imglab/v2.html

I most probably will make it live on Monday. And will also fix your bug there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NaturalIntelligence/imglab/issues/56#issuecomment-401540208, or mute the thread https://github.com/notifications/unsubscribe-auth/AOgsdFHsDZbA2MHo2lPsPUIyiPIQFccAks5uB3g0gaJpZM4U9816 .

-- Best regards, Chanchana

offchan42 avatar Jun 30 '18 13:06 offchan42

It has most of the features supported by v1. However some necessary features are expected to be completed by Monday.

Have a look and tell us if you miss something there.

amitguptagwl avatar Jun 30 '18 14:06 amitguptagwl

@off99555 point 1 is fixed in v2. I need more detail for point 2. As I can see the correct result.

Please try v2 only.

amitguptagwl avatar Jul 02 '18 03:07 amitguptagwl

You could try training in dlib train_shape_predictor and you would see the error. The text doesn't look suspicious but the BOM utf8 encoding is. From looking at the file using the eyes, there is no issue, but it didn't work in dlib. So you should try with dlib trainer first.

offchan42 avatar Jul 02 '18 09:07 offchan42

I've fixed the changes as per your suggestion. Please test it and let me know.

amitguptagwl avatar Jul 03 '18 05:07 amitguptagwl

v2 link is down

offchan42 avatar Jul 03 '18 10:07 offchan42

I've make the v2 live now. So you need not to append v2.html in last.

amitguptagwl avatar Jul 03 '18 10:07 amitguptagwl

@off99555 I'm expecting that your problem must have been resolved. If not, please reopen the issue or raise new one for other issues.

amitguptagwl avatar Jul 05 '18 01:07 amitguptagwl

(I was going to file this as a new bug, but instead, this bug should be reopened.)

Better Bug Description

Output for box should be converted to integers (floor, ceil, round) as appropriate for dlib. The library dlib apparently does not like non-integral coordinates. I got this error msg when running their example code with the XML output file generated by imglab:

./dnn_mmod_train_find_cars_ex ~/Pictures/sc/
Error on line 96: string cast error: invalid string = '35.71428571428571'

This makes sense, in that dlib looks at entire pixels, not fractional ones. (Although, I suppose one could argue that dlib should be more robust.)

My XML file that I created has this line in it:

<box top='35.71428571428571' left='62.85714285714285' width='509.99999999999994' height='1257.1428571428569'>

To Reproduce Steps to reproduce the behavior:

  1. Load a picture
  2. zoom in (I think this is what creates fractional pixel coordinates).
  3. mark a bounding box with a rectangle
  4. export data to dlib training.xml
  5. try running the dnn_mmod_train_find_cars_ex with the directory containing the XML file and images.

Screenshots

Console Errors N/A because the XML errors that are created affect dlib processing, well after imglab is finished.

**Device detail

  • Mac OS 10.14.4 (18E226)
  • Version 74.0.3729.169 (Official Build) (64-bit)
  • For imglab,
git log
commit 62eaeba4e41bc6f84e1113b8dc75053bbd692e18 
Author: Amit Gupta <[email protected]>
Date:   Thu Nov 29 13:32:43 2018 +0530

For dlib

git log 
commit dbe569a1f1808756016b50310dc273ce8848e0b3
Author: Adrià Arrufat <[email protected]>
Date:   Mon May 6 01:07:51 2019 +0900

Additional context I believe the problem is in file imglab/dataformaters/dlib.js

line 34: imgXMLStr += "\t\t<box top='"+box.y+"' left='"+box.x+"' width='"+box.w+"' height='"+box.h+"'>\n";

which does not do any rounding. The fix should be:

imgXMLStr += "\t\t<box top='"+Math.floor(box.y)+"' left='"+Math.floor(box.x)+"' width='"+Math.ceil(box.w)+"' height='"+Math.ceil(box.h)+"'>\n";

(I'm assuming it's better to expand the box outwards)

Notice in the code, that the part coordinates are rounded down (with Math.floor). I think it's better to use Math.round instead.

        for(var shape_i in shapes){
            var box = shapes [ shape_i ].bbox;
            imgXMLStr += "\t\t<box top='"+box.y+"' left='"+box.x+"' width='"+box.w+"' height='"+box.h+"'>\n";
            imgXMLStr += "\t\t\t<label>"+ shapes [ shape_i ].label +"</label>\n";
            //Add points
            var fPoints = shapes [ shape_i ].featurePoints;

            for(var fPoint_i in fPoints){
		var label = fPoints[ fPoint_i ].label;

		console.log(label);
                var fPoint = fPoints [ fPoint_i ];
                //TODO: pad fPoint_i
                imgXMLStr += "\t\t\t<part name='"+ fPoint_i +"' x='"+ Math.floor(fPoint.x)+"' y='"+ Math.floor(fPoint.y) +"'/>\n";

            }

gitclem avatar May 24 '19 22:05 gitclem

Thanks for reporting. Though, reopning. It's better to create new issue.

amitguptagwl avatar May 30 '19 01:05 amitguptagwl

Rats... in another github project, they wanted me not to create a new issue.... but rather reopen an old one.

gitclem avatar Jun 04 '19 22:06 gitclem

Any live link to V2?

blueclowd avatar Jun 26 '19 08:06 blueclowd

v2 is live. v1 has been removed. So no separate link for v2

amitguptagwl avatar Jun 28 '19 04:06 amitguptagwl

May I know if the current link is https://imglab.in/ ?

I tried but still got floating point in the dlib xml. Any ideas?

blueclowd avatar Jul 11 '19 04:07 blueclowd

May I know if the current link is https://imglab.in/ ?

I tried but still got floating point in the dlib xml. Any ideas?

See my comment above from May 24. A Math.round is(was) missing.

gitclem avatar Jul 15 '19 16:07 gitclem

@gitclem implemented your changes @blueclowd please check if your issue is fixed.

amitguptagwl avatar Jul 27 '19 16:07 amitguptagwl