jozhang97 / DETA

Detection Transformers with Assignment
Apache License 2.0
243 stars 20 forks source link

Writing detections to json file and evaluation on test-dev #17

Closed kemaloksuz closed 1 year ago

kemaloksuz commented 1 year ago

Hi, thanks for the great work.

You mention in the repo that you achieve 63.5 AP on test-dev. I wonder if this repository supports dumping detections to a json file. I spent some time but was not obvious to me.

Thanks

jozhang97 commented 1 year ago

Thanks for your interest. Unfortunately this code does not support dumping detections to json.

You can add some code around the evaluate for loop in https://github.com/jozhang97/DETA/blob/master/engine.py

Something like

            for target, output in zip(targets, results):
                scores = output['scores'].tolist()
                labels = output['labels'].tolist()
                boxes = output['boxes']
                boxes[:,2:] -= boxes[:,:2]  # xyxy xywh
                boxes = boxes.tolist()
                image_id = target['image_id'].item()
                for s, l, b in zip(scores, labels, boxes):
                    pred = {
                        'image_id': image_id,
                        'category_id': l,
                        'bbox': b,
                        'score': s
                    }
                    ret_json.append(pred)
kemaloksuz commented 1 year ago

That was a great help, thanks!