Skip to content

Commit

Permalink
Merge branch 'cvat-ai:develop' into opencv-image-clahe
Browse files Browse the repository at this point in the history
  • Loading branch information
denck007 authored Jan 6, 2025
2 parents 57ecbe4 + 25245e6 commit 2053b10
Show file tree
Hide file tree
Showing 176 changed files with 986 additions and 659 deletions.
30 changes: 3 additions & 27 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: files
uses: tj-actions/[email protected]
with:
files: |
cvat-sdk/**/*.py
cvat-cli/**/*.py
tests/python/**/*.py
cvat/apps/quality_control/**/*.py
cvat/apps/analytics_report/**/*.py
dir_names: true

- name: Run checks
run: |
# If different modules use different isort configs,
# we need to run isort for each python component group separately.
# Otherwise, they all will use the same config.
pipx install $(grep "^isort" ./dev/requirements.txt)
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"
echo "isort version: $(isort --version-number)"
if [[ ! -z $UPDATED_DIRS ]]; then
pipx install $(grep "^isort" ./dev/requirements.txt)
echo "isort version: $(isort --version-number)"
echo "The dirs will be checked: $UPDATED_DIRS"
EXIT_CODE=0
for DIR in $UPDATED_DIRS; do
isort --check $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true
done
exit $EXIT_CODE
else
echo "No files with the \"py\" extension found"
fi
isort --check --diff --resolve-all-configs .
1 change: 1 addition & 0 deletions cvat-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ profile = "black"
forced_separate = ["tests"]
line_length = 100
skip_gitignore = true # align tool behavior with Black
known_first_party = ["cvat_sdk"]
10 changes: 5 additions & 5 deletions cvat/apps/dataset_manager/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
#
# SPDX-License-Identifier: MIT

from copy import copy, deepcopy

import math
from collections.abc import Container, Sequence
from copy import copy, deepcopy
from itertools import chain
from typing import Optional

import numpy as np
from itertools import chain
from scipy.optimize import linear_sum_assignment
from shapely import geometry

from cvat.apps.engine.models import ShapeType, DimensionType
from cvat.apps.engine.serializers import LabeledDataSerializer
from cvat.apps.dataset_manager.util import faster_deepcopy
from cvat.apps.engine.models import DimensionType, ShapeType
from cvat.apps.engine.serializers import LabeledDataSerializer


class AnnotationIR:
Expand Down
28 changes: 19 additions & 9 deletions cvat/apps/dataset_manager/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,39 @@
from types import SimpleNamespace
from typing import Any, Callable, Literal, NamedTuple, Optional, Union

from attrs.converters import to_bool
import datumaro as dm
import defusedxml.ElementTree as ET
import rq
from attr import attrib, attrs
from attrs.converters import to_bool
from datumaro.components.format_detection import RejectionReason
from django.conf import settings
from django.db.models import Prefetch, QuerySet
from django.utils import timezone
from django.conf import settings

from cvat.apps.dataset_manager.formats.utils import get_label_color
from cvat.apps.dataset_manager.util import add_prefetch_fields
from cvat.apps.engine import models
from cvat.apps.engine.frame_provider import TaskFrameProvider, FrameQuality, FrameOutputType
from cvat.apps.engine.models import (AttributeSpec, AttributeType, DimensionType, Job,
JobType, Label, LabelType, Project, SegmentType, ShapeType,
Task)
from cvat.apps.engine.rq_job_handler import RQJobMetaField
from cvat.apps.engine.frame_provider import FrameOutputType, FrameQuality, TaskFrameProvider
from cvat.apps.engine.lazy_list import LazyList
from cvat.apps.engine.models import (
AttributeSpec,
AttributeType,
DimensionType,
Job,
JobType,
Label,
LabelType,
Project,
SegmentType,
ShapeType,
Task,
)
from cvat.apps.engine.rq_job_handler import RQJobMetaField

from .annotation import AnnotationIR, AnnotationManager, TrackManager
from .formats.transformations import MaskConverter, EllipsesToMasks
from ..engine.log import ServerLogManager
from .annotation import AnnotationIR, AnnotationManager, TrackManager
from .formats.transformations import EllipsesToMasks, MaskConverter

slogger = ServerLogManager(__name__)

Expand Down
5 changes: 2 additions & 3 deletions cvat/apps/dataset_manager/formats/camvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
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.bindings import GetCVATDataExtractor, import_dm_annotations
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .utils import make_colormap


Expand Down
9 changes: 6 additions & 3 deletions cvat/apps/dataset_manager/formats/cityscapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
from datumaro.plugins.cityscapes_format import write_label_map
from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .utils import make_colormap


Expand Down
8 changes: 6 additions & 2 deletions cvat/apps/dataset_manager/formats/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

import zipfile

from datumaro.components.dataset import Dataset
from datumaro.components.annotation import AnnotationType
from datumaro.components.dataset import Dataset
from datumaro.plugins.coco_format.importer import CocoImporter

from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor, NoMediaInAnnotationFileError, import_dm_annotations, detect_dataset
GetCVATDataExtractor,
NoMediaInAnnotationFileError,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .registry import dm_env, exporter, importer


@exporter(name='COCO', ext='ZIP', version='1.0')
def _export(dst_file, temp_dir, instance_data, save_images=False):
with GetCVATDataExtractor(instance_data, include_images=save_images) as extractor:
Expand Down
23 changes: 14 additions & 9 deletions cvat/apps/dataset_manager/formats/cvat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@
from io import BufferedWriter
from typing import Callable, Union

from datumaro.components.annotation import (AnnotationType, Bbox, Label,
LabelCategories, Points, Polygon,
PolyLine, Skeleton)
from datumaro.components.annotation import (
AnnotationType,
Bbox,
Label,
LabelCategories,
Points,
Polygon,
PolyLine,
Skeleton,
)
from datumaro.components.dataset import Dataset, DatasetItem
from datumaro.components.extractor import (DEFAULT_SUBSET_NAME, Extractor,
Importer)
from datumaro.components.extractor import DEFAULT_SUBSET_NAME, Extractor, Importer
from datumaro.plugins.cvat_format.extractor import CvatImporter as _CvatImporter

from datumaro.util.image import Image
from defusedxml import ElementTree

from cvat.apps.dataset_manager.bindings import (
JobData,
NoMediaInAnnotationFileError,
ProjectData,
TaskData,
JobData,
detect_dataset,
get_defaulted_subset,
import_dm_annotations,
match_dm_item
match_dm_item,
)
from cvat.apps.dataset_manager.util import make_zip_archive
from cvat.apps.engine.frame_provider import FrameQuality, FrameOutputType, make_frame_provider
from cvat.apps.engine.frame_provider import FrameOutputType, FrameQuality, make_frame_provider

from .registry import dm_env, exporter, importer

Expand Down
6 changes: 5 additions & 1 deletion cvat/apps/dataset_manager/formats/datumaro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# SPDX-License-Identifier: MIT

import zipfile

from datumaro.components.dataset import Dataset

from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor, import_dm_annotations, NoMediaInAnnotationFileError, detect_dataset
GetCVATDataExtractor,
NoMediaInAnnotationFileError,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive
from cvat.apps.engine.models import DimensionType
Expand Down
8 changes: 3 additions & 5 deletions cvat/apps/dataset_manager/formats/icdar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

import zipfile

from datumaro.components.annotation import (AnnotationType, Caption, Label,
LabelCategories)
from datumaro.components.annotation import AnnotationType, Caption, Label, LabelCategories
from datumaro.components.dataset import Dataset
from datumaro.components.extractor import ItemTransform

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import GetCVATDataExtractor, import_dm_annotations
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons


class AddLabelToAnns(ItemTransform):
Expand Down
3 changes: 1 addition & 2 deletions cvat/apps/dataset_manager/formats/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

from datumaro.components.dataset import Dataset

from cvat.apps.dataset_manager.bindings import GetCVATDataExtractor, \
import_dm_annotations
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
Expand Down
9 changes: 6 additions & 3 deletions cvat/apps/dataset_manager/formats/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@

from datumaro.components.dataset import Dataset
from datumaro.plugins.kitti_format.format import KittiPath, write_label_map

from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset, import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .utils import make_colormap


Expand Down
7 changes: 5 additions & 2 deletions cvat/apps/dataset_manager/formats/labelme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from datumaro.components.dataset import Dataset
from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.formats.transformations import MaskToPolygonTransformation
from cvat.apps.dataset_manager.util import make_zip_archive

Expand Down
7 changes: 5 additions & 2 deletions cvat/apps/dataset_manager/formats/lfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from datumaro.components.dataset import Dataset
from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .registry import dm_env, exporter, importer
Expand Down
11 changes: 7 additions & 4 deletions cvat/apps/dataset_manager/formats/market1501.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@

import zipfile

from datumaro.components.annotation import (AnnotationType, Label,
LabelCategories)
from datumaro.components.annotation import AnnotationType, Label, LabelCategories
from datumaro.components.dataset import Dataset
from datumaro.components.extractor import ItemTransform

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .registry import dm_env, exporter, importer


class AttrToLabelAttr(ItemTransform):
def __init__(self, extractor, label):
super().__init__(extractor)
Expand Down
10 changes: 7 additions & 3 deletions cvat/apps/dataset_manager/formats/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
from datumaro.components.dataset import Dataset
from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
import_dm_annotations)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .utils import make_colormap


@exporter(name='Segmentation mask', ext='ZIP', version='1.1')
def _export(dst_file, temp_dir, instance_data, save_images=False):
with GetCVATDataExtractor(instance_data, include_images=save_images) as extractor:
Expand Down
10 changes: 7 additions & 3 deletions cvat/apps/dataset_manager/formats/mots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
from datumaro.components.extractor import ItemTransform
from pyunpack import Archive

from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, detect_dataset,
find_dataset_root, match_dm_item)
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
find_dataset_root,
match_dm_item,
)
from cvat.apps.dataset_manager.util import make_zip_archive

from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons
from .registry import dm_env, exporter, importer
from .transformations import MaskToPolygonTransformation, RotatedBoxesToPolygons


class KeepTracks(ItemTransform):
Expand Down
Loading

0 comments on commit 2053b10

Please sign in to comment.