marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.46k stars 355 forks source link

[class-attrs-id] keeps showing me all the classes #257

Closed davideschiavon closed 1 year ago

davideschiavon commented 2 years ago

Hello,

I am trying to detect only "person" (class 0). I have found from the Deepstream documentation that creating a section in the config_infer_primary.txt will enable the option to select a specific class.

I configured [class-attrs-all] to [class-attrs-0] (I also tried 00) but it keeps showing me all classes. Any suggestions?

`[property] gpu-id=0 net-scale-factor=0.0039215697906911373 model-color-format=0 custom-network-config=yolov5s.cfg model-file=yolov5s.wts model-engine-file=model_b1_gpu0_fp32.engine

int8-calib-file=calib.table

labelfile-path=labels.txt batch-size=1 network-mode=0 num-detected-classes=80 interval=0 gie-unique-id=1 process-mode=1 network-type=0 cluster-mode=2 maintain-aspect-ratio=1 parse-bbox-func-name=NvDsInferParseYolo custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so engine-create-func-name=NvDsInferYoloCudaEngineGet

filter-out-class-ids=56

[class-attrs-00] threshold=0.5 nms-iou-threshold=0.45 pre-cluster-threshold=0.25 topk=300 `

Thanks! Dave

pngstar commented 2 years ago

Hello,

filter-out-class-ids < use this function. see this link. https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvinfer.html?highlight=filter%20out%20class%20ids

EmpireofKings commented 2 years ago

You can add this to force all the classes besides 0 to a high conf threshold,

[class-attrs-all]
nms-iou-threshold=0.99
pre-cluster-threshold=0.99
topk=1

[class-attrs-0]
nms-iou-threshold=0.45
pre-cluster-threshold=0.25
topk=300

or you could simply add the below statement to your config.

operate-on-class-ids=0

It will force nvinfer to only operate on the 0. You can also add more classes with commas like so,

operate-on-class-ids=0,69

marcoslucianops commented 2 years ago

Use filter-out-class-ids.

Example:

Class 0: Car Class 1: Person Class 2: Bike

filter-out-class-ids=0;2

It will show only the person class

MohammadsAdrA-AI commented 1 year ago

I tried operate-on-class-ids , filter-out-class-ids and force all the classes besides 0 to a high conf threshold, but still has the same issue.

marcoslucianops commented 1 year ago

The operate-on-class-ids is for secondary gie. You should use filter-out-class-ids in the [property] section to filter the classes (as I said the the example above).

MohammadsAdrA-AI commented 1 year ago

Thank you so much, that works, Also any way to set a different threshold for each class?

marcoslucianops commented 1 year ago

You can set like

[class-attrs-all]
nms-iou-threshold=0.45
pre-cluster-threshold=0.25
topk=300

[class-attrs-0]
pre-cluster-threshold=0.2

[class-attrs-1]
pre-cluster-threshold=0.5
MohammadsAdrA-AI commented 1 year ago

I tried thia aet as well, the inference result shows that it only concerned the [class-attrs-all] and it didn't care about specific threshold in each class. should I enable anything to make that happen?

marcoslucianops commented 1 year ago

Referring to https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvinfer.html in the Gst-nvinfer File Configuration Specifications section, setting the class-attr key as I said is enough to filter the classes.