-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add LFW format #3770
Merged
+150
−7
Merged
Add LFW format #3770
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
341323c
Add LFW
98b2e93
Add tests
7f792dc
Add documentation for LFW format
42c046e
Update CHANGELOG
d340b59
Fix UI test
bf74687
Merge branch 'develop' into sk/add-lfw
77a20e9
Add license
2061141
Update documentation
ca3bff2
Merge branch 'develop' into sk/add-lfw
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (C) 2021 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
from tempfile import TemporaryDirectory | ||
|
||
from datumaro.components.dataset import Dataset | ||
from pyunpack import Archive | ||
|
||
from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, | ||
import_dm_annotations) | ||
from cvat.apps.dataset_manager.util import make_zip_archive | ||
|
||
from .registry import dm_env, exporter, importer | ||
|
||
|
||
@importer(name='LFW', ext='ZIP', version='1.0') | ||
def _import(src_file, instance_data): | ||
with TemporaryDirectory() as tmp_dir: | ||
Archive(src_file.name).extractall(tmp_dir) | ||
|
||
dataset = Dataset.import_from(tmp_dir, 'lfw') | ||
|
||
import_dm_annotations(dataset, instance_data) | ||
|
||
@exporter(name='LFW', ext='ZIP', version='1.0') | ||
def _exporter(dst_file, instance_data, save_images=False): | ||
dataset = Dataset.from_extractors(GetCVATDataExtractor(instance_data, | ||
include_images=save_images), env=dm_env) | ||
with TemporaryDirectory() as tmp_dir: | ||
dataset.export(tmp_dir, format='lfw', save_images=save_images) | ||
|
||
make_zip_archive(tmp_dir, dst_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
site/content/en/docs/manual/advanced/formats/format-lfw.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
linkTitle: 'LFW' | ||
weight: 17 | ||
--- | ||
|
||
# [LFW](http://vis-www.cs.umass.edu/lfw/) | ||
|
||
- Format specification available [here](http://vis-www.cs.umass.edu/lfw/README.txt) | ||
|
||
- Supported annotations: tags, points. | ||
|
||
- Supported attributes: | ||
|
||
- `negative_pairs` (should be defined for labels as `text`): | ||
list of image names with mismatched persons. | ||
- `positive_pairs` (should be defined for labels as `text`): | ||
list of image names with matched persons. | ||
|
||
# Import LFW annotation | ||
|
||
The uploaded annotations file should be a zip file with the following structure: | ||
|
||
```bash | ||
<archive_name>.zip/ | ||
└── annotations/ | ||
├── landmarks.txt # list with landmark points for each image | ||
├── pairs.txt # list of matched and mismatched pairs of person | ||
└── people.txt # list of persons name | ||
``` | ||
|
||
Full information about the content of annotation files is available | ||
[here](http://vis-www.cs.umass.edu/lfw/README.txt) | ||
|
||
# Export LFW annotation | ||
|
||
Downloaded file: a zip archive of the following structure: | ||
|
||
```bash | ||
<archive_name>.zip/ | ||
└── images/ # if the option save images was selected | ||
│ ├── name1/ | ||
│ │ ├── name1_0001.jpg | ||
│ │ ├── name1_0002.jpg | ||
│ │ ├── ... | ||
│ ├── name2/ | ||
│ │ ├── name2_0001.jpg | ||
│ │ ├── name2_0002.jpg | ||
│ │ ├── ... | ||
│ ├── ... | ||
├── landmarks.txt | ||
├── pairs.txt | ||
└── people.txt | ||
``` | ||
|
||
# Example: create task with images and upload LFW annotations into it | ||
|
||
This is one of the possible ways to create a task and add LFW annotations for it. | ||
|
||
- On the task creation page: | ||
- Add labels that correspond to the names of the persons. | ||
- For each label define `text` attributes with names `positive_pairs` and | ||
`negative_pairs` | ||
- Add images using zip archive from local repository: | ||
|
||
```bash | ||
images.zip/ | ||
├── name1_0001.jpg | ||
├── name1_0002.jpg | ||
├── ... | ||
├── name1_<N>.jpg | ||
├── name2_0001.jpg | ||
├── ... | ||
``` | ||
|
||
- On the annotation page: | ||
Upload annotation -> LFW 1.0 -> choose archive with structure | ||
that described in the [import section](#import-lfw-annotation). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the file optional now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's. Added clarification about it.