Getting Issue in extracting classifier label in deepstream-imagedata-multistream python test application in DS-5

Hi,

Hardware and Software Details :
Device : Jetson NX-Xavier.
Package: nvidia-jetpack
Version: 4.4.1-b50
Architecture: arm64
TensorRT : 7.1.3-1+cuda10.2
Deepstream : 5

Problem :

I am using deepstream-imagedata-multistream python test application in DS-5.

In some other DS application with C code mention below I am able to get the result of classifier (label_info->result_label).

    for (l_class = obj_meta->classifier_meta_list; l_class != NULL;
               l_class = l_class->next) {
            class_meta = (NvDsClassifierMeta *)(l_class->data);
    	if (!class_meta)
              continue;
            if (class_meta->unique_component_id == SECONDARY_CLASSIFIER_UID) {
              for ( label_i = 0, l_label = class_meta->label_info_list;
                label_i < class_meta->num_labels && l_label; label_i++,
                l_label = l_label->next) {
    	    label_info = (NvDsLabelInfo *)(l_label->data);
    	    if (label_info) {
    	      if (label_info->label_id == 0 && label_info->result_class_id == 1) {
    	        **g_print ("Plate License %s\n",label_info->result_label);**
    	      }
    	    }
    	  }
    	}

For above code I am getting correct output as expected Plate License 113BJ375

but when I am implementing in python I am getting different result.

while l_class is not None:
                class_meta =  pyds.NvDsClassifierMeta.cast(l_class.data)
                if class_meta.unique_component_id == SECONDARY_CLASSIFIER_UID:
                    label_i = 0
                    l_label = class_meta.label_info_list
                    # print("l_label is :",l_label)
                    while l_label is not None:
                        if label_i < class_meta.num_labels:
                            label_info = pyds.NvDsLabelInfo.cast(l_label.data)
                            # print(" result_prob : ",label_info.result_prob)
                            if label_info.label_id == 0 and label_info.result_class_id == 1:
                                #number_plate = np.array2string(label_info.result_label)
                                #print(" number_plate :  ",number_plate)
                                print("Number Plate : %s"%label_info.result_label)

                        label_i += 1
                        try:
                            l_label = l_label.next
                        except StopIteration:
                            break
                try:
                    l_class = l_class.next
                except StopIteration:
                    break

For this code I am getting result like

[ 910445127 875647826 56 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 1
0 1065242403 0 65 0 877607360
127 875747280 127 0 0 0
0 0 0 0 0 64
0 164 0 130 0 631995120
0 0 0 0 0 139
0 60 0 0 1072693248 0
0 140 0 40 0 0
0 0 0 141 0 44
0 858303104 101 0 0 0
0 0 0 160 0 1029
0 0 0 0 0 0
0 0 0 0 0 0
0 632937808 0 1 0 0
0 -1924651544 127 0 0 -1924651120
127 0 0 0 0 48641
0 -1]

please help me out so that I can get the same result as I am getting in the C code.

Thanks.

Hey customer, what’s the log you shared is from? from print("Number Plate : %s"%label_info.result_label) ?

Thanks @bcao for response.
Yes the log which I had shared is from print("Number Plate : %s"%label_info.result_label) .

OK, would you mind to share a whole repro with us, so I can debug locally.
BTW, you are using DS 5.0 or DS5.1?

Code Repo : GitHub - NVIDIA-AI-IOT/deepstream_lpr_app: Sample app code for LPR deployment on DeepStream
I am converting this into python and Have done that but getting issue in extracting Number plate text as mentioned above in problem statement.
I am using DS-5.0.

Ok, actually, I mean can you share your python version code with us to repro locally, the whole setup, so I can do a debug quickly.

Below is the modified file:
anpr_custom_impl.py (18.7 KB)

Thanks, will check and let you know.

Thanks @bcao
Please let me know once you check that.

Hello @bcao any updates on this. How can I resolve this issue ?
Please help.

Sorry for the late, we are checking internally.

Thanks for the reply.
Please let me know once you checked it, I am stuck at this problem since last 4 days.

Hey, have you tried to add some log inside the nvinfer_custom_lpr_parser.cpp to see if there is any difference between c and python

Hi @bcao Thanks for the response.

I have resolved this issue by converting label_info.result_label into string.
number_plate = (label_info.result_label).tostring()
number_plate = codecs.decode(number_plate, ‘ISO-8859-1’)

Great work, then you can mark your comment as the solution.