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

Add LFW format #3770

Merged
merged 9 commits into from
Nov 9, 2021
Merged
Changes from 1 commit
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
Next Next commit
Add LFW
  • Loading branch information
kirill.sizov committed Oct 5, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 341323c92db1ccc1320bf8160ba8bf50c55bd8cf
29 changes: 29 additions & 0 deletions cvat/apps/dataset_manager/formats/lfw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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)
2 changes: 1 addition & 1 deletion cvat/apps/dataset_manager/formats/registry.py
Original file line number Diff line number Diff line change
@@ -109,4 +109,4 @@ def make_exporter(name):
import cvat.apps.dataset_manager.formats.icdar
import cvat.apps.dataset_manager.formats.velodynepoint
import cvat.apps.dataset_manager.formats.pointcloud

import cvat.apps.dataset_manager.formats.lfw
2 changes: 1 addition & 1 deletion cvat/apps/dataset_manager/formats/utils.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import os.path as osp
from hashlib import blake2s

from datumaro.cli.util import make_file_name
from datumaro.util.os_util import make_file_name


def get_color_from_index(index):
2 changes: 1 addition & 1 deletion cvat/apps/dataset_manager/views.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from datetime import timedelta

import django_rq
from datumaro.cli.util import make_file_name
from datumaro.util.os_util import make_file_name
from datumaro.util import to_snake_case
from django.utils import timezone