Skip to content

Commit 9f7d181

Browse files
yasakova-anastasiaMaxim Zhiltsov
and
Maxim Zhiltsov
authored
Support for WiderFace dataset format (cvat-ai#2864)
* Add support for WiderFace dataset format * Add WiderFace to documentation * update format docs * Fix format descriptions * Update Changelog * Update Datumaro version * Update Datumaro version to 0.1.6.1 * fix linter * fix base.txt * fix Changelog * fix README Co-authored-by: Maxim Zhiltsov <[email protected]>
1 parent 9fd4c03 commit 9f7d181

File tree

7 files changed

+124
-0
lines changed

7 files changed

+124
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Pre-built [cvat_server](https://hub.docker.com/r/openvino/cvat_server) and
2121
[cvat_ui](https://hub.docker.com/r/openvino/cvat_ui) images were published on DockerHub (<https://github.com/openvinotoolkit/cvat/pull/2766>)
2222
- Project task subsets (<https://github.com/openvinotoolkit/cvat/pull/2774>)
23+
- [WiderFace](http://shuoyang1213.me/WIDERFACE/) format support (<https://github.com/openvinotoolkit/cvat/pull/2864>)
24+
- [VGGFace2](https://github.com/ox-vgg/vgg_face2) format support (<https://github.com/openvinotoolkit/cvat/pull/2865>)
2325

2426
### Changed
2527

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ For more information about supported formats look at the
6262
| [LabelMe 3.0](http://labelme.csail.mit.edu/Release3.0) | X | X |
6363
| [ImageNet](http://www.image-net.org) | X | X |
6464
| [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/) | X | X |
65+
| [WIDER Face](http://shuoyang1213.me/WIDERFACE/) | X | X |
6566
| [VGGFace2](https://github.com/ox-vgg/vgg_face2) | X | X |
6667

6768
## Deep learning serverless functions for automatic labeling

cvat/apps/dataset_manager/formats/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- [TF detection API](#tfrecord)
2121
- [ImageNet](#imagenet)
2222
- [CamVid](#camvid)
23+
- [WIDER Face](#widerface)
2324
- [VGGFace2](#vggface2)
2425

2526
## How to add a new annotation format support<a id="how-to-add"></a>
@@ -876,6 +877,36 @@ Uploaded file: a zip archive of the structure above
876877

877878
- supported annotations: Polygons
878879

880+
### [WIDER Face](http://shuoyang1213.me/WIDERFACE/)<a id="widerface" />
881+
882+
#### WIDER Face Dumper
883+
884+
Downloaded file: a zip archive of the following structure:
885+
886+
```bash
887+
taskname.zip/
888+
├── labels.txt # optional
889+
├── wider_face_split/
890+
│ └── wider_face_<any_subset_name>_bbx_gt.txt
891+
└── WIDER_<any_subset_name>/
892+
└── images/
893+
├── 0--label0/
894+
│ └── 0_label0_image1.jpg
895+
└── 1--label1/
896+
└── 1_label1_image2.jpg
897+
```
898+
899+
- supported annotations: Rectangles (with attributes), Labels
900+
- supported attributes: `blur`, `expression`, `illumination`,
901+
`occluded` (both the annotation property & an attribute), `pose`, `invalid`
902+
903+
#### WIDER Face Loader
904+
905+
Uploaded file: a zip archive of the structure above
906+
907+
- supported annotations: Rectangles (with attributes), Labels
908+
- supported attributes: `blur`, `expression`, `illumination`, `occluded`, `pose`, `invalid`
909+
879910
### [VGGFace2](https://github.com/ox-vgg/vgg_face2)<a id="vggface2" />
880911

881912
#### VGGFace2 Dumper

cvat/apps/dataset_manager/formats/registry.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ def make_exporter(name):
9595
import cvat.apps.dataset_manager.formats.yolo
9696
import cvat.apps.dataset_manager.formats.imagenet
9797
import cvat.apps.dataset_manager.formats.camvid
98+
import cvat.apps.dataset_manager.formats.widerface
9899
import cvat.apps.dataset_manager.formats.vggface2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (C) 2021 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import zipfile
6+
from tempfile import TemporaryDirectory
7+
8+
from datumaro.components.dataset import Dataset
9+
10+
from cvat.apps.dataset_manager.bindings import CvatTaskDataExtractor, \
11+
import_dm_annotations
12+
from cvat.apps.dataset_manager.util import make_zip_archive
13+
14+
from .registry import dm_env, exporter, importer
15+
16+
17+
@exporter(name='WiderFace', ext='ZIP', version='1.0')
18+
def _export(dst_file, task_data, save_images=False):
19+
dataset = Dataset.from_extractors(CvatTaskDataExtractor(
20+
task_data, include_images=save_images), env=dm_env)
21+
with TemporaryDirectory() as temp_dir:
22+
dataset.export(temp_dir, 'wider_face', save_images=save_images)
23+
24+
make_zip_archive(temp_dir, dst_file)
25+
26+
@importer(name='WiderFace', ext='ZIP', version='1.0')
27+
def _import(src_file, task_data):
28+
with TemporaryDirectory() as tmp_dir:
29+
zipfile.ZipFile(src_file).extractall(tmp_dir)
30+
31+
dataset = Dataset.import_from(tmp_dir, 'wider_face', env=dm_env)
32+
import_dm_annotations(dataset, task_data)

cvat/apps/dataset_manager/tests/test_formats.py

+3
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def test_export_formats_query(self):
282282
'YOLO 1.1',
283283
'ImageNet 1.0',
284284
'CamVid 1.0',
285+
'WiderFace 1.0',
285286
'VGGFace2 1.0',
286287
})
287288

@@ -301,6 +302,7 @@ def test_import_formats_query(self):
301302
'YOLO 1.1',
302303
'ImageNet 1.0',
303304
'CamVid 1.0',
305+
'WiderFace 1.0',
304306
'VGGFace2 1.0',
305307
})
306308

@@ -342,6 +344,7 @@ def test_empty_images_are_exported(self):
342344
('YOLO 1.1', 'yolo'),
343345
('ImageNet 1.0', 'imagenet_txt'),
344346
('CamVid 1.0', 'camvid'),
347+
('WiderFace 1.0', 'wider_face'),
345348
('VGGFace2 1.0', 'vgg_face2'),
346349
]:
347350
with self.subTest(format=format_name):

cvat/apps/engine/tests/test_rest_api.py

+54
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,32 @@ def _create_task(self, owner, assignee):
25952595
]
25962596
},
25972597
{"name": "person"},
2598+
{
2599+
"name": "widerface",
2600+
"attributes": [
2601+
{
2602+
"name": "blur",
2603+
"mutable": False,
2604+
"input_type": "select",
2605+
"default_value": "0",
2606+
"values": ["0", "1", "2"]
2607+
},
2608+
{
2609+
"name": "expression",
2610+
"mutable": False,
2611+
"input_type": "select",
2612+
"default_value": "0",
2613+
"values": ["0", "1"]
2614+
},
2615+
{
2616+
"name": "illumination",
2617+
"mutable": False,
2618+
"input_type": "select",
2619+
"default_value": "0",
2620+
"values": ["0", "1"]
2621+
},
2622+
]
2623+
},
25982624
]
25992625
}
26002626

@@ -3716,6 +3742,30 @@ def _get_initial_annotation(annotation_format):
37163742
"occluded": False,
37173743
}]
37183744

3745+
rectangle_shapes_with_wider_attrs = [{
3746+
"frame": 0,
3747+
"label_id": task["labels"][2]["id"],
3748+
"group": 0,
3749+
"source": "manual",
3750+
"attributes": [
3751+
{
3752+
"spec_id": task["labels"][2]["attributes"][0]["id"],
3753+
"value": task["labels"][2]["attributes"][0]["default_value"]
3754+
},
3755+
{
3756+
"spec_id": task["labels"][2]["attributes"][1]["id"],
3757+
"value": task["labels"][2]["attributes"][1]["values"][1]
3758+
},
3759+
{
3760+
"spec_id": task["labels"][2]["attributes"][2]["id"],
3761+
"value": task["labels"][2]["attributes"][2]["default_value"]
3762+
}
3763+
],
3764+
"points": [1.0, 2.1, 10.6, 53.22],
3765+
"type": "rectangle",
3766+
"occluded": False,
3767+
}]
3768+
37193769
rectangle_shapes_wo_attrs = [{
37203770
"frame": 1,
37213771
"label_id": task["labels"][1]["id"],
@@ -3864,6 +3914,10 @@ def _get_initial_annotation(annotation_format):
38643914
annotations["shapes"] = rectangle_shapes_wo_attrs \
38653915
+ polygon_shapes_wo_attrs
38663916

3917+
elif annotation_format == "WiderFace 1.0":
3918+
annotations["tags"] = tags_wo_attrs
3919+
annotations["shapes"] = rectangle_shapes_with_wider_attrs
3920+
38673921
elif annotation_format == "VGGFace2 1.0":
38683922
annotations["tags"] = tags_wo_attrs
38693923
annotations["shapes"] = points_wo_attrs \

0 commit comments

Comments
 (0)