Skip to content

Commit

Permalink
Merge pull request #6660 from opencv/release-2.6.0
Browse files Browse the repository at this point in the history
## \[2.6.0\] - 2023-08-11

### Added

- \[SDK\] Introduced the `DeferredTqdmProgressReporter` class,
  which avoids the glitchy output seen with the `TqdmProgressReporter` under certain circumstances
  (<#6556>)
- \[SDK, CLI\] Added the `cvat_sdk.auto_annotation`
  module, providing functionality to automatically annotate tasks
  by executing a user-provided function on the local machine.
  A corresponding CLI command (`auto-annotate`) is also available.
  Some predefined functions using torchvision are also available.
  (<#6483>,
  <#6649>)
- Included an indication for cached frames in the interface
  (<#6586>)

### Changed

- Raised the default guide assets limitations to 30 assets,
  with a maximum size of 10MB each
  (<#6575>)
- \[SDK\] Custom `ProgressReporter` implementations should now override `start2` instead of `start`
  The old implementation is still supported.
  (<#6556>)
- Improved memory optimization and code in the decoding module (<#6585>)

### Removed

- Removed the YOLOv5 serverless function
  (<#6618>)

### Fixed

- Corrected an issue where the prebuilt FFmpeg bundled in PyAV
  was being used instead of the custom build.
- Fixed the filename for labels in the CamVid format (<#6600>)
  • Loading branch information
SpecLad committed Aug 11, 2023
2 parents 8fc85eb + f416df1 commit 68e690f
Show file tree
Hide file tree
Showing 118 changed files with 3,448 additions and 1,902 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ jobs:
CHANGED_FILES="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $CHANGED_FILES ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install bandit
pipx install bandit
echo "Bandit version: "$(bandit --version | head -1)
echo "The files will be checked: "$(echo $CHANGED_FILES)
bandit -a file --ini .bandit $CHANGED_FILES
deactivate
else
echo "No files with the \"py\" extension found"
fi
7 changes: 1 addition & 6 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ jobs:
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $UPDATED_DIRS ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
pipx install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
echo "Black version: "$(black --version)
echo "The dirs will be checked: $UPDATED_DIRS"
EXIT_CODE=0
for DIR in $UPDATED_DIRS; do
black --check --diff $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true
done
deactivate
exit $EXIT_CODE
else
echo "No files with the \"py\" extension found"
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,19 @@ jobs:
name: expected_schema
path: cvat/schema-expected.yml

- name: Running REST API and SDK tests
id: run_tests
- name: Generate SDK
run: |
pip3 install -r cvat-sdk/gen/requirements.txt
./cvat-sdk/gen/generate.sh
pip3 install -r ./tests/python/requirements.txt
pip3 install -e ./cvat-sdk
pip3 install -e ./cvat-cli
- name: Install SDK
run: |
pip3 install -r ./tests/python/requirements.txt \
-e './cvat-sdk[pytorch]' -e ./cvat-cli
- name: Running REST API and SDK tests
id: run_tests
run: |
pytest tests/python/
- name: Creating a log file from cvat containers
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ jobs:
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $UPDATED_DIRS ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "isort.*" ./cvat-cli/requirements/development.txt)
pipx install $(egrep "isort.*" ./cvat-cli/requirements/development.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
deactivate
exit $EXIT_CODE
else
echo "No files with the \"py\" extension found"
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ jobs:
CHANGED_FILES="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $CHANGED_FILES ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "pylint.*==.*" ./cvat/requirements/development.txt)
pip install $(egrep "django==.*" ./cvat/requirements/base.txt)
pipx install $(egrep "^pylint==" ./cvat/requirements/development.txt)
pipx inject pylint \
$(egrep "^pylint-.+==" ./cvat/requirements/development.txt) \
$(egrep "^django==" ./cvat/requirements/base.txt)
echo "Pylint version: "$(pylint --version | head -1)
echo "The files will be checked: "$(echo $CHANGED_FILES)
pylint $CHANGED_FILES
deactivate
else
echo "No files with the \"py\" extension found"
fi
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@
"type": "node",
"request": "launch",
"name": "jest debug",
"cwd": "${workspaceFolder}/cvat-core",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--config",
Expand Down
40 changes: 39 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## \[2.6.0\] - 2023-08-11

### Added

- \[SDK\] Introduced the `DeferredTqdmProgressReporter` class,
which avoids the glitchy output seen with the `TqdmProgressReporter` under certain circumstances
(<https://github.com/opencv/cvat/pull/6556>)
- \[SDK, CLI\] Added the `cvat_sdk.auto_annotation`
module, providing functionality to automatically annotate tasks
by executing a user-provided function on the local machine.
A corresponding CLI command (`auto-annotate`) is also available.
Some predefined functions using torchvision are also available.
(<https://github.com/opencv/cvat/pull/6483>,
<https://github.com/opencv/cvat/pull/6649>)
- Included an indication for cached frames in the interface
(<https://github.com/opencv/cvat/pull/6586>)

### Changed

- Raised the default guide assets limitations to 30 assets,
with a maximum size of 10MB each
(<https://github.com/opencv/cvat/pull/6575>)
- \[SDK\] Custom `ProgressReporter` implementations should now override `start2` instead of `start`
The old implementation is still supported.
(<https://github.com/opencv/cvat/pull/6556>)
- Improved memory optimization and code in the decoding module (<https://github.com/opencv/cvat/pull/6585>)

### Removed

- Removed the YOLOv5 serverless function
(<https://github.com/opencv/cvat/pull/6618>)

### Fixed

- Corrected an issue where the prebuilt FFmpeg bundled in PyAV
was being used instead of the custom build.
- Fixed the filename for labels in the CamVid format (<https://github.com/opencv/cvat/pull/6600>)

## \[2.5.2\] - 2023-07-27

### Added
Expand Down Expand Up @@ -42,7 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/opencv/cvat/pull/6447>)
- \[API\] Fixed API issue related to file downloading failures for filenames with special characters (<https://github.com/opencv/cvat/pull/6492>)
- \[Helm\] In Helm, we've resolved an issue with multiple caches
in the same RWX volume, which was preventing db migration from starting (<https://github.com/opencv/cvat/pull/6137>)
in the same RWX volume, which was preventing db migration from starting (<https://github.com/opencv/cvat/pull/6137>)

## \[2.5.1\] - 2023-07-19

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ COPY utils/dataset_manifest/requirements.txt /tmp/utils/dataset_manifest/require
RUN grep -q '^av==' /tmp/utils/dataset_manifest/requirements.txt
RUN sed -i '/^av==/!d' /tmp/utils/dataset_manifest/requirements.txt

# Work around https://github.com/PyAV-Org/PyAV/issues/1140
RUN pip install setuptools wheel 'cython<3'

RUN --mount=type=cache,target=/root/.cache/pip/http \
python3 -m pip wheel \
python3 -m pip wheel --no-binary=av --no-build-isolation \
-r /tmp/utils/dataset_manifest/requirements.txt \
-w /tmp/wheelhouse

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:lts-slim AS cvat-ui
ARG WA_PAGE_VIEW_HIT
ARG UI_APP_CONFIG
ARG CLIENT_PLUGINS
ARG SOURCE_MAPS_TOKEN

ENV TERM=xterm \
LANG='C.UTF-8' \
Expand All @@ -27,7 +28,9 @@ COPY cvat-core/ /tmp/cvat-core/
COPY cvat-canvas3d/ /tmp/cvat-canvas3d/
COPY cvat-canvas/ /tmp/cvat-canvas/
COPY cvat-ui/ /tmp/cvat-ui/
RUN CLIENT_PLUGINS="${CLIENT_PLUGINS}" UI_APP_CONFIG="${UI_APP_CONFIG}" yarn run build:cvat-ui
RUN CLIENT_PLUGINS="${CLIENT_PLUGINS}" \
UI_APP_CONFIG="${UI_APP_CONFIG}" \
SOURCE_MAPS_TOKEN="${SOURCE_MAPS_TOKEN}" yarn run build:cvat-ui

FROM nginx:mainline-alpine
# Replace default.conf configuration to remove unnecessary rules
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ up to 10x. Here is a list of the algorithms we support, and the platforms they c
| [Object reidentification](/serverless/openvino/omz/intel/person-reidentification-retail-0277/nuclio) | reid | OpenVINO | ✔️ | |
| [Semantic segmentation for ADAS](/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio) | detector | OpenVINO | ✔️ | |
| [Text detection v4](/serverless/openvino/omz/intel/text-detection-0004/nuclio) | detector | OpenVINO | ✔️ | |
| [YOLO v5](/serverless/pytorch/ultralytics/yolov5/nuclio) | detector | PyTorch | ✔️ | |
| [SiamMask](/serverless/pytorch/foolwood/siammask/nuclio) | tracker | PyTorch | ✔️ | ✔️ |
| [TransT](/serverless/pytorch/dschoerk/transt/nuclio) | tracker | PyTorch | ✔️ | ✔️ |
| [f-BRS](/serverless/pytorch/saic-vul/fbrs/nuclio) | interactor | PyTorch | ✔️ | |
Expand Down
2 changes: 1 addition & 1 deletion cvat-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-canvas",
"version": "2.17.1",
"version": "2.17.3",
"description": "Part of Computer Vision Annotation Tool which presents its canvas library",
"main": "src/canvas.ts",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions cvat-canvas/src/typescript/canvasModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Size {
export interface Image {
renderWidth: number;
renderHeight: number;
imageData: ImageData | CanvasImageSource;
imageData: ImageBitmap;
}

export interface Position {
Expand Down Expand Up @@ -569,7 +569,7 @@ export class CanvasModelImpl extends MasterImpl implements CanvasModel {
.catch((exception: any): void => {
this.data.exception = exception;
// don't notify when the frame is no longer needed
if (typeof exception !== 'number' || exception === this.data.imageID) {
if (typeof exception !== 'number') {
this.notify(UpdateReasons.DATA_FAILED);
}
});
Expand Down
14 changes: 1 addition & 13 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1420,19 +1420,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
this.background.setAttribute('height', `${image.renderHeight}px`);

if (ctx) {
if (image.imageData instanceof ImageData) {
ctx.scale(
image.renderWidth / image.imageData.width,
image.renderHeight / image.imageData.height,
);
ctx.putImageData(image.imageData, 0, 0);
// Transformation matrix must not affect the putImageData() method.
// By this reason need to redraw the image to apply scale.
// https://www.w3.org/TR/2dcontext/#dom-context-2d-putimagedata
ctx.drawImage(this.background, 0, 0);
} else {
ctx.drawImage(image.imageData, 0, 0);
}
ctx.drawImage(image.imageData, 0, 0, image.renderWidth, image.renderHeight);
}

if (model.imageIsDeleted) {
Expand Down
2 changes: 1 addition & 1 deletion cvat-cli/requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cvat-sdk~=2.5.0
cvat-sdk~=2.6.0
Pillow>=6.2.0
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
2 changes: 1 addition & 1 deletion cvat-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse_requirements(filename=BASE_REQUIREMENTS_FILE):
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.7",
python_requires=">=3.8",
install_requires=BASE_REQUIREMENTS,
entry_points={
"console_scripts": [
Expand Down
1 change: 1 addition & 0 deletions cvat-cli/src/cvat_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def main(args: List[str] = None):
"upload": CLI.tasks_upload,
"export": CLI.tasks_export,
"import": CLI.tasks_import,
"auto-annotate": CLI.tasks_auto_annotate,
}
parser = make_cmdline_parser()
parsed_args = parser.parse_args(args)
Expand Down
59 changes: 48 additions & 11 deletions cvat-cli/src/cvat_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

from __future__ import annotations

import importlib
import importlib.util
import json
from typing import Dict, List, Sequence, Tuple
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple

import tqdm
import cvat_sdk.auto_annotation as cvataa
from cvat_sdk import Client, models
from cvat_sdk.core.helpers import TqdmProgressReporter
from cvat_sdk.core.helpers import DeferredTqdmProgressReporter
from cvat_sdk.core.proxies.tasks import ResourceType


Expand Down Expand Up @@ -67,7 +70,7 @@ def tasks_create(
status_check_period=status_check_period,
dataset_repository_url=dataset_repository_url,
use_lfs=lfs,
pbar=self._make_pbar(),
pbar=DeferredTqdmProgressReporter(),
)
print("Created task id", task.id)

Expand Down Expand Up @@ -109,7 +112,7 @@ def tasks_dump(
self.client.tasks.retrieve(obj_id=task_id).export_dataset(
format_name=fileformat,
filename=filename,
pbar=self._make_pbar(),
pbar=DeferredTqdmProgressReporter(),
status_check_period=status_check_period,
include_images=include_images,
)
Expand All @@ -123,22 +126,56 @@ def tasks_upload(
format_name=fileformat,
filename=filename,
status_check_period=status_check_period,
pbar=self._make_pbar(),
pbar=DeferredTqdmProgressReporter(),
)

def tasks_export(self, task_id: str, filename: str, *, status_check_period: int = 2) -> None:
"""Download a task backup"""
self.client.tasks.retrieve(obj_id=task_id).download_backup(
filename=filename, status_check_period=status_check_period, pbar=self._make_pbar()
filename=filename,
status_check_period=status_check_period,
pbar=DeferredTqdmProgressReporter(),
)

def tasks_import(self, filename: str, *, status_check_period: int = 2) -> None:
"""Import a task from a backup file"""
self.client.tasks.create_from_backup(
filename=filename, status_check_period=status_check_period, pbar=self._make_pbar()
filename=filename,
status_check_period=status_check_period,
pbar=DeferredTqdmProgressReporter(),
)

def _make_pbar(self, title: str = None) -> TqdmProgressReporter:
return TqdmProgressReporter(
tqdm.tqdm(unit_scale=True, unit="B", unit_divisor=1024, desc=title)
def tasks_auto_annotate(
self,
task_id: int,
*,
function_module: Optional[str] = None,
function_file: Optional[Path] = None,
function_parameters: Dict[str, Any],
clear_existing: bool = False,
allow_unmatched_labels: bool = False,
) -> None:
if function_module is not None:
function = importlib.import_module(function_module)
elif function_file is not None:
module_spec = importlib.util.spec_from_file_location("__cvat_function__", function_file)
function = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(function)
else:
assert False, "function identification arguments missing"

if hasattr(function, "create"):
# this is actually a function factory
function = function.create(**function_parameters)
else:
if function_parameters:
raise TypeError("function takes no parameters")

cvataa.annotate_task(
self.client,
task_id,
function,
pbar=DeferredTqdmProgressReporter(),
clear_existing=clear_existing,
allow_unmatched_labels=allow_unmatched_labels,
)
Loading

0 comments on commit 68e690f

Please sign in to comment.