How to get raw output of nvinfer ?

Hi,
I have fully read the release user guide,
I found that there are three ways to get access of the raw data:

way 1.
raw-output-file-write if set this property to true,
deepstream will generate thousands of xxxxxxxxxxxxxxxxx.bin file,
it seems that I have no way to open this binary file,(I have tried vi/vim/gedit or bash it directly)

way 2.
raw-output-generated-callback

the discrible of raw-output-generated-callback is “Pointer to the raw output generated callback function”,
but I could not find a demo demonstration how to use this pointer.

way3.
raw-outputgenerated-userdata
emm. it seems that I have to get the raw-output-generated-callback pointer before I could get it.

Hello,
I have found that,

static void
write_infer_output_to_file (GstBuffer *buf,
    NvDsInferNetworkInfo *network_info,  NvDsInferLayerInfo *layers_info,
    guint num_layers, guint batch_size, gpointer user_data)
{
  NvDsGieConfig *config = (NvDsGieConfig *) user_data;
  guint i;

  /* "gst_buffer_get_nvstream_meta()" can be called on the GstBuffer to get more
   * information about the buffer.*/

  for (i = 0; i < num_layers; i++) {
    NvDsInferLayerInfo *info = &layers_info[i];
    guint element_size = 0;
    FILE *file;
    gchar file_name[PATH_MAX];
    gchar layer_name[128];
    guint j;

    switch (info->dataType) {
      case FLOAT: element_size = 4; break;
      case HALF: element_size = 2; break;
      case INT32: element_size = 4; break;
      case INT8: element_size = 1; break;
    }

    g_strlcpy (layer_name, info->layerName, 128);
    for (j = 0; layer_name[j] != '

static void
write_infer_output_to_file (GstBuffer *buf,
NvDsInferNetworkInfo *network_info, NvDsInferLayerInfo *layers_info,
guint num_layers, guint batch_size, gpointer user_data)
{
NvDsGieConfig *config = (NvDsGieConfig *) user_data;
guint i;

/* “gst_buffer_get_nvstream_meta()” can be called on the GstBuffer to get more

  • information about the buffer.*/

for (i = 0; i < num_layers; i++) {
NvDsInferLayerInfo *info = &layers_info[i];
guint element_size = 0;
FILE *file;
gchar file_name[PATH_MAX];
gchar layer_name[128];
guint j;

switch (info->dataType) {
  case FLOAT: element_size = 4; break;
  case HALF: element_size = 2; break;
  case INT32: element_size = 4; break;
  case INT8: element_size = 1; break;
}

g_strlcpy (layer_name, info->layerName, 128);
for (j = 0; layer_name[j] != '\0'; j++) {
  layer_name[j] = (layer_name[j] == '/') ? '_' : layer_name[j];
}

g_snprintf (file_name, PATH_MAX,
    "%s/%s_batch%010lu_batchsize%02d.bin",
    config->raw_output_directory, layer_name,
    config->file_write_frame_num, batch_size);
file_name[PATH_MAX - 1] = '\0';

file = fopen (file_name, "w");
if (!file) {
  g_printerr ("Could not open file '%s' for writing:%s\n",
      file_name, strerror(errno));
  continue;
}
fwrite (info->buffer, element_size, info->dims.numElements * batch_size, file);
fclose (file);

}
config->file_write_frame_num++;
}

'; j++) {
      layer_name[j] = (layer_name[j] == '/') ? '_' : layer_name[j];
    }

    g_snprintf (file_name, PATH_MAX,
        "%s/%s_batch%010lu_batchsize%02d.bin",
        config->raw_output_directory, layer_name,
        config->file_write_frame_num, batch_size);
    file_name[PATH_MAX - 1] = '

static void
write_infer_output_to_file (GstBuffer *buf,
NvDsInferNetworkInfo *network_info, NvDsInferLayerInfo *layers_info,
guint num_layers, guint batch_size, gpointer user_data)
{
NvDsGieConfig *config = (NvDsGieConfig *) user_data;
guint i;

/* “gst_buffer_get_nvstream_meta()” can be called on the GstBuffer to get more

  • information about the buffer.*/

for (i = 0; i < num_layers; i++) {
NvDsInferLayerInfo *info = &layers_info[i];
guint element_size = 0;
FILE *file;
gchar file_name[PATH_MAX];
gchar layer_name[128];
guint j;

switch (info->dataType) {
  case FLOAT: element_size = 4; break;
  case HALF: element_size = 2; break;
  case INT32: element_size = 4; break;
  case INT8: element_size = 1; break;
}

g_strlcpy (layer_name, info->layerName, 128);
for (j = 0; layer_name[j] != '\0'; j++) {
  layer_name[j] = (layer_name[j] == '/') ? '_' : layer_name[j];
}

g_snprintf (file_name, PATH_MAX,
    "%s/%s_batch%010lu_batchsize%02d.bin",
    config->raw_output_directory, layer_name,
    config->file_write_frame_num, batch_size);
file_name[PATH_MAX - 1] = '\0';

file = fopen (file_name, "w");
if (!file) {
  g_printerr ("Could not open file '%s' for writing:%s\n",
      file_name, strerror(errno));
  continue;
}
fwrite (info->buffer, element_size, info->dims.numElements * batch_size, file);
fclose (file);

}
config->file_write_frame_num++;
}

';

    file = fopen (file_name, "w");
    if (!file) {
      g_printerr ("Could not open file '%s' for writing:%s\n",
          file_name, strerror(errno));
      continue;
    }
    fwrite (info->buffer, element_size, info->dims.numElements * batch_size, file);
    fclose (file);
  }
  config->file_write_frame_num++;
}

but the code piece only save a binary buffer,I could not find how to get the output of the layer from the binary buffer.

Any message is appreciated!

You can get the output of inference like osd_sink_pad_buffer_probe in deepstream-test1

HI Chris, How to get the inference from the osd_sink_pad_buffer_probe?

Same question with abramjos.
Questions here:

write_infer_output_to_file can dump the floats(inference result), but it did not know which bbox/image it refered to.
osd_sink_pad_buffer_probe can extract metadata and get frame number/bbox, but no inference result(the final output vector from model).

How to link inference_result to frame_number ?

maybe you can get the raw inference output from custom parse boundingbox function,a custom lib configured in nvinfer’s config file.

How do you extract bbox coordinates and frame from osd_sink_pad_buffer_probe?