open-mmlab / mmdetection

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

Custom Testing format #6997

Closed MatthewCodes closed 2 years ago

MatthewCodes commented 2 years ago

Hello I want to test my models from this framework against models from another framework using a script very similar to the evaluate method in the coco.py file:

        cocoGt = COCO('custom_gt.json')
        for metric in metrics:
            msg = f'Evaluating {metric}...'
            if logger is None:
                msg = '\n' + msg
            print_log(msg, logger=logger)

            if metric == 'proposal_fast':
                ar = self.fast_eval_recall(
                    results, proposal_nums, iou_thrs, logger='silent')
                log_msg = []
                for i, num in enumerate(proposal_nums):
                    eval_results[f'AR@{num}'] = ar[i]
                    log_msg.append(f'\nAR@{num}\t{ar[i]:.4f}')
                log_msg = ''.join(log_msg)
                print_log(log_msg, logger=logger)
                continue

            if metric not in result_files:
                raise KeyError(f'{metric} is not in results')
            try:
                cocoDt = cocoGt.loadRes('custom_predictions.json')

What is the bounding box format I should use for my cocoGt (ground truth) and for the cocoDt (my results). I tried to have them as [x1, y1, W, H] and the results were mostly 0.0 but when I switched the bbox format to [x1, y1, x2, y2] it improved my results to .70. And just to confirm the training bbox format should be [x1, y1, W, H]?

RangiLyu commented 2 years ago

All of the bbox format in MMDetection is [x1, y1, x2, y2]. But when using COCO API, you need to convert the boxes to [x1, y1, W, H] format.

MatthewCodes commented 2 years ago

So, when running dist_train.sh I can have the bbox format in my annotation files as [x1, y1, x2, y2]. But in this situation when I am doing manual testing my 'custom_gt.json' and 'custom_predictions.json' files should be [x1, y1, W, H]?

RangiLyu commented 2 years ago

If you are using CocoDataset format, your annotation file should be COCO format(x1, y1, W, H), after the file is loaded, it will be converted to [x1, y1, x2, y2].

So the annotation file of coco dataset should all be [x1, y1, W, H] format both in training and testing.