GeekAlexis / FastMOT

High-performance multiple object tracking based on YOLO, Deep SORT, and KLT 🚀
MIT License
1.15k stars 253 forks source link

Poor detection on a specific class in new version #181

Closed pintusorn closed 3 years ago

pintusorn commented 3 years ago

Hello,

I use a custom weight running on FastMOT and it is working fine.

There are 3 classes in my custom weight.

I am focusing on Motorcycle_with_Human and Car classes.

However, it seems like Car class has this flaw for detection. You can see it in the video I attached here: https://drive.google.com/file/d/1v6RValCM9L7Dz3w-NVbuAMUiWUIM4FeA/view?usp=sharing

Here is my code for mot.json,

{   
    "resize_to": [1024, 576],

    "stream_cfg": {
        "resolution": [1024,576],
        "frame_rate": 30,
        "buffer_size": 10
    },

    "mot_cfg": {
        "detector_type": "YOLO",
        "detector_frame_skip": 1,

        "ssd_detector_cfg": {
            "model": "SSDInceptionV2",
            "class_ids": [1],
            "tile_overlap": 0.25,
            "tiling_grid": [4, 2],
            "conf_thresh": 0.5,
            "merge_thresh": 0.6,
            "max_area": 120000
        },
        "yolo_detector_cfg": {
            "model": "YOLOv4Tiny",
            "class_ids": [0,1,2],
            "conf_thresh": 0.25,
            "nms_thresh": 0.5,
            "max_area": 800000,
            "min_aspect_ratio": 1.2
        },
        "public_detector_cfg": {
            "sequence_path": "MOT20/train/MOT20-01",
            "conf_thresh": 0.5,
            "max_area": 800000
        },
        "feature_extractor_cfg": {
            "model": "OSNet025",
            "batch_size": 16
        },

        "tracker_cfg": {
            "max_age": 6,
            "age_penalty": 2,
            "motion_weight": 0.2,
            "max_assoc_cost": 0.8,
            "max_reid_cost": 0.6,
            "iou_thresh": 0.2,
            "duplicate_thresh": 0.8,
            "occlusion_thresh": 0.7,
            "conf_thresh": 0.5,
            "confirm_hits": 1,
            "history_size": 50,

            "kalman_filter_cfg": {
                "std_factor_acc": 2.25,
                "std_offset_acc": 78.5,
                "std_factor_det": [0.08, 0.08],
                "std_factor_klt": [0.14, 0.14],
                "min_std_det": [4.0, 4.0],
                "min_std_klt": [5.0, 5.0],
                "init_pos_weight": 5,
                "init_vel_weight": 12,
                "vel_coupling": 0.6,
                "vel_half_life": 2
            },

            "flow_cfg": {
                "bg_feat_scale_factor": [0.1, 0.1],
                "opt_flow_scale_factor": [0.5, 0.5],
                "feat_density": 0.005,
                "feat_dist_factor": 0.06,
                "ransac_max_iter": 500,
                "ransac_conf": 0.99,
                "max_error": 100,
                "inlier_thresh": 4,
                "bg_feat_thresh": 10,
                "obj_feat_params": {
                    "maxCorners": 1000,
                    "qualityLevel": 0.06,
                    "blockSize": 3
                },
                "opt_flow_params": {
                    "winSize": [5, 5],
                    "maxLevel": 5,
                    "criteria": [3, 10, 0.03]
                }
            }
        },

        "visualizer_cfg": {
            "draw_detections": false,
            "draw_confidence": false,
            "draw_covariance": false,
            "draw_klt": false,
            "draw_obj_flow": false,
            "draw_bg_flow": false
        }
    }
}

Here is the label.py


LABEL_MAP = (
    'Car',
    'Human',
    'Motorcycle_with_Human' 
)

Lastly, this is a YOLOv4Tiny class inside yolo.py

class YOLOv4Tiny(YOLO):
    ENGINE_PATH = Path(__file__).parent / 'yolov4ploy-tiny-416.trt'
    MODEL_PATH = Path(__file__).parent /  'yolov4ploy-tiny-416.onnx'
    NUM_CLASSES = 3
    #LETTERBOX =False
    #NEW_COORDS=False
    INPUT_SHAPE = (3, 416, 416)
    LAYER_FACTORS = [32, 16]
    SCALES = [1.05, 1.05]
    ANCHORS = [[81,82, 135,169, 344,319],
               [23,27, 37,58, 81,82]]

I am not sure why it happens. I used this weight before on the older version of your code, it seems to detect fine image

Moreover, when I add verbose tag on this current code version, there is nothing happen, just the original detection box as you can see in the video.

Is it something to do with variables? Do I need to adjust anything?

Thank you very much in advance

GeekAlexis commented 3 years ago

There are some changes in parameters and API in version 2.0 you need to account for.

  1. min_aspect_ratio is set for human detection. If you want to detect square objects, lower it to 0.1
  2. You can toggle options in visualizer_cfg for drawing, verbose only prints debugging information now. This is more flexible.

See docstring in the code for parameter tuning. For this version, it is also recommended to set labels and create your custom YOLO class in app.py so that you don't have to mess with internal API code.