From 29c2a58b9d51f0c7c6ff861345c0bb3e8d5f8e99 Mon Sep 17 00:00:00 2001 From: Anastasia Yasakova Date: Wed, 22 Mar 2023 09:59:30 +0200 Subject: [PATCH] Fix invalid mask when running automatic annotation on a task (#5883) Fixed #5877 --- CHANGELOG.md | 1 + cvat/apps/lambda_manager/views.py | 32 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 268f5ae9d9b2..802b64c10832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - An invalid project/org handling in webhooks () - Warning `key` is undefined on project page () +- Invalid mask when running automatic annotation on a task () - Cloud storage content listing when the manifest name contains special characters () diff --git a/cvat/apps/lambda_manager/views.py b/cvat/apps/lambda_manager/views.py index f78ecd98a029..f3444a8b3126 100644 --- a/cvat/apps/lambda_manager/views.py +++ b/cvat/apps/lambda_manager/views.py @@ -5,32 +5,33 @@ import base64 import json -from functools import wraps -from enum import Enum -from copy import deepcopy +import os import textwrap +from copy import deepcopy +from enum import Enum +from functools import wraps from typing import Any, Dict, Optional +import datumaro.util.mask_tools as mask_tools import django_rq +import numpy as np import requests import rq -import os - from django.conf import settings from django.core.exceptions import ObjectDoesNotExist, ValidationError -from rest_framework import status, viewsets, serializers +from drf_spectacular.types import OpenApiTypes +from drf_spectacular.utils import (OpenApiParameter, OpenApiResponse, + extend_schema, extend_schema_view, + inline_serializer) +from rest_framework import serializers, status, viewsets from rest_framework.response import Response import cvat.apps.dataset_manager as dm from cvat.apps.engine.frame_provider import FrameProvider -from cvat.apps.engine.models import Job, Task +from cvat.apps.engine.models import Job, ShapeType, SourceType, Task, DataChoice from cvat.apps.engine.serializers import LabeledDataSerializer -from cvat.apps.engine.models import ShapeType, SourceType, DataChoice from cvat.utils.http import make_requests_session -from drf_spectacular.utils import (extend_schema, extend_schema_view, - OpenApiResponse, OpenApiParameter, inline_serializer) -from drf_spectacular.types import OpenApiTypes class LambdaType(Enum): DETECTOR = "detector" @@ -559,14 +560,7 @@ def reset(self): elif anno["type"] == "mask": [xtl, ytl, xbr, ybr] = shape["points"][-4:] cut_points = shape["points"][:-4] - rle = [0] - prev = shape["points"][0] - for val in cut_points: - if val == prev: - rle[-1] += 1 - else: - rle.append(1) - prev = val + rle = mask_tools.mask_to_rle(np.array(cut_points))["counts"].tolist() rle.extend([xtl, ytl, xbr, ybr]) shape["points"] = rle