open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
28.7k stars 9.32k forks source link

Low confidence score #11612

Open tienduchoang opened 3 months ago

tienduchoang commented 3 months ago

I am working to retrain mm_grounding_dino with my custom dataset. The training process works fine

Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.784
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=1000 ] = 0.948

I also train another model with the same dataset on yolov7. The mAP of the mm_grounding_dino is better than the mAP of the yolov7 model. However, when i test the mm_grounding_dino model with my custom test dataset, the confidence score is much slower than the confidence score of the yolov7 on the same image. There are so many images where mm_grouding_dino cannot detect objects. In short, yolov7 perform detects objects better.

Below is my inference code:

import mmcv
from mmdet.apis import init_detector, inference_detector
from mmdet.utils import register_all_modules
from mmdet.registry import VISUALIZERS
import sys
sys.path.append("/ws")
import os

if __name__=="__main__":
    config_file = 'path/to/config/file'
    # Setup a checkpoint file to load
    checkpoint_file = 'path/to/checkpoint/file'

    # register all modules in mmdet into the registries
    register_all_modules()

    # build the model from a config file and a checkpoint file
    model = init_detector(config_file, checkpoint_file, device='cuda:0')  # or device='cuda:0'
    # texts = "hand gun . large gun . on the floor . register empty . register money"
    texts = "$: coco"
    image_folder = "/ws/test_data"
    output_folder = image_folder + "_output"
    if not os.path.exists(output_folder):
        os.mkdir(output_folder)
    image_names = os.listdir(image_folder) 
    for image_name in image_names:
        image_path = os.path.join(image_folder, image_name)
        image = mmcv.imread(image_path, channel_order='rgb')
        result = inference_detector(model, image, text_prompt=texts)
        # init visualizer(run the block only once in jupyter notebook)
        visualizer = VISUALIZERS.build(model.cfg.visualizer)
        # the dataset_meta is loaded from the checkpoint and
        # then pass to the model in init_detector
        visualizer.dataset_meta = model.dataset_meta
        # show the results
        visualizer.add_datasample(
            'result',
            image,
            data_sample=result,
            draw_gt = None,
            wait_time=0,
            out_file=os.path.join(output_folder, image_name),
            pred_score_thr=0.3
        )
tienduchoang commented 3 months ago

Hi @pengxin233 Have you got the same problem? Can you pls take a look?