Random model training error

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Random model training error

Finest Сasual Dating - Authentic Ladies

Post by matchquatt » Tue Feb 06, 2024, 18:56

Casual dating at its finest – join the leading platform for relaxed and fun encounters!
Authentic Damsels


Exemplary Сasual Dating

Re: Random model training error

Post by Creator » Sat Aug 19, 2017, 00:02

yes, the problem lies in your ground truth image.
One mistake could appear during the automatic conversion from RGB to grayscale image (desaturation). Here different colors may be converted to the same gray value, e.g. color (255, 0, 0) and color (0, 255, 0) by many desaturation algorithms are converted to the same value 128.
Another mistake might appear during automatic image normalization to the range of [0; 6). I think that at this stage all the values were mapped to zero.

In order to check if it is true and fix the problem, please convert one ground truth image manually, using Photoshop or gimp, or other image editing software. Just fill the colors you have with new colors (0,0,0), (1,1,1),...(5,5,5) and then convert the image to a one-channel bmp or png format (ground truth should be stored in a loseless image format).

Re: Random model training error

Post by Bryan » Mon Aug 14, 2017, 09:09

Thank you for your reply! I have tried the first solution and command parameters are set to "5 1 KTesting_07.jpg feature.jpg NormalGrayKTesting_07.jpg result.jpg KTraining_07_mask.tif". The result is showed in the attachment.
From the result.jpg and RunningResult.png, I think my ground truth has something wrong. I convert NormalGrayKTesting_07.jpg (ground truth pic, RGB image) to grey (one channel) and normalize its channel value to 0 to 6. Thus, it seems like a totally dark image. As can be seen, status[0] has 50790 of 50790 samples and others are zero. I don't know why.
Attachments
RunningResult.PNG
result.jpg
result.jpg (69.04 KiB) Viewed 13473 times

Re: Random model training error

Post by Creator » Fri Aug 11, 2017, 21:25

I use mask when the original image needs to choose ROI. For instance, the picture in the attachment has building, road and so on corresponding to white area of the second picture. Hence I don't need to extract features of original image in black and to train black areas.

Now I understand the purpose of the mask. Currently, the mask functionality is not implemented in the DGM library. Thus, you have to handle this problem manually. Here I would suggest two options:
  1. If you use the code from demo train, then you probably use the block training for the nodes with the macros

    Code: Select all

    nodeTrainer->addFeatureVec(fv, gt);

    Instead of using this macros, you should use the complete per-pixel form of the training. Please see the example code below:

    Code: Select all

    Mat vec(fv.channels(), 1, CV_8UC1); 
    for (int y = 0; y < gt.rows; y++) { 
        byte *pFV = fv.ptr<byte>(y);   
        byte *pGT = gt.ptr<byte>(y);   
        byte *pMask = mask.ptr<byte>(y);
        for (int x = 0; x < gt.cols; x++) {   
            if (mPask[x] == 0) continue;
            for (int f = 0; f < vec.rows; f++) vec.at<byte>(f, 0) = pFV[vec.rows * x + f];       
            nodeTrainer->addFeatureVec(vec, pGT[x]);   
        } // x   
    } // y   
  2. Another option, you can modify the DGM functions addFeatureVec() in the TrainNode.cpp and macroses.h by adding one extra argument const Mat &mask and then submit it back to GitHub.

I am not sure about the fourth suggestion you gave. I have changed the ground truth pic to a pic with one-channel whose value is from 0 to 6. However there is still a error saying vector iterator not decrementable.

Please try first with incorporating the code from the first point above. Check that it produces the same results as using the nodeTrainer->addFeatureVec(fv, gt); function on the original tutorial images. Then use your data, and if the error appears again, please write me back with more details on the error, i.e. where exactly it appears, what is the debug data, like the length of the vector and the value of its iterator when debugging is stopped.

Re: Random model training error

Post by Bryan » Mon Aug 07, 2017, 08:59

I use mask when the original image needs to choose ROI. For instance, the picture in the attachment has building, road and so on corresponding to white area of the second picture. Hence I don't need to extract features of original image in black and to train black areas.
I am not sure about the fourth suggestion you gave. I have changed the ground truth pic to a pic with one-channel whose value is from 0 to 6. However there is still a error saying vector iterator not decrementable.
Attachments
KTesting_02_mask.jpg
The Mask
KTesting_02.jpg
Input Image

Re: Random model training error

Post by Creator » Sun Jul 30, 2017, 21:43

Hi Bryan,
here are the answers to your questions:
  1. The ordinary image (I assume, it is a 3-channel RGB image) will be considered as 3 distinct features. The DGM algorithms will work with that data, but there are some issues:

    • Using different features will lead to slightly different results (in terms of classification accuracy)
    • Using original images instead of extracted features usually gives poor results
    • For betters results it is better to use more than 3 different features, for road extraction tasks, the number of features should be at least 16
  2. The ground truth image should be an 1-channel image, with the colors (i.e. gray values) equal to the class IDs.
  3. I am not sure if I understood this question right. For which purpose do you want to use the mask?
  4. The error says, that you have defined, that you have 6 classes. But during the training, you try to feed a trainer algorithm with a sample, corresponding to class 76. But the valid values for the ground truth classes are 0, 1, 2, 3, 4, 5. I think, here you have a problem with the ground-truth image (please ref. to answer 2). Your ground truth image is defined by colors, so you should convert it to a 1-channel image with class indexes instead of colors.

Random model training error

Post by Bryan » Sat Jul 29, 2017, 00:26

Hi! I have some problems to consult you. I run the demo train.cpp program using pictures in the attachment. However, the abortion occurs and the reminder is showed following:

Building the Graph... Done! (4285.328649ms)
Training... Assertion failed: gt < m_nStates in "E:\DGM_Feature\DGM\modules\DGM\TrainNodeGMM.cpp", line 47
The groundtruth value 76 is out of range [0; 6)

  1. If the original image is ordinary image, it would influence the result?
  2. The ground Truth image is drawn by human with different color?
  3. How to add a mask for the original image when running feature extract.cpp and obtaining feature.jpg
  4. What is wrong with the error?
Attachments
KTesting_07.jpg
original image
GroundTruth_07.jpg
groundtruth
feature.jpg
feature

Top