From 5eda5d76eda552352d823740fde20c67e8f09e0f Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Thu, 25 Feb 2021 10:33:50 +0300 Subject: [PATCH 01/11] Add support for WiderFace dataset format --- cvat/apps/dataset_manager/formats/registry.py | 1 + .../apps/dataset_manager/formats/widerface.py | 32 +++++++++++ .../dataset_manager/tests/test_formats.py | 3 ++ cvat/apps/engine/tests/test_rest_api.py | 54 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 cvat/apps/dataset_manager/formats/widerface.py diff --git a/cvat/apps/dataset_manager/formats/registry.py b/cvat/apps/dataset_manager/formats/registry.py index 46039f25fcdd..ca6a7c76f69d 100644 --- a/cvat/apps/dataset_manager/formats/registry.py +++ b/cvat/apps/dataset_manager/formats/registry.py @@ -95,3 +95,4 @@ def make_exporter(name): import cvat.apps.dataset_manager.formats.yolo import cvat.apps.dataset_manager.formats.imagenet import cvat.apps.dataset_manager.formats.camvid +import cvat.apps.dataset_manager.formats.widerface diff --git a/cvat/apps/dataset_manager/formats/widerface.py b/cvat/apps/dataset_manager/formats/widerface.py new file mode 100644 index 000000000000..7f120ffe2154 --- /dev/null +++ b/cvat/apps/dataset_manager/formats/widerface.py @@ -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='WiderFace', 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, 'wider_face', save_images=save_images) + + make_zip_archive(temp_dir, dst_file) + +@importer(name='WiderFace', 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, 'wider_face', env=dm_env) + import_dm_annotations(dataset, task_data) diff --git a/cvat/apps/dataset_manager/tests/test_formats.py b/cvat/apps/dataset_manager/tests/test_formats.py index a01e60b78ae7..4ba65e34c428 100644 --- a/cvat/apps/dataset_manager/tests/test_formats.py +++ b/cvat/apps/dataset_manager/tests/test_formats.py @@ -271,6 +271,7 @@ def test_export_formats_query(self): 'YOLO 1.1', 'ImageNet 1.0', 'CamVid 1.0', + 'WiderFace 1.0', }) def test_import_formats_query(self): @@ -289,6 +290,7 @@ def test_import_formats_query(self): 'YOLO 1.1', 'ImageNet 1.0', 'CamVid 1.0', + 'WiderFace 1.0', }) def test_exports(self): @@ -326,6 +328,7 @@ def test_empty_images_are_exported(self): ('YOLO 1.1', 'yolo'), ('ImageNet 1.0', 'imagenet_txt'), ('CamVid 1.0', 'camvid'), + ('WiderFace 1.0', 'wider_face'), ]: with self.subTest(format=format_name): if not dm.formats.registry.EXPORT_FORMATS[format_name].ENABLED: diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index d9d2c182a8e0..a5c450a06ab6 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -2597,6 +2597,32 @@ def _create_task(self, owner, assignee): ] }, {"name": "person"}, + { + "name": "widerface", + "attributes": [ + { + "name": "blur", + "mutable": False, + "input_type": "select", + "default_value": "0", + "values": ["0", "1", "2"] + }, + { + "name": "expression", + "mutable": False, + "input_type": "select", + "default_value": "0", + "values": ["0", "1"] + }, + { + "name": "illumination", + "mutable": False, + "input_type": "select", + "default_value": "0", + "values": ["0", "1"] + }, + ] + }, ] } @@ -3718,6 +3744,30 @@ def _get_initial_annotation(annotation_format): "occluded": False, }] + rectangle_shapes_with_wider_attrs = [{ + "frame": 0, + "label_id": task["labels"][2]["id"], + "group": 0, + "source": "manual", + "attributes": [ + { + "spec_id": task["labels"][2]["attributes"][0]["id"], + "value": task["labels"][2]["attributes"][0]["default_value"] + }, + { + "spec_id": task["labels"][2]["attributes"][1]["id"], + "value": task["labels"][2]["attributes"][1]["values"][1] + }, + { + "spec_id": task["labels"][2]["attributes"][2]["id"], + "value": task["labels"][2]["attributes"][2]["default_value"] + } + ], + "points": [1.0, 2.1, 10.6, 53.22], + "type": "rectangle", + "occluded": False, + }] + rectangle_shapes_wo_attrs = [{ "frame": 1, "label_id": task["labels"][1]["id"], @@ -3855,6 +3905,10 @@ def _get_initial_annotation(annotation_format): annotations["shapes"] = rectangle_shapes_wo_attrs \ + polygon_shapes_wo_attrs + elif annotation_format == "WiderFace 1.0": + annotations["tags"] = tags_wo_attrs + annotations["shapes"] = rectangle_shapes_with_wider_attrs + else: raise Exception("Unknown format {}".format(annotation_format)) From 0fa3d3b37a72eb0b77d0201a5e459ce89ca3b29c Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Thu, 25 Feb 2021 10:37:37 +0300 Subject: [PATCH 02/11] Add WiderFace to documentation --- README.md | 1 + cvat/apps/dataset_manager/formats/README.md | 30 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index dd8b68c6b56d..52c71db13045 100644 --- a/README.md +++ b/README.md @@ -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 | | [ImageNet](http://www.image-net.org) | X | X | | [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/) | X | X | +| [WIDER Face](http://shuoyang1213.me/WIDERFACE/) | X | X | ## Deep learning serverless functions for automatic labeling diff --git a/cvat/apps/dataset_manager/formats/README.md b/cvat/apps/dataset_manager/formats/README.md index 38ff06762172..218d62888941 100644 --- a/cvat/apps/dataset_manager/formats/README.md +++ b/cvat/apps/dataset_manager/formats/README.md @@ -20,6 +20,7 @@ - [TF detection API](#tfrecord) - [ImageNet](#imagenet) - [CamVid](#camvid) + - [WIDER Face](#widerface) ## How to add a new annotation format support @@ -874,3 +875,32 @@ has own color which corresponds to a label. Uploaded file: a zip archive of the structure above - supported annotations: Polygons + +### [WIDER Face](http://shuoyang1213.me/WIDERFACE/) + +#### WIDER Face Dumper + +Downloaded file: a zip archive of the following structure: + +```bash +taskname.zip/ +├── labels.txt # optional +└── WIDER_/ + └── images + ├── 0--label0/ + └── 0_label0_image1.jpg + └── 1--label1/ + └── 1_label1_image2.jpg +└── wider_face_split/ + └── wider_face__bbx_gt.txt +``` + +- supported annotations: Rectangles (with attributes), Labels +- supported attributes: `blur`, `expression`, `illumination`, `occlused`, `pose`, `invalid` + +#### WIDER Face Loader + +Uploaded file: a zip archive of the structure above + +- supported annotations: Rectangles (with attributes), Labels +- supported attributes: `blur`, `expression`, `illumination`, `occlused`, `pose`, `invalid` From b523a991810b9a179bd62ecaf03195ad89134e0f Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Mon, 1 Mar 2021 11:59:23 +0300 Subject: [PATCH 03/11] update format docs --- cvat/apps/dataset_manager/formats/README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cvat/apps/dataset_manager/formats/README.md b/cvat/apps/dataset_manager/formats/README.md index 218d62888941..ae5887970c0e 100644 --- a/cvat/apps/dataset_manager/formats/README.md +++ b/cvat/apps/dataset_manager/formats/README.md @@ -885,22 +885,23 @@ Downloaded file: a zip archive of the following structure: ```bash taskname.zip/ ├── labels.txt # optional -└── WIDER_/ - └── images - ├── 0--label0/ - └── 0_label0_image1.jpg - └── 1--label1/ - └── 1_label1_image2.jpg +├── WIDER_/ +| └── images +| ├── 0--label0/ +| | └── 0_label0_image1.jpg +| └── 1--label1/ +| └── 1_label1_image2.jpg └── wider_face_split/ └── wider_face__bbx_gt.txt ``` - supported annotations: Rectangles (with attributes), Labels -- supported attributes: `blur`, `expression`, `illumination`, `occlused`, `pose`, `invalid` +- supported attributes: `blur`, `expression`, `illumination`, + `occluded` (both the annotation property & an attribute), `pose`, `invalid` #### WIDER Face Loader Uploaded file: a zip archive of the structure above - supported annotations: Rectangles (with attributes), Labels -- supported attributes: `blur`, `expression`, `illumination`, `occlused`, `pose`, `invalid` +- supported attributes: `blur`, `expression`, `illumination`, `occluded`, `pose`, `invalid` From 2220b5b9e7e139af297c53cd92b1efb3f46da524 Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Mon, 1 Mar 2021 12:02:56 +0300 Subject: [PATCH 04/11] Fix format descriptions --- cvat/apps/dataset_manager/formats/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cvat/apps/dataset_manager/formats/README.md b/cvat/apps/dataset_manager/formats/README.md index 218d62888941..00b874b72f5e 100644 --- a/cvat/apps/dataset_manager/formats/README.md +++ b/cvat/apps/dataset_manager/formats/README.md @@ -885,14 +885,14 @@ Downloaded file: a zip archive of the following structure: ```bash taskname.zip/ ├── labels.txt # optional +├── wider_face_split/ +│   └── wider_face__bbx_gt.txt └── WIDER_/ - └── images + └── images/ ├── 0--label0/ - └── 0_label0_image1.jpg + │  └── 0_label0_image1.jpg └── 1--label1/ └── 1_label1_image2.jpg -└── wider_face_split/ - └── wider_face__bbx_gt.txt ``` - supported annotations: Rectangles (with attributes), Labels From e414a1802805573540c017ed727b862c717b2f79 Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 2 Mar 2021 12:52:29 +0300 Subject: [PATCH 05/11] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b514f5104134..4a68920fea94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pre-built [cvat_server](https://hub.docker.com/r/openvino/cvat_server) and [cvat_ui](https://hub.docker.com/r/openvino/cvat_ui) images were published on DockerHub () - Project task subsets () +- [WiderFace](http://shuoyang1213.me/WIDERFACE/) format support () ### Changed From ddc7ec15c5caeb65e5fcde34e5c3ecc8fe91a5fe Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 2 Mar 2021 13:44:16 +0300 Subject: [PATCH 06/11] Update Datumaro version --- cvat/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvat/requirements/base.txt b/cvat/requirements/base.txt index c8a6bda47911..07648bd0ce7e 100644 --- a/cvat/requirements/base.txt +++ b/cvat/requirements/base.txt @@ -46,4 +46,4 @@ patool==1.12 diskcache==5.0.2 open3d==0.11.2 # workaround for binary incompatibility with numpy when pycocotools is installed by wheel -datumaro==0.1.5.1 --no-binary=datumaro --no-binary=pycocotools +datumaro==0.1.6 --no-binary=datumaro --no-binary=pycocotools From 56995781686ba42d562c35c3c9c38b4652a0fc26 Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 2 Mar 2021 17:52:46 +0300 Subject: [PATCH 07/11] Update Datumaro version to 0.1.6.1 --- cvat/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvat/requirements/base.txt b/cvat/requirements/base.txt index 07648bd0ce7e..e7fe7b5a9f1b 100644 --- a/cvat/requirements/base.txt +++ b/cvat/requirements/base.txt @@ -46,4 +46,4 @@ patool==1.12 diskcache==5.0.2 open3d==0.11.2 # workaround for binary incompatibility with numpy when pycocotools is installed by wheel -datumaro==0.1.6 --no-binary=datumaro --no-binary=pycocotools +datumaro==0.1.6.1 --no-binary=datumaro --no-binary=pycocotools From 18b3c4f5ce906d2783753b57941359ca692a7350 Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 2 Mar 2021 19:01:36 +0300 Subject: [PATCH 08/11] fix linter --- cvat/apps/engine/tests/test_rest_api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index a5c450a06ab6..6f08bbf4f740 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -16,8 +16,6 @@ from glob import glob from io import BytesIO from unittest import mock -import open3d as o3d -import struct import av import numpy as np @@ -739,7 +737,7 @@ def _run_api_v1_users(self, user): 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) for user_info in response.data['results']: db_user = getattr(self, user_info['username']) From 801e1357070329eb0c70135caec33823536ff9ba Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Wed, 3 Mar 2021 17:08:06 +0300 Subject: [PATCH 09/11] fix base.txt --- cvat/requirements/base.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cvat/requirements/base.txt b/cvat/requirements/base.txt index e7fe7b5a9f1b..98ea74c5fec7 100644 --- a/cvat/requirements/base.txt +++ b/cvat/requirements/base.txt @@ -45,5 +45,9 @@ tensorflow==2.4.1 # Optional requirement of Datumaro patool==1.12 diskcache==5.0.2 open3d==0.11.2 -# workaround for binary incompatibility with numpy when pycocotools is installed by wheel +# --no-binary=datumaro: workaround for pip to install +# opencv-headless instead of regular opencv, to actually run setup script +# --no-binary=pycocotools: workaround for binary incompatibility on numpy 1.20 +# of pycocotools and tensorflow 2.4.1 +# when pycocotools is installed by wheel in python 3.8+ datumaro==0.1.6.1 --no-binary=datumaro --no-binary=pycocotools From 214e75ef5d714bb83fa47426f6a6bb148ea85392 Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 9 Mar 2021 11:12:53 +0300 Subject: [PATCH 10/11] fix Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcce801a8111..e351167ea542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [cvat_ui](https://hub.docker.com/r/openvino/cvat_ui) images were published on DockerHub () - Project task subsets () - [WiderFace](http://shuoyang1213.me/WIDERFACE/) format support () +- [VGGFace2](https://github.com/ox-vgg/vgg_face2) format support () ### Changed From 05330509d18b598f68c93f1c8ab6e688f6e6dddc Mon Sep 17 00:00:00 2001 From: yasakova-anastasia Date: Tue, 9 Mar 2021 11:16:43 +0300 Subject: [PATCH 11/11] fix README --- cvat/apps/dataset_manager/formats/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cvat/apps/dataset_manager/formats/README.md b/cvat/apps/dataset_manager/formats/README.md index c502efbf0bc5..a89cf6e1fb5f 100644 --- a/cvat/apps/dataset_manager/formats/README.md +++ b/cvat/apps/dataset_manager/formats/README.md @@ -20,10 +20,8 @@ - [TF detection API](#tfrecord) - [ImageNet](#imagenet) - [CamVid](#camvid) - <<<<<<< HEAD - - # [WIDER Face](#widerface) + - [WIDER Face](#widerface) - [VGGFace2](#vggface2) - > > > > > > > develop ## How to add a new annotation format support