Пример #1
0
    def get(self, dataset_id):
        """ Returns exports of images and annotations in the dataset (only owners) """
        dataset = current_user.datasets.filter(id=dataset_id).first()

        if dataset is None:
            return {"message": "Invalid dataset ID"}, 400

        if not current_user.can_download(dataset):
            return {
                "message":
                "You do not have permission to download the dataset's annotations"
            }, 403

        exports = ExportModel.objects(
            dataset_id=dataset.id).order_by('-created_at').limit(50)

        dict_export = []
        for export in exports:

            time_delta = datetime.datetime.utcnow() - export.created_at
            dict_export.append({
                'id': export.id,
                'ago': query_util.td_format(time_delta),
                'tags': export.tags
            })

        return dict_export
Пример #2
0
    def get(self, dataset_id):
        """ Returns coco of images and annotations in the dataset (only owners) """
        dataset = current_user.datasets.filter(id=dataset_id).first()

        if dataset is None:
            return {"message": "Invalid dataset ID"}, 400
        
        if not current_user.can_download(dataset):
            return {"message": "You do not have permission to download the dataset's annotations"}, 403

        return coco_util.get_dataset_coco(dataset)
Пример #3
0
    def get(self, image_id):
        """ Returns coco of image and annotations """
        image = current_user.images.filter(id=image_id).exclude('deleted_date').first()
        
        if image is None:
            return {"message": "Invalid image ID"}, 400

        if not current_user.can_download(image):
            return {"message": "You do not have permission to download the images's annotations"}, 403

        return coco_util.get_image_coco(image_id)
Пример #4
0
    def get(self, image_id):
        """ Returns coco of image and annotations """
        image = current_user.find_image_without_deleted_date_by_id(image_id)

        if image is None:
            return {"message": "Invalid image ID"}, 400

        if not current_user.can_download(image):
            return {
                "message":
                "You do not have permission to download the images's annotations"
            }, 403

        usecase = ExportLabelmeUsecase()
        return usecase.execute(image_id)
Пример #5
0
    def get(self, export_id):
        """ Returns exports """

        export = ExportModel.objects(id=export_id).first()
        if export is None:
            return {"message": "Invalid export ID"}, 400

        dataset = current_user.datasets.filter(id=export.dataset_id).first()
        if dataset is None:
            return {"message": "Invalid dataset ID"}, 400
        
        if not current_user.can_download(dataset):
            return {"message": "You do not have permission to download the dataset's annotations"}, 403

        return send_file(export.path, attachment_filename=f"{dataset.name}-{'-'.join(export.tags)}.json", as_attachment=True)
Пример #6
0
    def get(self, dataset_id):
        """ Returns coco of all datasets """

        # step one: get ALL datasets, not just of current user... how to retrieve all datasetmodels ?
        # dataset = current_user.datasets.filter(id=dataset_id).first()

        if dataset is None:
            return {"message": "Invalid dataset ID"}, 400

        if not current_user.can_download(dataset):
            return {
                "message":
                "You do not have permission to download the dataset's annotations"
            }, 403

        # step two: modify coco_util to allow for multiple dataset omdels?
        return coco_util.get_dataset_coco(dataset)