Add tags support for VOC (#1201)

* Extend voc format test with tags

* Add import and export of voc labels

* Fix voc and yolo format version numbers
main
zhiltsov-max 6 years ago committed by GitHub
parent 0d873a3de6
commit b3f7f5b8bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -339,7 +339,7 @@ It may take some time.
```bash ```bash
cat train.txt | while read p; do echo ${p%/*/*}/labels/${${p##*/}%%.*}.txt; done | zip labels.zip -j -@ obj.names 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. It may take some time.
### [MS COCO Object Detection](http://cocodataset.org/#format-data) ### [MS COCO Object Detection](http://cocodataset.org/#format-data)

@ -74,7 +74,7 @@ def dump(file_object, annotations):
extractor = CvatAnnotationsExtractor('', annotations) extractor = CvatAnnotationsExtractor('', annotations)
extractor = extractor.transform(id_from_image) extractor = extractor.transform(id_from_image)
extractor = Dataset.from_extractors(extractor) # apply lazy transforms extractor = Dataset.from_extractors(extractor) # apply lazy transforms
converter = env.make_converter('voc_detection') converter = env.make_converter('voc')
with TemporaryDirectory() as temp_dir: with TemporaryDirectory() as temp_dir:
converter(extractor, save_dir=temp_dir) converter(extractor, save_dir=temp_dir)
make_zip_archive(temp_dir, file_object) make_zip_archive(temp_dir, file_object)

@ -240,7 +240,7 @@ def import_dm_annotations(dm_dataset, cvat_task_anno):
for n, v in ann.attributes.items()], for n, v in ann.attributes.items()],
)) ))
elif ann.type == datumaro.AnnotationType.label: 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, frame=frame_number,
label=label_cat.items[ann.label].name, label=label_cat.items[ann.label].name,
group=group_map.get(ann.group, 0), group=group_map.get(ann.group, 0),

@ -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. is highlighted if a task has the interpolation mode.
- [CVAT XML 1.1 for images](/cvat/apps/documentation/xml_format.md#annotation) - [CVAT XML 1.1 for images](/cvat/apps/documentation/xml_format.md#annotation)
is highlighted if a task has the annotation mode. is highlighted if a task has the annotation mode.
- [PASCAL VOC ZIP 1.0](http://host.robots.ox.ac.uk/pascal/VOC/) - [PASCAL VOC ZIP 1.1](http://host.robots.ox.ac.uk/pascal/VOC/)
- [YOLO ZIP 1.0](https://pjreddie.com/darknet/yolo/) - [YOLO ZIP 1.1](https://pjreddie.com/darknet/yolo/)
- [COCO JSON 1.0](http://cocodataset.org/#format-data) - [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 - ``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. with the value of each color.
@ -523,8 +523,8 @@ Usage examples:
![](static/documentation/images/image029.jpg "Example XML format") ![](static/documentation/images/image029.jpg "Example XML format")
- [PASCAL VOC ZIP 1.0](http://host.robots.ox.ac.uk/pascal/VOC/) - [PASCAL VOC ZIP 1.1](http://host.robots.ox.ac.uk/pascal/VOC/)
- [YOLO ZIP 1.0](https://pjreddie.com/darknet/yolo/) - [YOLO ZIP 1.1](https://pjreddie.com/darknet/yolo/)
- [COCO JSON 1.0](http://cocodataset.org/#format-data) - [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 - ``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 the value of each color

@ -2660,13 +2660,13 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
tags_wo_attrs = [{ tags_wo_attrs = [{
"frame": 2, "frame": 2,
"label_id": task["labels"][1]["id"], "label_id": task["labels"][1]["id"],
"group": 3, "group": 0,
"attributes": [] "attributes": []
}] }]
tags_with_attrs = [{ tags_with_attrs = [{
"frame": 1, "frame": 1,
"label_id": task["labels"][0]["id"], "label_id": task["labels"][0]["id"],
"group": 0, "group": 3,
"attributes": [ "attributes": [
{ {
"spec_id": task["labels"][0]["attributes"][0]["id"], "spec_id": task["labels"][0]["attributes"][0]["id"],
@ -2693,10 +2693,13 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
+ polygon_shapes_wo_attrs + polygon_shapes_with_attrs + polygon_shapes_wo_attrs + polygon_shapes_with_attrs
annotations["tags"] = tags_with_attrs + tags_wo_attrs annotations["tags"] = tags_with_attrs + tags_wo_attrs
elif annotation_format == "PASCAL VOC ZIP 1.1" or \ elif annotation_format == "PASCAL VOC ZIP 1.1":
annotation_format == "YOLO ZIP 1.1" or \ annotations["shapes"] = rectangle_shapes_wo_attrs
annotations["tags"] = tags_wo_attrs
elif annotation_format == "YOLO ZIP 1.1" or \
annotation_format == "TFRecord ZIP 1.0": 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": elif annotation_format == "COCO JSON 1.0":
annotations["shapes"] = polygon_shapes_wo_attrs annotations["shapes"] = polygon_shapes_wo_attrs

@ -59,8 +59,8 @@ class _Converter:
elif isinstance(tasks, VocTask): elif isinstance(tasks, VocTask):
tasks = [tasks] tasks = [tasks]
else: else:
for t in tasks: tasks = [t if t in VocTask else VocTask[t] for t in tasks]
assert t in VocTask
self._tasks = tasks self._tasks = tasks
self._extractor = extractor self._extractor = extractor

Loading…
Cancel
Save