Pango-WARNING **: 12:56:28.228: Invalid UTF-8 string passed to pango_layout_set_text()

Hello when i custom parser classifier by function:

bool NvDsInferClassiferParseCustomSoftmax (std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
        NvDsInferNetworkInfo  const &networkInfo,
        float classifierThreshold,
        std::vector<NvDsInferAttribute> &attrList,
        std::string &descString)
{
    /* Get the number of attributes supported by the classifier. */
    unsigned int batch_size = outputLayersInfo.size();

    /* Iterate through all the output coverage layers of the classifier.
    */
    for (unsigned int l = 0; l < batch_size; l++)
    {
        /* outputCoverageBuffer for classifiers is usually a softmax layer.
         * The layer is an array of probabilities of the object belonging
         * to each class with each probability being in the range [0,1] and
         * sum all probabilities will be 1.
         */
        unsigned int numClasses = int(labels[l].size()) + 1;
//        printf("%d",numClasses); 32
        NvDsInferDimsCHW dims;

        getDimsCHWFromDims(dims, outputLayersInfo[l].inferDims);
        unsigned int Timestep = dims.c; //27

        float *outputCoverageBuffer = (float *)outputLayersInfo[l].buffer;
        bool attrFound = false;
        NvDsInferAttribute attr;
        std::string perdictext;
        std::list <int> objList;

        for (unsigned int k = 2; k < Timestep; k++)
        {
            float maxPixelValue = 0;
            float curPixelValue = 0;
            unsigned int index;

            for (unsigned int c = k*numClasses; c < (k+1)*numClasses; c++)
            {
                curPixelValue = outputCoverageBuffer[c];
                if (curPixelValue > maxPixelValue)
                {
                    maxPixelValue = curPixelValue;
                    index = c - k*numClasses;
                }
            }
            objList.push_back(index);
        }

        std::list<int>::iterator oldIndx;
        std::list<int>::iterator curIndx;
        std::list<int> objListRemoveOverloop;

        for (int idx = 0 ; idx < int(objList.size()); idx++){
            curIndx = std::next(objList.begin(), idx);
            if (idx == 0){
                objListRemoveOverloop.push_back(*curIndx);
                oldIndx = curIndx;
            }
            else{
                if (curIndx != oldIndx){
                    objListRemoveOverloop.push_back(*curIndx);
                    oldIndx = curIndx;
                }
            }
        }

        std::list<int>::iterator curI;

        for (int i = 0 ; i < int(objListRemoveOverloop.size()); i++){
            curI = std::next(objListRemoveOverloop.begin(), i);
            if (*curI < int(labels[l].size())){
                perdictext.append(labels[l][*curI]);
                attrFound = true;
                attr.attributeIndex = l;
                attr.attributeValue = 0;
                attr.attributeConfidence = 1.0;
            }
        }

        std::cout << ' ' << perdictext;

         if (attrFound)
        {
            attr.attributeLabel = perdictext.c_str();
            //attr.attributeLabel = labels[l][1].c_str();
            attrList.push_back(attr);
            if (attr.attributeLabel)
                descString.append(attr.attributeLabel).append(" ");
        }

    }

    return true;
}

there is an error with label show object and on terminal show:

Pango-WARNING **: 12:56:28.228: Invalid UTF-8 string passed to pango_layout_set_text()

how to fix it

Hi,
I am trying to run with your code, but made some changes, besides some compile error, one change is add belowing within function bool NvDsInferClassiferParseCustomSoftmax (std::vector const &outputLayersInfo,
NvDsInferNetworkInfo const &networkInfo,
float classifierThreshold,
std::vector &attrList,
std::string &descString)

static std::vector < std::vector< std:: string > > labels { {
“coupe1”, “largevehicle1”, “sedan1”, “suv1”, “truck1”, “van1”} };
I am using builtin resnet18 model.

1 Like

nvdsinfer_customclassifierparser.cpp (5.2 KB)
this my file, my output format: 1x27x32

Hi
But i changed to use your source, also can not repro your error, just save one pictue, see attached, from the pircture, you can see the character you used go into the lable. if you still not sove it, please specify details how to repro uncluding the config you used.

1 Like

Hi you, i had solved the problem.
Thank you for help