jsbroks / coco-annotator

:pencil2: Web-based image segmentation tool for object detection, localization, and keypoints
MIT License
2.11k stars 460 forks source link

How to combine collections & Reduce Optimisation speed #220

Open trinath503 opened 5 years ago

trinath503 commented 5 years ago

File : https://github.com/jsbroks/coco-annotator/blob/master/backend/webserver/api/datasets.py API: @api.route('//data') Line : 309 in the file

       images = current_user.images \
            .filter(dataset_id=dataset_id, path__startswith=directory, deleted=False, **query) \
            .order_by(order).only('id', 'file_name', 'annotating', 'annotated', 'num_annotations')

        total = images.count()
        pages = int(total/per_page) + 1

        images = images.skip(page*per_page).limit(per_page)
        images_json = query_util.fix_ids(images)
        for image in images:
            image_json = query_util.fix_ids(image)

            query = AnnotationModel.objects(image_id=image.id, deleted=False)
            category_ids = query.distinct('category_id')
            categories = CategoryModel.objects(id__in=category_ids).only('name', 'color')

            image_json['annotations'] = query.count()
            image_json['categories'] = query_util.fix_ids(categories)

            images_json.append(image_json)''''

can we combine image-model, annotation-model, category-model and run the single query? please share your ideas

jsbroks commented 5 years ago

Why are you closing this?