Tried to use classId filtering with "infer-on-class-ids" into primary_gie but not working

Hi guys,

Using official deepstream-app from deepstream-4.0.1 we set up a demo with following high level pipeline components created by DeepStream-app,

2-VideoCamera(Rtsp) -> | GstRtspBin -> GstDecodeBin -> Primary_Gie_Bin -> Tracking_Bin -> OSD_Bin -> SinkBin(RtspServer) | -> RtspClient(recording)

in this way we can get a video from rtsp camera, analyze it in NvInfer and NvTracker and we can get all 80 yolo objects detected.

Now I have to filter out all objects minus “persons and cars” so ClassId=0 and ClassId=2
Se we want to see only persons and cars

Reading on DeepStream manuals I see I can set attribute

“infer-on-class-id or operate-on-class-ids”

using api like

"g_object_set ( G_OBJECT( primary/seocondary_gie), "infer-on-class-id, “0;2”, NULL )

So I tried to set it in primary-gie but nothing worked !!!

So I saw manuals saying “Class IDs of the parent GIE on which this GIE is to operate on”
It seems I cannot use it in PRIMARY-GIE ?? is it right ??

Consider that we cannot use a secondary-gie due to performance problems.

So how can I do to filter only “persons and cars” Yolo classes ID ?

ThankYou
M.

Can you modify Yolo parsing code:
sources/objectDetector_Yolo/./nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp
–> NvDsInferParseCustomYoloV3() -> NvDsInferParseYoloV3() -> decodeYoloV3Tensor() -> addBBoxProposal() -> bbi.classId = maxIndex; This is the class id.

Can you modify Yolo parsing code: nvdsparsebbox_Yolo.cpp
addBBoxProposal() -> bbi.classId = maxIndex; This is the class id.

Ok … we already did a very similar modification in another part of same file “nvdsparsebbox_Yolo.cpp” setting a direct test/check like : "if classId ==0 || classId==2 " and it worked.

So also your modification probably will work in the same way.

The limitation of this solution is that it isn’t a gie-infer-plugin exposed “property” like “infer-on-class-id” for secondary-gie, … so we have to wrap/improve in some way that part of code, in order to set objectsFiltering dynamically during Yolo engine activation.

But ok if the correct solution is to work at Yolo level in that way, ok we will do it without problems.

Thanks,
M.

The limitation of this solution is that it isn’t a gie-infer-plugin exposed “property” like “infer-on-class-id” for secondary-gie,

You can set threshold > 1 in [class-attrs-] group for class-ids that should not be generated by nvinfer. Please refer to samples/configs/deepstream-app/config_infer_primary.txt -> [class-attrs-2]

Hi,
I tried work with [class-attrs-0] and [class-attrs-2] that should correspond to persons and cars setting necessary property like threshold … like shown below

Per class configuration

[class-attrs-0]
threshold=1.1
group-threshold=1
eps=0.5

[class-attrs-2]
threshold=1.1
group-threshold=2
eps=0.5

and only to verify that class suppression works well but …
… but nothing took place … so cars and persons are always present.

I think that this setting do not work probably because we use YoloV3 network solution. YoloV3 uses its internal threshold setting to filter detected objects … is it correct ?

In any case as explained in my “comment #3” we can modify a couple of rows of code in “nvdsparsebbox_Yolo.cpp” … and we would have a solution for filtering

so we have to wrap/improve in some way that part of code, in order to
set objectsFiltering dynamically during Yolo engine activation.

But ok if the correct solution is to work at Yolo level in that way,
ok we will do it without problems.

Thanks,
M.

Yes. You are right.
“threshold” in [class-attrs-0] is used in
“NvDsInferContextImpl::parseBoundingBox()” -> “detectionParams.perClassThreshold[classIndex]”
But yolo threshold is set in nvdsparsebbox_Yolo.cpp -> NvDsInferParseYoloV3() -> kPROB_THRESH You can set it acoording to your need.