Open BeanBagKing opened 2 weeks ago
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"
Actions before raising this issue
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: https://github.com/cvat-ai/cvat/issues/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.)