From 0b7fb04a09e67f4766da6add0e04e13c4bfee932 Mon Sep 17 00:00:00 2001 From: magician <1508907793@qq.com> Date: Tue, 8 Nov 2022 17:39:20 +0800 Subject: [PATCH] fix pascal_voc import bug (#4647) * fix pascal_voc import bug * Add tests * Fix black * Small fixes * Fix test * Fix black * Update Changelog * Fix Changelog * Fixes * Remove unnecessary changes * Remove unnecessary changes * Join tests * Small fix * Fixes * Fix pylint * Remove unused import * Small fix Co-authored-by: yasakova-anastasia --- CHANGELOG.md | 1 + cvat/apps/dataset_manager/bindings.py | 3 +++ tests/python/rest_api/test_projects.py | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afd6f709..c63edcfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ non-ascii paths while adding files from "Connected file share" (issue #4428) - Extra rerenders of different pages with each click () - Skeleton points exported out of order in the COCO Keypoints format () +- PASCAL VOC 1.1 can't import dataset () - Changing an object causes current z layer to be set to the maximum () - Job assignee can not resolve an issue () - Create manifest with cvat/server docker container command () diff --git a/cvat/apps/dataset_manager/bindings.py b/cvat/apps/dataset_manager/bindings.py index 2dc518cf..aba8362c 100644 --- a/cvat/apps/dataset_manager/bindings.py +++ b/cvat/apps/dataset_manager/bindings.py @@ -1895,6 +1895,9 @@ def load_dataset_data(project_annotation, dataset: dm.Dataset, project_data): else: for label in dataset.categories()[dm.AnnotationType.label].items: if not project_annotation.db_project.label_set.filter(name=label.name).exists(): + if label.name == "background": + dataset.transform("remap_labels", mapping={"background": ""}, default="keep") + continue raise CvatImportError(f'Target project does not have label with name "{label.name}"') for subset_id, subset in enumerate(dataset.subsets().values()): job = rq.get_current_job() diff --git a/tests/python/rest_api/test_projects.py b/tests/python/rest_api/test_projects.py index ff0a568d..5f5cb486 100644 --- a/tests/python/rest_api/test_projects.py +++ b/tests/python/rest_api/test_projects.py @@ -458,10 +458,11 @@ class TestImportExportDatasetProject: ) assert response.status == HTTPStatus.ACCEPTED - @pytest.mark.parametrize("format_name", ("ImageNet 1.0", "Datumaro 1.0")) + @pytest.mark.parametrize("format_name", ("Datumaro 1.0", "ImageNet 1.0", "PASCAL VOC 1.1")) def test_can_import_export_dataset_with_some_format(self, format_name): # https://github.com/opencv/cvat/issues/4410 # https://github.com/opencv/cvat/issues/4850 + # https://github.com/opencv/cvat/issues/4621 username = "admin1" project_id = 4