コード例 #1
0
    def upload(self, annotation_file, loader):
        annotation_importer = Annotation(
            annotation_ir=self.ir_data,
            db_task=self.db_job.segment.task,
            create_callback=self.create,
        )
        self.delete()
        db_format = loader.annotation_format
        with open(annotation_file, 'rb') as file_object:
            source_code = open(
                os.path.join(settings.BASE_DIR,
                             db_format.handler_file.name)).read()
            global_vars = globals()
            imports = import_modules(source_code)
            global_vars.update(imports)

            execute_python_code(source_code, global_vars)

            global_vars["file_object"] = file_object
            global_vars["annotations"] = annotation_importer

            execute_python_code(
                "{}(file_object, annotations)".format(loader.handler),
                global_vars)
        self.create(
            annotation_importer.data.slice(self.start_frame,
                                           self.stop_frame).serialize())
コード例 #2
0
ファイル: annotation.py プロジェクト: myris3/cvat_tdt4265
    def dump(self, filename, dumper, scheme, host):
        anno_exporter = Annotation(
            annotation_ir=self.ir_data,
            db_task=self.db_task,
            scheme=scheme,
            host=host,
        )
        db_format = dumper.annotation_format

        with open(filename, 'wb') as dump_file:
            source_code = open(os.path.join(settings.BASE_DIR, db_format.handler_file.name)).read()
            global_vars = globals()
            imports = import_modules(source_code)
            global_vars.update(imports)
            execute_python_code(source_code, global_vars)
            global_vars["file_object"] = dump_file
            global_vars["annotations"] = anno_exporter

            execute_python_code("{}(file_object, annotations)".format(dumper.handler), global_vars)
コード例 #3
0
    def __init__(self, url, db_task, user):
        self._db_task = db_task
        self._categories = self._load_categories()

        cvat_annotations = TaskAnnotation(db_task.id, user)
        with transaction.atomic():
            cvat_annotations.init_from_db()
        cvat_annotations = Annotation(cvat_annotations.ir_data, db_task)

        dm_annotations = []

        for cvat_anno in cvat_annotations.group_by_frame():
            dm_anno = self._read_cvat_anno(cvat_anno)
            dm_item = datumaro.DatasetItem(id=cvat_anno.frame,
                                           annotations=dm_anno)
            dm_annotations.append((dm_item.id, dm_item))

        dm_annotations = sorted(dm_annotations, key=lambda e: e[0])
        self._items = OrderedDict(dm_annotations)

        self._subsets = None
コード例 #4
0
 def __init__(self, url, db_task, user):
     cvat_annotations = TaskAnnotation(db_task.id, user)
     with transaction.atomic():
         cvat_annotations.init_from_db()
     cvat_annotations = Annotation(cvat_annotations.ir_data, db_task)
     super().__init__(url, cvat_annotations)