Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix holes in exported instance masks #3044

Merged
merged 9 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ICDAR](https://rrc.cvc.uab.es/?ch=2) format support (<https://github.com/openvinotoolkit/cvat/pull/2866>)
- Added switcher to maintain poylgon crop behaviour (<https://github.com/openvinotoolkit/cvat/pull/3021>
- Filters and sorting options for job list, added tooltip for tasks filters (<https://github.com/openvinotoolkit/cvat/pull/3030>)
- Documentation on mask annotation (<https://github.com/openvinotoolkit/cvat/pull/3044>)
zhiltsov-max marked this conversation as resolved.
Show resolved Hide resolved

### Changed

Expand Down Expand Up @@ -85,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Incorrect text on the warning when specifying an incorrect link to the issue tracker (<https://github.com/openvinotoolkit/cvat/pull/2971>)
- Updating label attributes when label contains number attributes (<https://github.com/openvinotoolkit/cvat/pull/2969>)
- Crop a polygon if its points are outside the bounds of the image (<https://github.com/openvinotoolkit/cvat/pull/3025>)
- Export of instance masks with holes (<https://github.com/openvinotoolkit/cvat/pull/3044>)

### Security

Expand Down
138 changes: 103 additions & 35 deletions cvat/apps/dataset_manager/formats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [How to add a format](#how-to-add)
- [Format descriptions](#formats)
- [CVAT](#cvat)
- [Datumaro](#datumaro)
- [LabelMe](#labelme)
- [MOT](#mot)
- [MOTS](#mots)
Expand Down Expand Up @@ -175,7 +176,7 @@ features, so it can be used to make data backups.

- [Format specification](/cvat/apps/documentation/xml_format.md)

#### CVAT for images dumper
#### CVAT for images export

Downloaded file: a ZIP file of the following structure:

Expand All @@ -189,7 +190,7 @@ taskname.zip/

- tracks are split by frames

#### CVAT for videos dumper
#### CVAT for videos export

Downloaded file: a ZIP file of the following structure:

Expand All @@ -207,6 +208,17 @@ taskname.zip/

Uploaded file: an XML file or a ZIP file of the structures above

### Datumaro format <a id="datumaro" />

[Datumaro](https://github.com/openvinotoolkit/datumaro/) is a tool, which can
help with complex dataset and annotation transformations, format conversions,
dataset statistics, merging, custom formats etc. It is used as a provider
of dataset support in CVAT, so basically, everything possible in CVAT
is possible in Datumaro too, but Datumaro can offer dataset operations.

- supported annotations: any 2D shapes, labels
- supported attributes: any

### [Pascal VOC](http://host.robots.ox.ac.uk/pascal/VOC/)<a id="voc" />

- [Format specification](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/devkit_doc.pdf)
Expand All @@ -219,17 +231,18 @@ Uploaded file: an XML file or a ZIP file of the structures above

- supported attributes:

- `occluded`
- `occluded` (both UI option and a separate attribute)
- `truncated` and `difficult` (should be defined for labels as `checkbox` -es)
- action attributes (import only, should be defined as `checkbox` -es)
- arbitrary attributes (in the `attributes` secion of XML files)

#### Pascal VOC export

Downloaded file: a zip archive of the following structure:

```bash
taskname.zip/
├── JpegImages/
├── JPEGImages/
│   ├── <image_name1>.jpg
│   ├── <image_name2>.jpg
│   └── <image_nameN>.jpg
Expand Down Expand Up @@ -499,17 +512,47 @@ zip images.zip -j -@ < train.txt

- [Format specification](http://cocodataset.org/#format-data)

#### COCO dumper description
#### COCO export

Downloaded file: single unpacked `json`.
Downloaded file: a zip archive with following structure:

```bash
archive.zip/
├── images/
│ ├── <image_name1.ext>
│ ├── <image_name2.ext>
│ └── ...
└── annotations/
   └── instances_default.json
```

- supported annotations: Polygons, Rectangles
- supported attributes:
- `is_crowd` (checkbox or integer with values 0 and 1) -
specifies that the instance (an object group) should have an
RLE-encoded mask in the `segmentation` field. All the grouped shapes
are merged into a single mask, the largest one defines all
the object properties
- `score` (number) - the annotation `score` field
- arbitrary attributes - will be stored in the `attributes` annotation section


*Note*: there is also a [support for COCO keypoints over Datumaro](https://github.com/openvinotoolkit/cvat/issues/2910#issuecomment-726077582)

#### COCO loader description
1. Install [Datumaro](https://github.com/openvinotoolkit/datumaro)
`pip install datumaro`
1. Export the task in the `Datumaro` format, unzip
1. Export the Datumaro project in `coco` / `coco_person_keypoints` formats
`datum export -f coco -p path/to/project [-- --save-images]`

Uploaded file: single unpacked `*.json` .
This way, one can export CVAT points as single keypoints or
keypoint lists (without the `visibility` COCO flag).

- supported annotations: Polygons, Rectangles (if `segmentation` field is empty)
#### COCO import

Uploaded file: a single unpacked `*.json` or a zip archive with the structure above (without images).

- supported annotations: Polygons, Rectangles (if the `segmentation` field is empty)

#### How to create a task from MS COCO dataset

Expand Down Expand Up @@ -559,25 +602,48 @@ image_feature_description = {
}
```

#### TFRecord dumper description
#### TFRecord export

Downloaded file: a zip archive with following structure:

```bash
taskname.zip/
├── task2.tfrecord
├── default.tfrecord
└── label_map.pbtxt

# label_map.pbtxt
item {
id: 1
name: 'label_0'
}
item {
id: 2
name: 'label_1'
}
...
```

- supported annotations: Rectangles
- supported annotations: Rectangles, Polygons (as masks, manually over [Datumaro](https://github.com/openvinotoolkit/datumaro/blob/develop/docs/user_manual.md))

#### TFRecord loader description
How to export masks:
1. Export annotations in `Datumaro` format
1. Apply `polygons_to_masks` and `boxes_to_masks` transforms
```bash
datum transform -t polygons_to_masks -p path/to/proj -o ptm
datum transform -t boxes_to_masks -p ptm -o btm
```
1. Export in the `TF Detection API` format
```bash
datum export -f tf_detection_api -p btm [-- --save-images]
```

#### TFRecord import

Uploaded file: a zip archive of following structure:

```bash
taskname.zip/
└── task2.tfrecord
└── <any name>.tfrecord
```

- supported annotations: Rectangles
Expand Down Expand Up @@ -706,7 +772,7 @@ python create_pascal_tf_record.py --data_dir <path to VOCdevkit> --set train --y

### [MOT sequence](https://arxiv.org/pdf/1906.04567.pdf)<a id="mot" />

#### MOT Dumper
#### MOT export

Downloaded file: a zip archive of the following structure:

Expand Down Expand Up @@ -735,7 +801,7 @@ person
- supported annotations: Rectangle shapes and tracks
- supported attributes: `visibility` (number), `ignored` (checkbox)

#### MOT Loader
#### MOT import

Uploaded file: a zip archive of the structure above or:

Expand All @@ -749,7 +815,7 @@ taskname.zip/

### [MOTS PNG](https://www.vision.rwth-aachen.de/page/mots)<a id="mots" />

#### MOTS PNG Dumper
#### MOTS PNG export

Downloaded file: a zip archive of the following structure:

Expand All @@ -773,15 +839,15 @@ person

- supported annotations: Rectangle and Polygon tracks

#### MOTS PNG Loader
#### MOTS PNG import

Uploaded file: a zip archive of the structure above

- supported annotations: Polygon tracks

### [LabelMe](http://labelme.csail.mit.edu/Release3.0)<a id="labelme" />

#### LabelMe Dumper
#### LabelMe export

Downloaded file: a zip archive of the following structure:

Expand All @@ -793,7 +859,7 @@ taskname.zip/

- supported annotations: Rectangles, Polygons (with attributes)

#### LabelMe Loader
#### LabelMe import

Uploaded file: a zip archive of the following structure:

Expand All @@ -811,7 +877,7 @@ taskname.zip/

### [ImageNet](http://www.image-net.org)<a id="imagenet" />

#### ImageNet Dumper
#### ImageNet export

Downloaded file: a zip archive of the following structure:

Expand All @@ -835,15 +901,15 @@ taskname.zip/

- supported annotations: Labels

#### ImageNet Loader
#### ImageNet import

Uploaded file: a zip archive of the structure above

- supported annotations: Labels

### [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/)<a id="camvid" />

#### CamVid Dumper
#### CamVid export

Downloaded file: a zip archive of the following structure:

Expand Down Expand Up @@ -873,15 +939,15 @@ has own color which corresponds to a label.

- supported annotations: Rectangles, Polygons

#### CamVid Loader
#### CamVid import

Uploaded file: a zip archive of the structure above

- supported annotations: Polygons

### [WIDER Face](http://shuoyang1213.me/WIDERFACE/)<a id="widerface" />

#### WIDER Face Dumper
#### WIDER Face export

Downloaded file: a zip archive of the following structure:

Expand All @@ -899,19 +965,21 @@ taskname.zip/
```

- supported annotations: Rectangles (with attributes), Labels
- supported attributes: `blur`, `expression`, `illumination`,
`occluded` (both the annotation property & an attribute), `pose`, `invalid`
- supported attributes:
- `blur`, `expression`, `illumination`, `pose`, `invalid`
- `occluded` (both the annotation property & an attribute)

#### WIDER Face Loader
#### WIDER Face import

Uploaded file: a zip archive of the structure above

- supported annotations: Rectangles (with attributes), Labels
- supported attributes: `blur`, `expression`, `illumination`, `occluded`, `pose`, `invalid`
- supported attributes:
- `blur`, `expression`, `illumination`, `occluded`, `pose`, `invalid`

### [VGGFace2](https://github.com/ox-vgg/vgg_face2)<a id="vggface2" />

#### VGGFace2 Dumper
#### VGGFace2 export

Downloaded file: a zip archive of the following structure:

Expand All @@ -934,15 +1002,15 @@ label1 <class1>

- supported annotations: Rectangles, Points (landmarks - groups of 5 points)

#### VGGFace2 Loader
#### VGGFace2 import

Uploaded file: a zip archive of the structure above

- supported annotations: Rectangles, Points (landmarks - groups of 5 points)

### [Market-1501](https://www.aitribune.com/dataset/2018051063)<a id="market1501" />

#### Market-1501 Dumper
#### Market-1501 export

Downloaded file: a zip archive of the following structure:

Expand Down Expand Up @@ -970,15 +1038,15 @@ s1 - sequence

- supported annotations: Label `market-1501` with atrributes (`query`, `person_id`, `camera_id`)

#### Market-1501 Loader
#### Market-1501 import

Uploaded file: a zip archive of the structure above

- supported annotations: Label `market-1501` with atrributes (`query`, `person_id`, `camera_id`)

### [ICDAR13/15](https://rrc.cvc.uab.es/?ch=2)<a id="icdar" />

#### ICDAR13/15 Dumper
#### ICDAR13/15 export

Downloaded file: a zip archive of the following structure:

Expand Down Expand Up @@ -1027,7 +1095,7 @@ taskname.zip/
- supported annotations: Rectangles and Polygons with label `icdar`
and attributes `index`, `text`, `color`, `center`

#### ICDAR13/15 Loader
#### ICDAR13/15 import

Uploaded file: a zip archive of the structure above

Expand Down
3 changes: 2 additions & 1 deletion cvat/apps/dataset_manager/formats/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ 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, 'coco_instances', save_images=save_images)
dataset.export(temp_dir, 'coco_instances', save_images=save_images,
merge_images=True)

make_zip_archive(temp_dir, dst_file)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading