Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset which is not COCO in COCO format #9

Closed
toddChavezz opened this issue Sep 15, 2020 · 2 comments
Closed

Dataset which is not COCO in COCO format #9

toddChavezz opened this issue Sep 15, 2020 · 2 comments

Comments

@toddChavezz
Copy link

Is it possible to apply TIDE as it is to a custom dataset which is not COCO but is in the exact format of COCO? My model also outputs the same results file. But at the moment I get:

Traceback (most recent call last):
File "..../mAP_evaluation.py", line 91, in evaluate_coco
tide.summarize()
File "..../lib/python3.7/site-packages/tidecv/quantify.py", line 494, in summarize
main_errors = self.get_main_errors()
File "..../lib/python3.7/site-packages/tidecv/quantify.py", line 603, in get_main_errors
for error, value in run.fix_main_errors().items()
File "..../lib/python3.7/site-packages/tidecv/quantify.py", line 349, in fix_main_errors
new_ap = _ap_data.get_mAP()
File "...../lib/python3.7/site-packages/tidecv/ap.py", line 150, in get_mAP
return sum(aps) / len(aps)
ZeroDivisionError: division by zero

Thanks a lot in advance!

@reubenwenisch
Copy link

@toddChavezz were you able to do this successfully?

@toddChavezz
Copy link
Author

I borrowed the solution from my dear colleague @leonvarga . Call below functions like this:

            tide = TIDE()
            tide.evaluate(coco_gt_to_tide_data(coco_true), coco_dt_to_tide_data(coco_pred), mode=TIDE.BOX)
            tide.summarize()

The functions:

from tidecv import Data, f
from pycocotools.coco import COCO


def coco_gt_to_tide_data(coco_gt: COCO, name="default"):
    data = Data(name)

    for idx, image in enumerate(coco_gt.imgs.values()):
        if 'file_name' in image.keys():
            data.add_image(image['id'], image['file_name'])

    if coco_gt.cats is not None:
        for cat in coco_gt.cats.values():
            if 'name' in cat.keys():
                data.add_class(cat['id'], cat['name'])

    for ann in coco_gt.anns.values():
        image = ann['image_id']
        _cls = ann['category_id']
        box = ann['bbox']

        if ann['iscrowd']:
            data.add_ignore_region(image, _cls, box)
        else:
            data.add_ground_truth(image, _cls, box)

    return data


def coco_dt_to_tide_data(coco_dt: COCO, name="default"):
    data = Data(name)

    for det in coco_dt.anns.values():
        image = det['image_id']
        _cls = det['category_id']
        score = det['score']
        box = det['bbox'] if 'bbox' in det else None
        mask = det['segmentation'] if 'segmentation' in det else None

        data.add_detection(image, _cls, score, box, mask)

    return data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants