NvDsFrameMeta seems to contain only object level inference results.
Is there an attribute one can access to get classification metadata when there is 1 or more classification networks in a pipeline (and no primary object detection)?
Good question, the classification meta should be also in the object meta even there is no detector model in the pipeline, you can refer gstnvinfer_meta_utils.cpp → attach_metadata_classifier for how nvinfer attach the classsification meta data.
if (nvinfer->process_full_frame) {
/* Attach only one object in the meta since this is a full frame
* classification. */
object_meta = nvds_acquire_obj_meta_from_pool (batch_meta);
I start my script, it runs, but I only see frame number printed and nothing else (frame number printing statement is at the end of the probe function, just like in deepstream-test-1 example):
Now playing: …/…/…/…/samples/streams/sample_720p.h264
0:00:09.467327410 24536 0x55a872505d50 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1702> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-5.1/sources/apps/sample_apps/deepstream-test0/test.engine
INFO: …/nvdsinfer/nvdsinfer_model_builder.cpp:685 [Implicit Engine Info]: layers num: 2
0 INPUT kFLOAT input 3x512x512
1 OUTPUT kFLOAT sequential_5 3
0:00:09.467374989 24536 0x55a872505d50 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1806> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-5.1/sources/apps/sample_apps/deepstream-test0/test.engine
0:00:09.468018392 24536 0x55a872505d50 INFO nvinfer gstnvinfer_impl.cpp:313:notifyLoadModelStatus: [UID 1]: Load new model:dstest1_pgie_config.txt sucessfully
Running…
Frame Number = 0
Frame Number = 1
Frame Number = 2
Frame Number = 3
…
If I make changes to gstnvinfer_meta_utils.cpp - what steps do I need to take to apply changes (aside from “make clean” and “make” inside gstnvinfer dir)?
I tried to add some g_print statements into attach_metadata_classifier to see what steps were executed in each frame, but after “make clean” and “make” for both my app and gstnvinfer folder I did not see any expected output in std after stating my app?
You need to do make install after rebuild the lib. Yeah, will be better to do debug by yourself, it’s also a chance to get more familiar with DS SDK.
Update string label in an existing object metadata. If processing on full
frames, need to attach a new metadata. Assume only one label per object is generated.
*/
void
attach_metadata_classifier (GstNvInfer * nvinfer, GstMiniObject * tensor_out_object,
GstNvInferFrame & frame, GstNvInferObjectInfo & object_info)
{
NvDsObjectMeta *object_meta = frame.obj_meta;
NvDsBatchMeta *batch_meta = (nvinfer->process_full_frame) ?
frame.frame_meta->base_meta.batch_meta : object_meta->base_meta.batch_meta;
g_print(“Accesing meta\n”);
if (object_info.attributes.size () == 0 ||
object_info.label.length() == 0){
g_print(“No object metadata, returning\n”);
return;
}
And after running app i see the following ouput:
Now playing: …/…/…/…/samples/streams/sample_720p.h264
0:00:10.041046515 24642 0x56274ce43560 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1702> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-5.1/sources/apps/sample_apps/deepstream-test0/test.engine
INFO: …/nvdsinfer/nvdsinfer_model_builder.cpp:685 [Implicit Engine Info]: layers num: 2
0 INPUT kFLOAT input 3x512x512
1 OUTPUT kFLOAT sequential_5 3
0:00:10.041094612 24642 0x56274ce43560 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1806> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-5.1/sources/apps/sample_apps/deepstream-test0/test.engine
0:00:10.041622216 24642 0x56274ce43560 INFO nvinfer gstnvinfer_impl.cpp:313:notifyLoadModelStatus: [UID 1]: Load new model:dstest1_pgie_config.txt sucessfully
Running…
Accesing meta
No object metadata, returning
Frame Number = 0
Accesing meta
No object metadata, returning
Frame Number = 1
Accesing meta
No object metadata, returning
That means that no objects in a frame would mean no metadata attached after classifiction, If I’m not wrong.
Oh, you need to customized your post process parser for your model, you can refer nvdsinfer_customclassifierparser.cpp under $DS_TOP/sources/libs/nvdsinfer_customparser/ for how to do that
Thanks, will do that.
I somehow knew it wouldn’t be that easy.
I"ll try to update this post after figuring out what needed to be done for the sake of this topic’s completeness.
Overall - there was no need for extensive custom parsing (At least in my case);
When there are only classificaiton NNs in a pipeline - 1 object will be created in frame_meta->ojb_meta_list to which all classification results would be appended into obj_meta->classifier_meta_list
Therefor, I just needed to modify probe function to access Classifier metadata list and retrieve my values:
After delving deeper into the belly of the beast I found that my classification results were waiting for me right there.
Thanks again for help. Your pointers to the right files allowed me to understand where to look for answers.
But after tinkering with ClassifyPostprocessor::parseAttributesFromSoftmaxLayers function in nvdsinfer_context_impl_output_parsing.cpp I understood that I forgot to add path to labelfile in my config.
labelfile-path=./labels.txt
Without it, no classification data gets attached to MetaData.
After adding label file - everything started to work OK.