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

Show number of annotations for each class in a project #8020

Open
2 tasks done
BeanBagKing opened this issue Jun 12, 2024 · 1 comment
Open
2 tasks done

Show number of annotations for each class in a project #8020

BeanBagKing opened this issue Jun 12, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@BeanBagKing
Copy link

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Is your feature request related to a problem? Please describe.

I'd like to know the current total number of annotations I have for each class within a project. Currently this is only available at the job level.

Describe the solution you'd like

Exactly like the Info button in the upper right when you open a job, but I'd like to have it for the whole project. That way I know if there is an item I can slack off on because I have 10,000 of them already, or something I need to focus more on because I only have 20. As it stands I'd have to go job by job and add them up.

Describe alternatives you've considered

I feel like this would fit in well in the "View Analytics" option for a project, and as a bonus it can also be placed in the same area also exists for a Task and Job. If it was added globally there would be a single area to look for this information at whatever level a person deemed necessary.

Additional context

I searched for this issue and found a tangentially related question from last year, but no feature request for this: #7012

Bonus points for something like a pretty pie chart or other analytics (for example, percent of each, count/percent of images with no annotation, etc.)

@BeanBagKing BeanBagKing added the enhancement New feature or request label Jun 12, 2024
@zhiltsov-max
Copy link
Contributor

Hi, consider doing it via the CVAT SDK python package in a script like this:

import sys
from argparse import ArgumentParser
from typing import List, Optional

from cvat_sdk import make_client
from cvat_sdk.core.proxies.jobs import Job
from cvat_sdk.core.helpers import get_paginated_collection
from tqdm import tqdm


def main(args: Optional[List[str]] = None) -> int:
    parser = ArgumentParser()
    parser.add_argument("project_id", type=int)
    parsed_args = parser.parse_args(args)

    with make_client("https://app.cvat.ai", port=443, credentials=('username', 'pass')) as client:
        # client.organization_slug = ""
        client.config.status_check_period = 2

        all_annotations_count = {}

        jobs = [
            Job(client, job_model)
            for job_model in  get_paginated_collection(
                client.jobs.api.list_endpoint, project_id=parsed_args.project_id
            )
        ]

        for job in tqdm(jobs):
            annotations = job.get_annotations()

            annotations_count = {}
            annotations_count["tag"] = annotations_count.get("tag", 0) + len(annotations.tags)
            annotations_count["shapes"] = annotations_count.get("shapes", 0) + len(
                annotations.shapes
            )
            annotations_count["tracks"] = annotations_count.get("tracks", 0) + len(
                annotations.tracks
            )

            for shape in annotations.shapes:
                annotations_count[shape.type.value] = annotations_count.get(shape.type.value, 0) + 1

            print(f"Job {job.id} counts:", annotations_count)

            for k, v in annotations_count.items():
                all_annotations_count[k] = all_annotations_count.get(k, 0) + v

        print("checked jobs", [j.id for j in jobs])
        print("annotations count:", all_annotations_count)

    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))

To run, install the python packages:

pip install "cvat-sdk" "tqdm"

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

No branches or pull requests

2 participants