Deepstream YoloV3-Tiny is giving oversized bounding boxes

Good evening,

I’m following the Application Note on ‘Custom YOLO Model in the DeepStream YOLO App’ and got a strange issue - all the bounding boxes on image looks too big.
Picture examples are in the links:
First one are boxes I get on PC:
https://imgur.com/a/wMYMzmG
Second one on Jetson Nano
https://imgur.com/a/crCHETQ

As you can see Jetson Bboxes looks scaled up.

For reference:
-Custom YoloV3-Tiny was trained using AlexeyAB Darknet fork
-Reference video resolution is 1280x720, I’ve set same numbers in app config file
-It happens on every video
-I’ve tried to change width and height in yolov3-tiny.cfg file, it only affected fps
-I’ve tried to change masks=0,1,2 to masks=1,2,3 (in the same file) - no effect
-I’ve changed [streammux] width and height in app config without any result
-I’ve tried to find numbers like ‘416’ or ‘608’ in cpp files, but no luck

It’s seems to me that the issue is realted to bbox rescaling, but I don’t know where to check or how to output raw bbox values.

Thanks.

Moving to DeepStream SDK forum for resolution.

Hi,

To customized a YOLO model, you will need to update following steps:

1. Update NUM_CLASSES_YOLO in nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp.

static const int NUM_CLASSES_YOLO = 80;

2. Update NMS parameters in nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp.

extern "C" bool NvDsInferParseCustomYoloV3Tiny(
...
    static const std::vector<float> kANCHORS = {
        10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319};
    static const std::vector<std::vector<int>> kMASKS = {
        {3, 4, 5},
        //{0, 1, 2}}; // as per output result, select {1,2,3}
        {1, 2, 3}};
...

3. Update threshold parameter in nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp.

static bool NvDsInferParseYoloV3(
...
    const uint kNUM_BBOXES = 3;
    static const float kNMS_THRESH = 0.3f;
    static const float kPROB_THRESH = 0.7f;
...

4. Update file path in config_infer_primary_yoloV3_tiny.txt

[property]
...
custom-network-config=yolov3-tiny.cfg
model-file=yolov3-tiny.weights
...
num-detected-classes=80
...

The most common issue is from step.2, could you help to give it a try?
If the result still remains the same, could you share your model with us for debugging?

Thanks.

Dear AastaLLL,

Initially I did exactly as you described:

  1. Number of classes = 4
  2. In NvDsInferParseCustomYoloV3Tiny - nothing was changed here as long as Anchors are idenitcal to mine
  3. In NvDsInferParseYoloV3 - only kNMS_THRESH = 0.3f was changed to 0.5f, but I think this affects only on bounding box detection probability, not it’s size.
  4. Path to files is also correct, num-detected-classes=4

I will try to play with params in 2 and 3, but in advance here’s the trained model:
https://onedrive.live.com/?id=6317F6CD65F16BEC!47630&cid=6317F6CD65F16BEC
For reference:
obj_road.names - it’s labels.txt
config and weights files also attached, just rename them.

Video which I used for testing can be found here:
https://1drv.ms/u/s!Auxr8WXN9hdjgvQPZs1PrMtl6--fag?e=wpI5E2

Thank you!

Hi,

I try to access this link:

https://onedrive.live.com/?id=6317F6CD65F16BEC%2147630&cid=6317F6CD65F16BEC

But it’s empty.
Could you help me to double check the link again?

Thanks.

Hello AastaLLL,

Please, try this link:

https://1drv.ms/f/s!Auxr8WXN9hdjgvQOr_Q_kj-qitfDcQ

Looks like onedrive has some access issues.

Hi,

Please try this patch.
I can see the bounding box size is normal after applying the change.

diff --git a/sources/objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp b/sources/objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp
index 4226027..9c01115 100755
--- a/sources/objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp
+++ b/sources/objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp
@@ -373,8 +373,8 @@ extern "C" bool NvDsInferParseCustomYoloV3Tiny(
         10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319};
     static const std::vector<std::vector<int>> kMASKS = {
         {3, 4, 5},
-        //{0, 1, 2}}; // as per output result, select {1,2,3}
-        {1, 2, 3}};
+        {0, 1, 2}}; // as per output result, select {1,2,3}
+    //   {1, 2, 3}};
 
     return NvDsInferParseYoloV3 (
         outputLayersInfo, networkInfo, detectionParams, objectList,

Thanks.

1 Like

Thank you AastaLLL! This really worked out.