Skip to content

Commit

Permalink
Drop support of the TFRecord format
Browse files Browse the repository at this point in the history
Usage statistics on app.cvat.ai show that this format is rarely used, with
single-digit numbers of projects/tasks/jobs being exported or imported using
this format. Moreover, TensorFlow's popularity appears to be shrinking, so I'm
not expecting this format to make a comeback.

Meanwhile, supporting this format has a cost that has to be borne by everyone
deploying CVAT, because it requires TensorFlow to be installed and loaded.
This has various ill effects:

1. Loading time is increased. In my testing, even a command as trivial as
   `manage.py --help` is slowed down by 3.6 seconds. This may not seem like
   much, but the effect is compounded, because we have multiple processes
   (server + workers) all loading the same codebase. Plus, the container
   entrypoint may execute several Django commands.

2. Memory usage is increased. TensorFlow adds ~100MB of RAM usage per
   process with data alone; and the libraries add more (although it's hard
   to estimate the impact of library code, since it can be shared between
   processes in RAM).

3. Docker image size is increased by ~1.5GB (when unpacked). This is more
   than half of the current total size! Building time is increased as well.

Overall, it seems that the drawbacks of keeping support for this format
outweigh the benefits, so it's time to drop it.
  • Loading branch information
SpecLad committed Jan 31, 2024
1 parent c794836 commit d428cd7
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 379 deletions.
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>)
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 @@ -6027,8 +6027,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 @@ -6400,8 +6399,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
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

0 comments on commit d428cd7

Please sign in to comment.