jveitchmichaelis / deeplabel

A cross-platform desktop image annotation tool for machine learning
207 stars 40 forks source link

Use yolov4 train - it shows Wrong annotation #12

Closed brianng0305 closed 4 years ago

brianng0305 commented 4 years ago

Sir,

System: darknet, yolov4

Concrening with the darknet labels export, I set the Names.file as obj.names and export labels. I used the exported labels files for the yolov4 training, after loaded the model, it show error as below.

[yolo] params: iou loss: ciou (4), iou_norm: 0.07, cls_norm: 1.00, scale_x_y: 1.05 nms_kind: greedynms (1), beta = 0.600000 Total BFLOPS 59.636 avg_outputs = 491093 Allocate additional workspace_size = 52.43 MB Loading weights from /home/brian/yolo/layout/yolov4.conv.137... seen 64, trained: 0 K-images (0 Kilo-batches_64) Done! Loaded 137 layers from weights-file Learning Rate: 0.001, Momentum: 0.949, Decay: 0.0005 If error occurs - run training with flag: -dont_show Resizing, random_coef = 1.40

608 x 608 Create 6 permanent cpu-threads

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/1.txt . . . Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/2.txt

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/3.txt

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/4.txt

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/5.txt

Wrong annotation: x = 0, y = 0, < 0 or > 1, file: /home/brian/yolo/layout/output/train/6.txt

So I stopped the training. why the annotation are wrong?

jveitchmichaelis commented 4 years ago

Are all your labels zero or only some?

brianng0305 commented 4 years ago

All labels zero

jveitchmichaelis commented 4 years ago

I can't really give you any help without seeing either your dataset, or the label database you're using. If all your labels are zero then something odd is happening. In the past we've seen issues where one or two labels were placed at the origin as a bug, but never the whole set.

Can you paste an example exported label file?

brianng0305 commented 4 years ago

7 0 0 0 0 7 0.784314 0.0560928 0.0896359 0.065764 7 0.0504202 0.0580271 0.0756303 0.0580271 5 0 0 0 0 5 0.798319 0.628627 0.137255 0.0773694 0 0 0 0 0 8 0 0 0 0 8 0 0 0 0 8 0.918768 0.804642 0.0980392 0.0812379 4 0 0 0 0 4 0.913165 0.93617 0.0868347 0.065764 6 0 0 0 0 6 0.535014 0.943907 0.117647 0.0676983 7 0 0 0 0 7 0.52381 0.804642 0.092437 0.0851064 1 0 0 0 0 1 0.154062 0.663443 0.114846 0.0870406 8 0 0 0 0 8 0.162465 0.808511 0.123249 0.0909091

jveitchmichaelis commented 4 years ago

Ok, I suspect this is a bug. I can probably add a check to ignore labels with zero coords. You're building from source I guess, so if I push something quickly you should just be able to rebuild.

Did you do something like tracking? It's odd that you have lots of duplicated labels with zero coords in them.

This should be handled by this, by the way: https://github.com/jveitchmichaelis/deeplabel/commit/ecc24c5d6c36818f6ab29c4817a4b045dc25c5c8

Can check one of your images - does deeplabel show more bounding boxes than you have labelled? For example you label 4 things and it shows 8.

brianng0305 commented 4 years ago

Yes. I did tracking.(since I am not familiar with the software)

jveitchmichaelis commented 4 years ago

Ok, and you're working on a video sequence? You shouldn't be using tracking for other datasets.

brianng0305 commented 4 years ago

Can check one of your images - does deeplabel show more bounding boxes than you have labelled? For example you label 4 things and it shows 8. <- yes

brianng0305 commented 4 years ago

Ok, and you're working on a video sequence? You shouldn't be using tracking for other datasets. <- Got it. Thank you very much

jveitchmichaelis commented 4 years ago

Just to check, do you have the latest version of the code? e.g. run git pull

It's odd that you get zero area bounding boxes, because that error should be caught (i.e. they should never be saved in the first place).

I can add a very simple check in the exporter to skip these boxes, but that doesn't solve the root of the problem. For now just add:

            // Ignore labels with zero area
            if(label.rect.width()*label.rect.height() <= 0 ){
                continue;
            }

In darknetexporter.cpp around line 50. e.g.


  // Delete existing files for simplicity.
    if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
        BoundingBox label;
        foreach(label, labels){
            QString text;

            // Check if this label exists in the database
            if(id_map.find(label.classname.toLower()) == id_map.end()){
                qDebug() << "Couldn't find this label in the names file: " << label.classname.toLower();
                continue;
            }

            // Ignore labels with zero area
            if(label.rect.width()*label.rect.height() <= 0 ){
                continue;
            }

         .....
brianng0305 commented 4 years ago

the annotations files are correct now but it shows error:

libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile . . .

I may git clone this and re-build the files. (I am using the deeplabel 0.12 version)

jveitchmichaelis commented 4 years ago

Yes, I'd recommend building from master.

Not sure about the pngs. Deeplabel just copies images on export. Probably you can ignore it? Is that a warning in darknet or deeplabel?

brianng0305 commented 4 years ago

Yes. It highly propobly is the warning from darknet. I may use yolov3 model to try. It seems better.

jveitchmichaelis commented 4 years ago

Can you build from master to check if that solves your label issue? Then I can close this, thanks!

brianng0305 commented 4 years ago

Not works. Numbers of bounding boxes and lebals are not matched. I still need to add your code manually for the 'no zero' labels export.

jveitchmichaelis commented 4 years ago

@brianng0305 I've just pushed v0.13 (source only), but give that a go.

Your old project will still have zero-area labels. Deeplabel doesn't (at the moment) have the ability to "clean up" a project. This is just a workaround so that these labels are ignored during load/export. If you start a new project from scratch, these labels won't be saved in the first place (I hope).

https://github.com/jveitchmichaelis/deeplabel/commit/757ecc4259574e886954151a812de2fbe6f4e205

brianng0305 commented 4 years ago

Sir,

Yes. The v0.13 works perfectly and yolo is training the data. Thank you very much.

jveitchmichaelis commented 4 years ago

Awesome, I hope your model trains well! Thanks for being patient.