Support for VGGFace2 dataset format (#2865)

* Add support for VGGFace2  dataset format

* Add VGGFace2  to documentation

* fix format description

* Update Datumaro version

* fix linter

* fix test

* fix base.txt

Co-authored-by: Zhiltsov Max <zhiltsov.max35@gmail.com>
main
Anastasia Yasakova 5 years ago committed by GitHub
parent 62cc956967
commit 7a2dcfff61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,6 +62,7 @@ For more information about supported formats look at the
| [LabelMe 3.0](http://labelme.csail.mit.edu/Release3.0) | X | X | | [LabelMe 3.0](http://labelme.csail.mit.edu/Release3.0) | X | X |
| [ImageNet](http://www.image-net.org) | X | X | | [ImageNet](http://www.image-net.org) | X | X |
| [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/) | X | X | | [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/) | X | X |
| [VGGFace2](https://github.com/ox-vgg/vgg_face2) | X | X |
## Deep learning serverless functions for automatic labeling ## Deep learning serverless functions for automatic labeling

@ -20,6 +20,7 @@
- [TF detection API](#tfrecord) - [TF detection API](#tfrecord)
- [ImageNet](#imagenet) - [ImageNet](#imagenet)
- [CamVid](#camvid) - [CamVid](#camvid)
- [VGGFace2](#vggface2)
## How to add a new annotation format support<a id="how-to-add"></a> ## How to add a new annotation format support<a id="how-to-add"></a>
@ -874,3 +875,34 @@ has own color which corresponds to a label.
Uploaded file: a zip archive of the structure above Uploaded file: a zip archive of the structure above
- supported annotations: Polygons - supported annotations: Polygons
### [VGGFace2](https://github.com/ox-vgg/vgg_face2)<a id="vggface2" />
#### VGGFace2 Dumper
Downloaded file: a zip archive of the following structure:
```bash
taskname.zip/
├── labels.txt # optional
├── <any_subset_name>/
| ├── label0/
| | └── image1.jpg
| └── label1/
| └── image2.jpg
└── bb_landmark/
├── loose_bb_<any_subset_name>.csv
└── loose_landmark_<any_subset_name>.csv
# labels.txt
# n000001 car
label0 <class0>
label1 <class1>
```
- supported annotations: Rectangles, Points (landmarks - groups of 5 points)
#### VGGFace2 Loader
Uploaded file: a zip archive of the structure above
- supported annotations: Rectangles, Points (landmarks - groups of 5 points)

@ -95,3 +95,4 @@ import cvat.apps.dataset_manager.formats.tfrecord
import cvat.apps.dataset_manager.formats.yolo import cvat.apps.dataset_manager.formats.yolo
import cvat.apps.dataset_manager.formats.imagenet import cvat.apps.dataset_manager.formats.imagenet
import cvat.apps.dataset_manager.formats.camvid import cvat.apps.dataset_manager.formats.camvid
import cvat.apps.dataset_manager.formats.vggface2

@ -0,0 +1,32 @@
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
import zipfile
from tempfile import TemporaryDirectory
from datumaro.components.dataset import Dataset
from cvat.apps.dataset_manager.bindings import CvatTaskDataExtractor, \
import_dm_annotations
from cvat.apps.dataset_manager.util import make_zip_archive
from .registry import dm_env, exporter, importer
@exporter(name='VGGFace2', ext='ZIP', version='1.0')
def _export(dst_file, task_data, save_images=False):
dataset = Dataset.from_extractors(CvatTaskDataExtractor(
task_data, include_images=save_images), env=dm_env)
with TemporaryDirectory() as temp_dir:
dataset.export(temp_dir, 'vgg_face2', save_images=save_images)
make_zip_archive(temp_dir, dst_file)
@importer(name='VGGFace2', ext='ZIP', version='1.0')
def _import(src_file, task_data):
with TemporaryDirectory() as tmp_dir:
zipfile.ZipFile(src_file).extractall(tmp_dir)
dataset = Dataset.import_from(tmp_dir, 'vgg_face2', env=dm_env)
import_dm_annotations(dataset, task_data)

@ -282,6 +282,7 @@ class TaskExportTest(_DbTestBase):
'YOLO 1.1', 'YOLO 1.1',
'ImageNet 1.0', 'ImageNet 1.0',
'CamVid 1.0', 'CamVid 1.0',
'VGGFace2 1.0',
}) })
def test_import_formats_query(self): def test_import_formats_query(self):
@ -300,6 +301,7 @@ class TaskExportTest(_DbTestBase):
'YOLO 1.1', 'YOLO 1.1',
'ImageNet 1.0', 'ImageNet 1.0',
'CamVid 1.0', 'CamVid 1.0',
'VGGFace2 1.0',
}) })
def test_exports(self): def test_exports(self):
@ -312,6 +314,9 @@ class TaskExportTest(_DbTestBase):
self.skipTest("Format is disabled") self.skipTest("Format is disabled")
format_name = f.DISPLAY_NAME format_name = f.DISPLAY_NAME
if format_name == "VGGFace2 1.0":
self.skipTest("Format does not support multiple shapes for one item")
for save_images in { True, False }: for save_images in { True, False }:
images = self._generate_task_images(3) images = self._generate_task_images(3)
task = self._generate_task(images) task = self._generate_task(images)
@ -337,6 +342,7 @@ class TaskExportTest(_DbTestBase):
('YOLO 1.1', 'yolo'), ('YOLO 1.1', 'yolo'),
('ImageNet 1.0', 'imagenet_txt'), ('ImageNet 1.0', 'imagenet_txt'),
('CamVid 1.0', 'camvid'), ('CamVid 1.0', 'camvid'),
('VGGFace2 1.0', 'vgg_face2'),
]: ]:
with self.subTest(format=format_name): with self.subTest(format=format_name):
if not dm.formats.registry.EXPORT_FORMATS[format_name].ENABLED: if not dm.formats.registry.EXPORT_FORMATS[format_name].ENABLED:

@ -16,8 +16,6 @@ from enum import Enum
from glob import glob from glob import glob
from io import BytesIO from io import BytesIO
from unittest import mock from unittest import mock
import open3d as o3d
import struct
import av import av
import numpy as np import numpy as np
@ -739,7 +737,7 @@ class UserListAPITestCase(UserAPITestCase):
return response return response
def _check_response(self, user, response, is_full): def _check_response(self, user, response, is_full=True):
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
for user_info in response.data['results']: for user_info in response.data['results']:
db_user = getattr(self, user_info['username']) db_user = getattr(self, user_info['username'])
@ -3770,6 +3768,17 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
"occluded": False, "occluded": False,
}] }]
points_wo_attrs = [{
"frame": 1,
"label_id": task["labels"][1]["id"],
"group": 0,
"source": "manual",
"attributes": [],
"points": [20.0, 0.1, 10, 3.22, 4, 7, 10, 30, 1, 2],
"type": "points",
"occluded": False,
}]
tags_wo_attrs = [{ tags_wo_attrs = [{
"frame": 2, "frame": 2,
"label_id": task["labels"][1]["id"], "label_id": task["labels"][1]["id"],
@ -3855,6 +3864,11 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
annotations["shapes"] = rectangle_shapes_wo_attrs \ annotations["shapes"] = rectangle_shapes_wo_attrs \
+ polygon_shapes_wo_attrs + polygon_shapes_wo_attrs
elif annotation_format == "VGGFace2 1.0":
annotations["tags"] = tags_wo_attrs
annotations["shapes"] = points_wo_attrs \
+ rectangle_shapes_wo_attrs
else: else:
raise Exception("Unknown format {}".format(annotation_format)) raise Exception("Unknown format {}".format(annotation_format))

Loading…
Cancel
Save