From 37bf02b43e76d06c64f194eaee316542ebb79bd7 Mon Sep 17 00:00:00 2001 From: Zhiltsov Max Date: Wed, 26 Feb 2020 17:23:25 +0300 Subject: [PATCH 1/3] Extend voc format test with tags --- cvat/apps/engine/tests/test_rest_api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index a1695650ae1..e363c674e0d 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -2693,10 +2693,13 @@ def _get_initial_annotation(annotation_format): + polygon_shapes_wo_attrs + polygon_shapes_with_attrs annotations["tags"] = tags_with_attrs + tags_wo_attrs - elif annotation_format == "PASCAL VOC ZIP 1.1" or \ - annotation_format == "YOLO ZIP 1.1" or \ + elif annotation_format == "PASCAL VOC ZIP 1.0": + annotations["shapes"] = rectangle_shapes_wo_attrs + annotations["tags"] = tags_wo_attrs + + elif annotation_format == "YOLO ZIP 1.0" or \ annotation_format == "TFRecord ZIP 1.0": - annotations["shapes"] = rectangle_shapes_wo_attrs + annotations["shapes"] = rectangle_shapes_wo_attrs elif annotation_format == "COCO JSON 1.0": annotations["shapes"] = polygon_shapes_wo_attrs From f9200759d1c861421ac79af117062c5297f32be7 Mon Sep 17 00:00:00 2001 From: Zhiltsov Max Date: Wed, 26 Feb 2020 18:18:29 +0300 Subject: [PATCH 2/3] Add import and export of voc labels --- cvat/apps/annotation/pascal_voc.py | 2 +- cvat/apps/dataset_manager/bindings.py | 2 +- cvat/apps/engine/tests/test_rest_api.py | 4 ++-- datumaro/datumaro/plugins/voc_format/converter.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cvat/apps/annotation/pascal_voc.py b/cvat/apps/annotation/pascal_voc.py index 801d1ba42e0..2dd0aa48f51 100644 --- a/cvat/apps/annotation/pascal_voc.py +++ b/cvat/apps/annotation/pascal_voc.py @@ -74,7 +74,7 @@ def dump(file_object, annotations): extractor = CvatAnnotationsExtractor('', annotations) extractor = extractor.transform(id_from_image) extractor = Dataset.from_extractors(extractor) # apply lazy transforms - converter = env.make_converter('voc_detection') + converter = env.make_converter('voc') with TemporaryDirectory() as temp_dir: converter(extractor, save_dir=temp_dir) make_zip_archive(temp_dir, file_object) \ No newline at end of file diff --git a/cvat/apps/dataset_manager/bindings.py b/cvat/apps/dataset_manager/bindings.py index f2b88723672..da37a3048e6 100644 --- a/cvat/apps/dataset_manager/bindings.py +++ b/cvat/apps/dataset_manager/bindings.py @@ -240,7 +240,7 @@ def import_dm_annotations(dm_dataset, cvat_task_anno): for n, v in ann.attributes.items()], )) elif ann.type == datumaro.AnnotationType.label: - cvat_task_anno.add_shape(cvat_task_anno.Tag( + cvat_task_anno.add_tag(cvat_task_anno.Tag( frame=frame_number, label=label_cat.items[ann.label].name, group=group_map.get(ann.group, 0), diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index e363c674e0d..cbb94eff1d2 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -2660,13 +2660,13 @@ def _get_initial_annotation(annotation_format): tags_wo_attrs = [{ "frame": 2, "label_id": task["labels"][1]["id"], - "group": 3, + "group": 0, "attributes": [] }] tags_with_attrs = [{ "frame": 1, "label_id": task["labels"][0]["id"], - "group": 0, + "group": 3, "attributes": [ { "spec_id": task["labels"][0]["attributes"][0]["id"], diff --git a/datumaro/datumaro/plugins/voc_format/converter.py b/datumaro/datumaro/plugins/voc_format/converter.py index 108fd499eab..4b82b4f547a 100644 --- a/datumaro/datumaro/plugins/voc_format/converter.py +++ b/datumaro/datumaro/plugins/voc_format/converter.py @@ -59,8 +59,8 @@ def __init__(self, extractor, save_dir, elif isinstance(tasks, VocTask): tasks = [tasks] else: - for t in tasks: - assert t in VocTask + tasks = [t if t in VocTask else VocTask[t] for t in tasks] + self._tasks = tasks self._extractor = extractor From c5b9a57147c380d83972cbdc3e1c0d760de0acf0 Mon Sep 17 00:00:00 2001 From: Zhiltsov Max Date: Mon, 2 Mar 2020 11:32:34 +0300 Subject: [PATCH 3/3] Fix voc and yolo format version numbers --- cvat/apps/annotation/README.md | 2 +- cvat/apps/documentation/user_guide.md | 8 ++++---- cvat/apps/engine/tests/test_rest_api.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cvat/apps/annotation/README.md b/cvat/apps/annotation/README.md index c41bc22469e..279d7a4d606 100644 --- a/cvat/apps/annotation/README.md +++ b/cvat/apps/annotation/README.md @@ -339,7 +339,7 @@ It may take some time. ```bash cat train.txt | while read p; do echo ${p%/*/*}/labels/${${p##*/}%%.*}.txt; done | zip labels.zip -j -@ obj.names ``` -1. Click `Upload annotation` button, choose `YOLO ZIP 1.0` and select the *.zip file with labels from previous step. +1. Click `Upload annotation` button, choose `YOLO ZIP 1.1` and select the *.zip file with labels from previous step. It may take some time. ### [MS COCO Object Detection](http://cocodataset.org/#format-data) diff --git a/cvat/apps/documentation/user_guide.md b/cvat/apps/documentation/user_guide.md index 594e64c4161..d51c596fdcd 100644 --- a/cvat/apps/documentation/user_guide.md +++ b/cvat/apps/documentation/user_guide.md @@ -214,8 +214,8 @@ Go to the [Django administration panel](http://localhost:8080/admin). There you is highlighted if a task has the interpolation mode. - [CVAT XML 1.1 for images](/cvat/apps/documentation/xml_format.md#annotation) is highlighted if a task has the annotation mode. - - [PASCAL VOC ZIP 1.0](http://host.robots.ox.ac.uk/pascal/VOC/) - - [YOLO ZIP 1.0](https://pjreddie.com/darknet/yolo/) + - [PASCAL VOC ZIP 1.1](http://host.robots.ox.ac.uk/pascal/VOC/) + - [YOLO ZIP 1.1](https://pjreddie.com/darknet/yolo/) - [COCO JSON 1.0](http://cocodataset.org/#format-data) - ``MASK ZIP 1.0`` — archive contains a mask of each frame in the png format and a text file with the value of each color. @@ -523,8 +523,8 @@ Usage examples: ![](static/documentation/images/image029.jpg "Example XML format") - - [PASCAL VOC ZIP 1.0](http://host.robots.ox.ac.uk/pascal/VOC/) - - [YOLO ZIP 1.0](https://pjreddie.com/darknet/yolo/) + - [PASCAL VOC ZIP 1.1](http://host.robots.ox.ac.uk/pascal/VOC/) + - [YOLO ZIP 1.1](https://pjreddie.com/darknet/yolo/) - [COCO JSON 1.0](http://cocodataset.org/#format-data) - ``MASK ZIP 1.0`` — archive contains a mask of each frame in the png format and a text file with the value of each color diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index cbb94eff1d2..d959f71c5b5 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -2693,11 +2693,11 @@ def _get_initial_annotation(annotation_format): + polygon_shapes_wo_attrs + polygon_shapes_with_attrs annotations["tags"] = tags_with_attrs + tags_wo_attrs - elif annotation_format == "PASCAL VOC ZIP 1.0": + elif annotation_format == "PASCAL VOC ZIP 1.1": annotations["shapes"] = rectangle_shapes_wo_attrs annotations["tags"] = tags_wo_attrs - elif annotation_format == "YOLO ZIP 1.0" or \ + elif annotation_format == "YOLO ZIP 1.1" or \ annotation_format == "TFRecord ZIP 1.0": annotations["shapes"] = rectangle_shapes_wo_attrs