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

Drop support of the TFRecord format #7416

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ For more information about the supported formats, see:
| [YOLO](https://pjreddie.com/darknet/yolo/) | ✔️ | ✔️ |
| [MS COCO Object Detection](http://cocodataset.org/#format-data) | ✔️ | ✔️ |
| [MS COCO Keypoints Detection](http://cocodataset.org/#format-data) | ✔️ | ✔️ |
| [TFrecord](https://www.tensorflow.org/tutorials/load_data/tfrecord) | ✔️ | ✔️ |
| [MOT](https://motchallenge.net/) | ✔️ | ✔️ |
| [MOTS PNG](https://www.vision.rwth-aachen.de/page/mots) | ✔️ | ✔️ |
| [LabelMe 3.0](http://labelme.csail.mit.edu/Release3.0) | ✔️ | ✔️ |
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/20240131_180300_roman_remove_tfrecord.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Removed

- Removed support for the TFRecord dataset format
(<https://github.com/opencv/cvat/pull/7416>)
5 changes: 5 additions & 0 deletions changelog.d/20240213_010700_roman_import_export_events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Added

- Added `dataset:export` and `dataset:import` events that are logged when
the user initiates an export or import of a project, task or job
(<https://github.com/opencv/cvat/pull/7476>)
8 changes: 0 additions & 8 deletions cvat/apps/dataset_manager/formats/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ def make_exporter(name):
return EXPORT_FORMATS[name]()


# Add checking for TF availability to avoid CVAT sever instance / interpreter
# crash and provide a meaningful diagnostic message in the case of AVX
# instructions unavailability:
# https://github.com/openvinotoolkit/cvat/pull/1567
import datumaro.util.tf_util as TF
TF.enable_tf_check = True

# pylint: disable=unused-import
import cvat.apps.dataset_manager.formats.coco
import cvat.apps.dataset_manager.formats.cvat
Expand All @@ -111,7 +104,6 @@ def make_exporter(name):
import cvat.apps.dataset_manager.formats.mot
import cvat.apps.dataset_manager.formats.mots
import cvat.apps.dataset_manager.formats.pascal_voc
import cvat.apps.dataset_manager.formats.tfrecord
import cvat.apps.dataset_manager.formats.yolo
import cvat.apps.dataset_manager.formats.imagenet
import cvat.apps.dataset_manager.formats.camvid
Expand Down
38 changes: 0 additions & 38 deletions cvat/apps/dataset_manager/formats/tfrecord.py

This file was deleted.

18 changes: 0 additions & 18 deletions cvat/apps/dataset_manager/tests/assets/annotations.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,24 +701,6 @@
],
"tracks": []
},
"TFRecord 1.0": {
"version": 0,
"tags": [],
"shapes": [
{
"type": "rectangle",
"occluded": false,
"z_order": 0,
"points": [16.5, 17.2, 38.89, 25.63],
"frame": 0,
"label_id": null,
"group": 0,
"source": "manual",
"attributes": []
}
],
"tracks": []
},
"YOLO 1.1": {
"version": 0,
"tags": [],
Expand Down
3 changes: 0 additions & 3 deletions cvat/apps/dataset_manager/tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ def test_export_formats_query(self):
'MOTS PNG 1.0',
'PASCAL VOC 1.1',
'Segmentation mask 1.1',
'TFRecord 1.0',
'YOLO 1.1',
'ImageNet 1.0',
'CamVid 1.0',
Expand Down Expand Up @@ -326,7 +325,6 @@ def test_import_formats_query(self):
'MOTS PNG 1.0',
'PASCAL VOC 1.1',
'Segmentation mask 1.1',
'TFRecord 1.0',
'YOLO 1.1',
'ImageNet 1.0',
'CamVid 1.0',
Expand Down Expand Up @@ -381,7 +379,6 @@ def test_empty_images_are_exported(self):
# ('MOTS PNG 1.0', 'mots_png'), # does not support
('PASCAL VOC 1.1', 'voc'),
('Segmentation mask 1.1', 'voc'),
('TFRecord 1.0', 'tf_detection_api'),
('YOLO 1.1', 'yolo'),
('ImageNet 1.0', 'imagenet_txt'),
('CamVid 1.0', 'camvid'),
Expand Down
14 changes: 7 additions & 7 deletions cvat/apps/dataset_manager/tests/test_rest_api_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_api_v2_dump_and_upload_annotations_with_objects_type_is_shape(self):
"Cityscapes 1.0", "Datumaro 1.0",
"ImageNet 1.0", "MOTS PNG 1.0",
"PASCAL VOC 1.1", "Segmentation mask 1.1",
"TFRecord 1.0", "VGGFace2 1.0",
"VGGFace2 1.0",
"WiderFace 1.0", "YOLO 1.1"
]:
self._create_annotations(task, dump_format_name, "default")
Expand Down Expand Up @@ -522,7 +522,7 @@ def test_api_v2_dump_annotations_with_objects_type_is_track(self):
if dump_format_name in [
"Cityscapes 1.0", "ImageNet 1.0",
"MOTS PNG 1.0", "PASCAL VOC 1.1",
"Segmentation mask 1.1", "TFRecord 1.0",
"Segmentation mask 1.1",
"VGGFace2 1.0", "WiderFace 1.0", "YOLO 1.1"
]:
self._create_annotations(task, dump_format_name, "default")
Expand Down Expand Up @@ -968,7 +968,7 @@ def test_api_v2_rewriting_annotations(self):

if dump_format_name in [
"MOT 1.1", "PASCAL VOC 1.1", "Segmentation mask 1.1",
"TFRecord 1.0", "YOLO 1.1", "ImageNet 1.0",
"YOLO 1.1", "ImageNet 1.0",
"WiderFace 1.0", "VGGFace2 1.0",
"Datumaro 1.0", "Open Images V6 1.0", "KITTI 1.0"
]:
Expand Down Expand Up @@ -1084,7 +1084,7 @@ def test_api_v2_tasks_annotations_dump_and_upload_with_datumaro(self):
if dump_format_name in [
"MOT 1.1", "MOTS PNG 1.0",
"PASCAL VOC 1.1", "Segmentation mask 1.1",
"TFRecord 1.0", "YOLO 1.1", "ImageNet 1.0",
"YOLO 1.1", "ImageNet 1.0",
"WiderFace 1.0", "VGGFace2 1.0", "LFW 1.0",
"Open Images V6 1.0", "Datumaro 1.0", "KITTI 1.0"
]:
Expand Down Expand Up @@ -1287,7 +1287,7 @@ def test_api_v2_export_import_dataset(self):
dump_format_name = dump_format.DISPLAY_NAME
if dump_format_name in [
'Cityscapes 1.0', 'LFW 1.0', 'Market-1501 1.0',
'MOT 1.1', 'TFRecord 1.0'
'MOT 1.1',
]:
# TO-DO: fix bug for this formats
continue
Expand All @@ -1303,7 +1303,7 @@ def test_api_v2_export_import_dataset(self):
if dump_format_name in [
"Cityscapes 1.0", "Datumaro 1.0", "ImageNet 1.0",
"MOT 1.1", "MOTS PNG 1.0", "PASCAL VOC 1.1",
"Segmentation mask 1.1", "TFRecord 1.0", "VGGFace2 1.0",
"Segmentation mask 1.1", "VGGFace2 1.0",
"WiderFace 1.0", "YOLO 1.1"
]:
self._create_annotations(task, dump_format_name, "default")
Expand Down Expand Up @@ -1344,7 +1344,7 @@ def test_api_v2_export_import_dataset(self):
upload_format_name = upload_format.DISPLAY_NAME
if upload_format_name in [
'Cityscapes 1.0', 'LFW 1.0', 'Market-1501 1.0',
'MOT 1.1', 'TFRecord 1.0'
'MOT 1.1',
]:
# TO-DO: fix bug for this formats
continue
Expand Down
5 changes: 1 addition & 4 deletions cvat/apps/engine/tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6031,8 +6031,7 @@ def _get_initial_annotation(annotation_format):
annotations["shapes"] = rectangle_shapes_wo_attrs
annotations["tags"] = tags_wo_attrs

elif annotation_format == "YOLO 1.1" or \
annotation_format == "TFRecord 1.0":
elif annotation_format == "YOLO 1.1":
annotations["shapes"] = rectangle_shapes_wo_attrs

elif annotation_format == "COCO 1.0":
Expand Down Expand Up @@ -6404,8 +6403,6 @@ def etree_to_dict(t):
for json in jsons:
coco = coco_loader.COCO(json)
self.assertTrue(coco.getAnnIds())
elif format_name == "TFRecord 1.0":
self.assertTrue(zipfile.is_zipfile(content))
elif format_name == "Segmentation mask 1.1":
self.assertTrue(zipfile.is_zipfile(content))

Expand Down
16 changes: 16 additions & 0 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import cvat.apps.dataset_manager as dm
import cvat.apps.dataset_manager.views # pylint: disable=unused-import
from cvat.apps.engine.cloud_provider import db_storage_to_storage_instance, download_file_from_bucket, export_resource_to_cloud_storage
from cvat.apps.events.handlers import handle_dataset_export, handle_dataset_import
from cvat.apps.dataset_manager.bindings import CvatImportError
from cvat.apps.dataset_manager.serializers import DatasetFormatsSerializer
from cvat.apps.engine.frame_provider import FrameProvider
Expand Down Expand Up @@ -2838,6 +2839,8 @@ def _import_annotations(request, rq_id_template, rq_func, db_obj, format_name,
dependent_job = None
location = location_conf.get('location') if location_conf else Location.LOCAL

db_storage = None

if not filename or location == Location.CLOUD_STORAGE:
if location != Location.CLOUD_STORAGE:
serializer = AnnotationFileSerializer(data=request.data)
Expand Down Expand Up @@ -2898,6 +2901,9 @@ def _import_annotations(request, rq_id_template, rq_func, db_obj, format_name,
result_ttl=settings.IMPORT_CACHE_SUCCESS_TTL.total_seconds(),
failure_ttl=settings.IMPORT_CACHE_FAILED_TTL.total_seconds()
)

handle_dataset_import(db_obj, format_name=format_name, cloud_storage=db_storage)

serializer = RqIdSerializer(data={'rq_id': rq_id})
serializer.is_valid(raise_exception=True)

Expand Down Expand Up @@ -3045,6 +3051,8 @@ def _export_annotations(
is_annotation_file=is_annotation_file,
)
func_args = (db_storage, filename, filename_pattern, callback) + func_args
else:
db_storage = None

with get_rq_lock_by_user(queue, user_id):
queue.enqueue_call(
Expand All @@ -3056,6 +3064,10 @@ def _export_annotations(
result_ttl=ttl,
failure_ttl=ttl,
)

handle_dataset_export(db_instance,
format_name=format_name, cloud_storage=db_storage, save_images=not is_annotation_file)

return Response(status=status.HTTP_202_ACCEPTED)

def _import_project_dataset(request, rq_id_template, rq_func, db_obj, format_name, filename=None, conv_mask_to_poly=True, location_conf=None):
Expand All @@ -3080,6 +3092,8 @@ def _import_project_dataset(request, rq_id_template, rq_func, db_obj, format_nam
rq_job.delete()
dependent_job = None
location = location_conf.get('location') if location_conf else None
db_storage = None

if not filename and location != Location.CLOUD_STORAGE:
serializer = DatasetFileSerializer(data=request.data)
if serializer.is_valid(raise_exception=True):
Expand Down Expand Up @@ -3138,6 +3152,8 @@ def _import_project_dataset(request, rq_id_template, rq_func, db_obj, format_nam
result_ttl=settings.IMPORT_CACHE_SUCCESS_TTL.total_seconds(),
failure_ttl=settings.IMPORT_CACHE_FAILED_TTL.total_seconds()
)

handle_dataset_import(db_obj, format_name=format_name, cloud_storage=db_storage)
else:
return Response(status=status.HTTP_409_CONFLICT, data='Import job already exists')

Expand Down
1 change: 1 addition & 0 deletions cvat/apps/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class EventScopes:
"comment": ["create", "update", "delete"],
"annotations": ["create", "update", "delete"],
"label": ["create", "update", "delete"],
"dataset": ["export", "import"],
}

@classmethod
Expand Down
46 changes: 46 additions & 0 deletions cvat/apps/events/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT

from copy import deepcopy
from typing import Optional, Union
import traceback
import rq

Expand Down Expand Up @@ -474,6 +475,51 @@ def filter_shape_data(shape):
payload={"tracks": tracks},
)

def handle_dataset_io(
instance: Union[Project, Task, Job],
action: str,
*,
format_name: str,
cloud_storage: Optional[CloudStorage],
**payload_fields,
) -> None:
payload={"format": format_name, **payload_fields}

if cloud_storage:
payload["cloud_storage"] = {"id": cloud_storage.id}

record_server_event(
scope=event_scope(action, "dataset"),
request_id=request_id(),
org_id=organization_id(instance),
org_slug=organization_slug(instance),
project_id=project_id(instance),
task_id=task_id(instance),
job_id=job_id(instance),
user_id=user_id(instance),
user_name=user_name(instance),
user_email=user_email(instance),
payload=payload,
)

def handle_dataset_export(
instance: Union[Project, Task, Job],
*,
format_name: str,
cloud_storage: Optional[CloudStorage],
save_images: bool,
) -> None:
handle_dataset_io(instance, "export",
format_name=format_name, cloud_storage=cloud_storage, save_images=save_images)

def handle_dataset_import(
instance: Union[Project, Task, Job],
*,
format_name: str,
cloud_storage: Optional[CloudStorage],
) -> None:
handle_dataset_io(instance, "import", format_name=format_name, cloud_storage=cloud_storage)

def handle_rq_exception(rq_job, exc_type, exc_value, tb):
oid = rq_job.meta.get("org_id", None)
oslug = rq_job.meta.get("org_slug", None)
Expand Down
1 change: 0 additions & 1 deletion cvat/requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ rq-scheduler==0.13.1
rq==1.15.1
rules>=3.3
Shapely==1.7.1
tensorflow==2.11.1 # Optional requirement of Datumaro. Use tensorflow-macos==2.8.0 for Mac M1
Loading
Loading