Skip to content
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
2 changes: 1 addition & 1 deletion docs/source/api_reference/api_metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Project metadata example:
"creator_id": "admin@superannotate.com",
"updatedAt": "2020-08-31T05:43:43.118Z",
"createdAt": "2020-08-31T05:43:43.118Z"
"type": "Vector", # Pixel, Video, Multimodal
"type": "Vector", # Video, Multimodal
"attachment_name": None,
"attachment_path": None,
"entropy_status": 1,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cli_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To create a new project:

.. code-block:: bash

superannotatecli create-project --name <project_name> --description <project_description> --type <project_type Vector or Pixel>
superannotatecli create-project --name <project_name> --description <project_description> --type <project_type Vector>

----------

Expand Down
4 changes: 1 addition & 3 deletions docs/source/userguide/setup_project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ you are uploading to should contain annotation class with that name.


This will try uploading to the project all the JSON files in the folder that have :file:`"<image_name>.json"` postfix.
For pixel projects JSON files should be named :file:`"<image_name>___pixel.json"` and also for
each JSON a mask image file should be present with the name
:file:`"<image_name>___save.png"`. Image with :file:`<image_name>` should
Image with :file:`<image_name>` should
already be present in the project for the upload to work.


Expand Down
4 changes: 2 additions & 2 deletions docs/source/userguide/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can find more information annotation format conversion :ref:`here <ref_conve
export_annotation(
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_panoptic_segm",
"tests/converter_test/COCO/output/panoptic",
"COCO", "panoptic_test", "Pixel","panoptic_segmentation"
"COCO", "panoptic_test","panoptic_segmentation"
)

# From COCO keypoints detection format to SA annotation format
Expand All @@ -54,7 +54,7 @@ You can find more information annotation format conversion :ref:`here <ref_conve
import_annotation(
"tests/converter_test/VOC/input/fromPascalVOCToSuperAnnotate/VOC2012",
"tests/converter_test/VOC/output/instances",
"VOC", "instances_test", "Pixel", "instance_segmentation"
"VOC", "instances_test", "instance_segmentation"
)

# YOLO annotation format to SA annotation format
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ minversion = 3.7
log_cli=true
python_files = test_*.py
;pytest_plugins = ['pytest_profiling']
;addopts = -n 6 --dist loadscope
addopts = -n 6 --dist loadscope
4 changes: 1 addition & 3 deletions src/superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys


__version__ = "4.5.1"
__version__ = "4.5.2dev1"


os.environ.update({"sa_version": __version__})
Expand All @@ -17,7 +17,6 @@
from lib.core import PACKAGE_VERSION_MAJOR_UPGRADE
from lib.core.exceptions import AppException
from lib.core.exceptions import FileChangedError
from superannotate.lib.app.input_converters import convert_project_type
from superannotate.lib.app.input_converters import export_annotation
from superannotate.lib.app.input_converters import import_annotation
from superannotate.lib.app.interface.sdk_interface import SAClient
Expand All @@ -37,7 +36,6 @@
"FileChangedError",
"import_annotation",
"export_annotation",
"convert_project_type",
]

__author__ = "Superannotate"
Expand Down
8 changes: 1 addition & 7 deletions src/superannotate/lib/app/analytics/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import lib.core as constances
import pandas as pd
from lib.core import PIXEL_ANNOTATION_POSTFIX
from lib.core import VECTOR_ANNOTATION_POSTFIX
from lib.core.exceptions import AppException

Expand Down Expand Up @@ -162,8 +161,6 @@ def _set_annotation_suffix(self, path):
self._annotation_suffix = ".json"
elif VECTOR_ANNOTATION_POSTFIX in fname.name:
self._annotation_suffix = VECTOR_ANNOTATION_POSTFIX
elif PIXEL_ANNOTATION_POSTFIX in fname.name:
self._annotation_suffix = PIXEL_ANNOTATION_POSTFIX
else:
self._annotation_suffix = ".json"

Expand Down Expand Up @@ -205,10 +202,7 @@ def aggregate_annotations_as_df(self):
self.check_classes_path()
annotation_paths = self.get_annotation_paths()

if self.project_type in (
constances.ProjectType.VECTOR,
constances.ProjectType.PIXEL,
):
if self.project_type is constances.ProjectType.VECTOR:
return self.aggregate_image_annotations_as_df(annotation_paths)
if self.project_type is constances.ProjectType.VIDEO:
return self.aggregate_video_annotations_as_df(annotation_paths)
Expand Down
2 changes: 0 additions & 2 deletions src/superannotate/lib/app/analytics/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ def __get_user_metadata(annotation):

if "___objects.json" in annotations_paths[0].name:
type_postfix = "___objects.json"
elif "___pixel.json" in annotations_paths[0].name:
type_postfix = "___pixel.json"
else:
type_postfix = ".json"

Expand Down
8 changes: 2 additions & 6 deletions src/superannotate/lib/app/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import pandas as pd
from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
from lib.core import PIXEL_ANNOTATION_POSTFIX
from lib.core import VECTOR_ANNOTATION_POSTFIX
from lib.core.exceptions import AppException

Expand All @@ -36,7 +35,6 @@ def get_local_annotation_paths(
if i.name.endswith(
(
VECTOR_ANNOTATION_POSTFIX,
PIXEL_ANNOTATION_POSTFIX,
ATTACHED_VIDEO_ANNOTATION_POSTFIX,
)
)
Expand Down Expand Up @@ -66,10 +64,8 @@ def get_s3_annotation_paths(folder_path, s3_bucket, annotation_paths, recursive)
for data in paginator.paginate(Bucket=s3_bucket, Prefix=folder_path):
for annotation in data.get("Contents", []):
key = annotation["Key"]
if (
key.endswith(VECTOR_ANNOTATION_POSTFIX)
or key.endswith(PIXEL_ANNOTATION_POSTFIX)
or key.endswith(ATTACHED_VIDEO_ANNOTATION_POSTFIX)
if key.endswith(VECTOR_ANNOTATION_POSTFIX) or key.endswith(
ATTACHED_VIDEO_ANNOTATION_POSTFIX
):
if not recursive and "/" in key[len(folder_path) + 1 :]:
continue
Expand Down
2 changes: 0 additions & 2 deletions src/superannotate/lib/app/input_converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from lib.app.input_converters.conversion import convert_project_type
from lib.app.input_converters.conversion import export_annotation
from lib.app.input_converters.conversion import import_annotation


__all__ = [
"convert_project_type",
"export_annotation",
"import_annotation",
]
58 changes: 4 additions & 54 deletions src/superannotate/lib/app/input_converters/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
import tempfile
from argparse import Namespace
from pathlib import Path
from typing import Union

from lib.app.interface.base_interface import Tracker
from lib.core import LIMITED_FUNCTIONS
from lib.core.enums import ProjectType
from lib.core.exceptions import AppException
from typing_extensions import Literal

from .export_from_sa_conversions import export_from_sa
from .import_to_sa_conversions import import_to_sa
from .sa_conversion import sa_convert_project_type


ALLOWED_TASK_TYPES = [
Expand All @@ -27,26 +24,22 @@
"vector_annotation",
]

ALLOWED_PROJECT_TYPES = ["Pixel", "Vector"]
ALLOWED_PROJECT_TYPES = ["Vector"]

ALLOWED_ANNOTATION_IMPORT_FORMATS = {
"COCO": [
("Pixel", "panoptic_segmentation"),
("Pixel", "instance_segmentation"),
("Vector", "keypoint_detection"),
("Vector", "instance_segmentation"),
("Vector", "object_detection"),
],
"VOC": [
("Vector", "object_detection"),
("Vector", "instance_segmentation"),
("Pixel", "instance_segmentation"),
],
"LabelBox": [
("Vector", "object_detection"),
("Vector", "instance_segmentation"),
("Vector", "vector_annotation"),
("Pixel", "instance_segmentation"),
],
"DataLoop": [
("Vector", "object_detection"),
Expand All @@ -57,15 +50,14 @@
("Vector", "vector_annotation"),
("Vector", "object_detection"),
("Vector", "instance_segmentation"),
("Pixel", "instance_segmentation"),
("Vector", "keypoint_detection"),
],
"VoTT": [
("Vector", "object_detection"),
("Vector", "instance_segmentation"),
("Vector", "vector_annotation"),
],
"SageMaker": [("Pixel", "instance_segmentation"), ("Vector", "object_detection")],
"SageMaker": [("Vector", "object_detection")],
"VGG": [
("Vector", "object_detection"),
("Vector", "instance_segmentation"),
Expand All @@ -77,8 +69,6 @@

ALLOWED_ANNOTATION_EXPORT_FORMATS = {
"COCO": [
("Pixel", "panoptic_segmentation"),
("Pixel", "instance_segmentation"),
("Vector", "instance_segmentation"),
("Vector", "keypoint_detection"),
("Vector", "object_detection"),
Expand Down Expand Up @@ -166,8 +156,6 @@ def export_annotation(
--------------------------------------
project_type task
============== ======================
Pixel panoptic_segmentation
Pixel instance_segmentation
Vector instance_segmentation
Vector object_detection
Vector keypoint_detection
Expand All @@ -181,15 +169,13 @@ def export_annotation(
:type dataset_format: str
:param dataset_name: Will be used to create json file in the output_dir.
:type dataset_name: str
:param project_type: SuperAnnotate project type is either 'Vector' or 'Pixel' (Default: 'Vector')
:param project_type: SuperAnnotate project type is 'Vector'
'Vector' project creates <image_name>___objects.json for each image.
'Pixel' project creates <image_name>___pixel.jsons and <image_name>___save.png annotation mask for each image.
:type project_type: str
:param task: Task can be one of the following: ['panoptic_segmentation', 'instance_segmentation',
'keypoint_detection', 'object_detection']. (Default: "object_detection").
'keypoint_detection' can be used to converts keypoints from/to available annotation format.
'panoptic_segmentation' will use panoptic mask for each image to generate bluemask for SuperAnnotate annotation format and use bluemask to generate panoptic mask for invert conversion. Panoptic masks should be in the input folder.
'instance_segmentation' 'Pixel' project_type converts instance masks and 'Vector' project_type generates bounding boxes and polygons from instance masks. Masks should be in the input folder if it is 'Pixel' project_type.
'object_detection' converts objects from/to available annotation format
:type task: str
"""
Expand Down Expand Up @@ -223,8 +209,6 @@ def export_annotation(
_passes_value_sanity(values_info)
if project_type == "Vector":
extension = "___objects.json"
elif project_type == "Pixel":
extension = "___pixel.json"
else:
extension = ".json"
with tempfile.TemporaryDirectory() as tmp_dir:
Expand Down Expand Up @@ -264,8 +248,6 @@ def import_annotation(
--------------------------------------
project_type task
============== ======================
Pixel panoptic_segmentation
Pixel instance_segmentation
Vector instance_segmentation
Vector object_detection
Vector keypoint_detection
Expand All @@ -276,7 +258,6 @@ def import_annotation(
--------------------------------------
project_type task
============== ======================
Pixel instance_segmentation
Vector instance_segmentation
Vector object_detection
============== ======================
Expand All @@ -289,7 +270,6 @@ def import_annotation(
Vector object_detection
Vector instance_segmentation
Vector vector_annotation
Pixel instance_segmentation
============== ======================

============== ======================
Expand All @@ -311,7 +291,6 @@ def import_annotation(
Vector keypoint_detection
Vector vector_annotation
Vector instance_segmentation
Pixel instance_segmentation
============== ======================

============== ======================
Expand All @@ -329,7 +308,6 @@ def import_annotation(
--------------------------------------
project_type task
============== ======================
Pixel instance_segmentation
Vector objcet_detection
============== ======================

Expand Down Expand Up @@ -368,15 +346,13 @@ def import_annotation(
:type dataset_format: str
:param dataset_name: Name of the json file in the input_dir, which should be converted.
:type dataset_name: str
:param project_type: SuperAnnotate project type is either 'Vector' or 'Pixel' (Default: 'Vector')
:param project_type: SuperAnnotate project type is 'Vector'
'Vector' project creates <image_name>___objects.json for each image.
'Pixel' project creates <image_name>___pixel.jsons and <image_name>___save.png annotation mask for each image.
:type project_type: str
:param task: Task can be one of the following: ['panoptic_segmentation', 'instance_segmentation',
'keypoint_detection', 'object_detection', 'vector_annotation']. (Default: "object_detection").
'keypoint_detection' can be used to converts keypoints from/to available annotation format.
'panoptic_segmentation' will use panoptic mask for each image to generate bluemask for SuperAnnotate annotation format and use bluemask to generate panoptic mask for invert conversion. Panoptic masks should be in the input folder.
'instance_segmentation' 'Pixel' project_type converts instance masks and 'Vector' project_type generates bounding boxes and polygons from instance masks. Masks should be in the input folder if it is 'Pixel' project_type.
'object_detection' converts objects from/to available annotation format
'vector_annotation' can be used to convert all annotations (point, ellipse, circule, cuboid and etc) to SuperAnnotate vector project.
:param images_root: Additonal path to images directory in input_dir
Expand Down Expand Up @@ -427,29 +403,3 @@ def import_annotation(
_passes_converter_sanity(args, "import")

import_to_sa(args)


@Tracker
def convert_project_type(
input_dir: Union[str, Path],
output_dir: Union[str, Path],
convert_to: Literal["Vector", "Pixel"],
):
"""Converts SuperAnnotate 'Vector' project type to 'Pixel' or reverse.

:param input_dir: Path to the dataset folder that you want to convert.
:type input_dir: Pathlike(str or Path)
:param output_dir: Path to the folder where you want to have converted files.
:type output_dir: Pathlike(str or Path)
:param convert_to: the project type to which the current project should be converted.
:type convert_to: str
"""
params_info = [
(input_dir, "input_dir", (str, Path)),
(output_dir, "output_dir", (str, Path)),
]
_passes_type_sanity(params_info)

input_dir, output_dir = _change_type(input_dir, output_dir)

sa_convert_project_type(input_dir, output_dir, convert_to)
Loading