Read the buffer data recuperated from NvDsInferLayerInfo (in Python)

In python I recuperated the output layer of a classifier using the same method presented here: Get class_probabilities_map from segmentation task - #3 by mchi

But I cannot read the buffer data containing the output layer values. This data is NvDsInferLayerInfo :NVIDIA DeepStream SDK API Reference: Main Page

How to read this buffer data in Python?

This is the setup of my Xavier NX:

  • NVIDIA Jetson Xavier NX (Developer Kit Version)
    • Jetpack UNKNOWN [L4T 32.4.4]
    • NV Power Mode: MODE_15W_6CORE - Type: 2
    • jetson_stats.service: active
  • Libraries:
    • CUDA: 10.2.89
    • cuDNN: 8.0.0.180
    • TensorRT: 7.1.3.0
    • Visionworks: 1.6.0.501
    • OpenCV: 4.1.1 compiled CUDA: NO
    • VPI: 0.4.4
    • Vulkan: 1.2.70

As asked in another topic, please provide setup info.

Thanks for your reply. I added the setup information.

How to read this buffer data in Python?

what’s the relation of this topic with Get the full vector of probabilities for every class for one classifier in DeepStream - #11 by mchi ?

The previous topic is general. This one is specific on one method of getting the output vector.
Could you help me with this issue: How to read the buffer data from NvDsInferLayerInfo in Python?

In C, it is done like this to get the different probabilities for every class (from the example deepstream_infer_tensor_meta_test.cpp) :

    float *outputCoverageBuffer = (float *) meta->output_layers_info[0].buffer;
    float maxProbability = 0;
    bool attrFound = false;
    NvDsInferAttribute attr;

    /* Iterate through all the probabilities that the object belongs to
     * each class. Find the maximum probability and the corresponding class
     * which meets the minimum threshold. */
    for (unsigned int c = 0; c < numClasses; c++) {
      float probability = outputCoverageBuffer[c];
      if (probability > 0.51 && probability > maxProbability) {
        maxProbability = probability;
        attrFound = true;
        attr.attributeIndex = 0;
        attr.attributeValue = c;
        attr.attributeConfidence = probability;
      }
    }

In Python, the buffer is of type PyCapsule. tried to read it using the instruction:

jetson.utils.cudaToNumpy(layers_info[0].buffer)

but got this error:

Exception: jetson.utils – cudaToNumpy() failed to get input CUDA pointer from first arg (should be cudaImage or cudaMemory)

How to read this buffer?

Hi @bilel_bj,
Sorry for long delay!
Do you still need help for this issue?

No, thanks.

1 Like