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
56 changes: 49 additions & 7 deletions docs/source/superannotate.sdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ ________
.. autofunction:: superannotate.create_folder
.. autofunction:: superannotate.delete_folders
.. autofunction:: superannotate.upload_images_to_project
.. autofunction:: superannotate.attach_image_urls_to_project
.. autofunction:: superannotate.attach_document_urls_to_project
.. autofunction:: superannotate.attach_items_from_integrated_storage
.. autofunction:: superannotate.upload_image_to_project
.. autofunction:: superannotate.delete_annotations
.. _ref_upload_images_from_folder_to_project:
.. autofunction:: superannotate.upload_images_from_folder_to_project
.. autofunction:: superannotate.upload_video_to_project
.. autofunction:: superannotate.upload_videos_from_folder_to_project
.. autofunction:: superannotate.attach_video_urls_to_project
.. _ref_upload_annotations_from_folder_to_project:
.. autofunction:: superannotate.upload_annotations_from_folder_to_project
.. autofunction:: superannotate.upload_preannotations_from_folder_to_project
.. autofunction:: superannotate.share_project
.. autofunction:: superannotate.add_contributors_to_project
.. autofunction:: superannotate.get_project_settings
.. autofunction:: superannotate.set_project_default_image_quality_in_editor
Expand All @@ -73,6 +69,7 @@ ______

.. autofunction:: superannotate.query
.. autofunction:: superannotate.search_items
.. autofunction:: superannotate.download_annotations
.. autofunction:: superannotate.attach_items
.. autofunction:: superannotate.copy_items
.. autofunction:: superannotate.move_items
Expand All @@ -92,8 +89,6 @@ ______
.. autofunction:: superannotate.download_image_annotations
.. autofunction:: superannotate.upload_image_annotations
.. autofunction:: superannotate.copy_image
.. autofunction:: superannotate.copy_images
.. autofunction:: superannotate.move_images
.. autofunction:: superannotate.pin_image
.. autofunction:: superannotate.assign_images
.. autofunction:: superannotate.delete_images
Expand Down Expand Up @@ -159,11 +154,26 @@ Project metadata example:
"attachment_name": None,
"attachment_path": None,
"entropy_status": 1,
"status": 0,
"status": "NotStarted",
"...": "..."
}


----------

Setting metadata
_________________

Setting metadata example:

.. code-block:: python

{
"attribute": "FrameRate",
"value": 3
}


----------

Export metadata
Expand Down Expand Up @@ -250,6 +260,38 @@ Image metadata example:
}


----------

Priority score
_______________


Priority score example:

.. code-block:: python

{
"name" : "image1.png",
"priority": 0.567
}


----------

Attachment
_______________


Attachment example:

.. code-block:: python

{
"url": "https://sa-public-files.s3.../text_file_example_1.jpeg",
"name": "example.jpeg"
}


----------

.. _ref_class:
Expand Down
10 changes: 0 additions & 10 deletions docs/source/tutorial.sdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,6 @@ A team contributor can be invited to the team with:

sa.invite_contributors_to_team(emails=["admin@superannotate.com"], admin=False)


This invitation should be accepted by the contributor. After which, to share the
project with the found contributor as an QA:

.. code-block:: python

sa.share_project(project, "admin@superannotate.com", user_role="QA")



----------


Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
minversion = 3.7
log_cli=true
python_files = test_*.py
addopts = -n auto --dist=loadscope
;addopts = -n auto --dist=loadscope
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
superannotate_schemas>=v1.0.42dev2
superannotate_schemas>=v1.0.43dev3

3 changes: 2 additions & 1 deletion requirements_extra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pytest==6.2.4
pytest-xdist==2.3.0
pytest-parallel==0.1.0
pytest-rerunfailures==10.2
sphinx_rtd_theme==1.0.0
sphinx_rtd_theme==1.0.0
pytest-cov
18 changes: 3 additions & 15 deletions src/superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys

import requests
import superannotate.lib.core as constances
from packaging.version import parse
from superannotate.lib import core as constances
from superannotate.lib import get_default_controller
from superannotate.lib.app.analytics.class_analytics import class_distribution
from superannotate.lib.app.exceptions import AppException
Expand All @@ -21,20 +21,14 @@
from superannotate.lib.app.interface.sdk_interface import aggregate_annotations_as_df
from superannotate.lib.app.interface.sdk_interface import assign_folder
from superannotate.lib.app.interface.sdk_interface import assign_images
from superannotate.lib.app.interface.sdk_interface import (
attach_document_urls_to_project,
)
from superannotate.lib.app.interface.sdk_interface import attach_image_urls_to_project
from superannotate.lib.app.interface.sdk_interface import attach_items
from superannotate.lib.app.interface.sdk_interface import (
attach_items_from_integrated_storage,
)
from superannotate.lib.app.interface.sdk_interface import attach_video_urls_to_project
from superannotate.lib.app.interface.sdk_interface import benchmark
from superannotate.lib.app.interface.sdk_interface import clone_project
from superannotate.lib.app.interface.sdk_interface import consensus
from superannotate.lib.app.interface.sdk_interface import copy_image
from superannotate.lib.app.interface.sdk_interface import copy_images
from superannotate.lib.app.interface.sdk_interface import copy_items
from superannotate.lib.app.interface.sdk_interface import create_annotation_class
from superannotate.lib.app.interface.sdk_interface import (
Expand All @@ -51,6 +45,7 @@
from superannotate.lib.app.interface.sdk_interface import (
download_annotation_classes_json,
)
from superannotate.lib.app.interface.sdk_interface import download_annotations
from superannotate.lib.app.interface.sdk_interface import download_export
from superannotate.lib.app.interface.sdk_interface import download_image
from superannotate.lib.app.interface.sdk_interface import download_image_annotations
Expand All @@ -68,7 +63,6 @@
from superannotate.lib.app.interface.sdk_interface import get_team_metadata
from superannotate.lib.app.interface.sdk_interface import init
from superannotate.lib.app.interface.sdk_interface import invite_contributors_to_team
from superannotate.lib.app.interface.sdk_interface import move_images
from superannotate.lib.app.interface.sdk_interface import move_items
from superannotate.lib.app.interface.sdk_interface import pin_image
from superannotate.lib.app.interface.sdk_interface import prepare_export
Expand All @@ -89,7 +83,6 @@
set_project_default_image_quality_in_editor,
)
from superannotate.lib.app.interface.sdk_interface import set_project_workflow
from superannotate.lib.app.interface.sdk_interface import share_project
from superannotate.lib.app.interface.sdk_interface import unassign_folder
from superannotate.lib.app.interface.sdk_interface import unassign_images
from superannotate.lib.app.interface.sdk_interface import (
Expand Down Expand Up @@ -133,6 +126,7 @@
"get_exports",
# annotations
"get_annotations",
"download_annotations",
"get_annotations_per_frame",
# integrations
"get_integrations",
Expand All @@ -154,7 +148,6 @@
"search_projects",
"create_project",
"clone_project",
"share_project",
"delete_project",
"rename_project",
"upload_priority_scores",
Expand All @@ -176,8 +169,6 @@
"move_items",
"set_annotation_statuses",
# Image Section
"copy_images",
"move_images",
"delete_images",
"download_image",
"pin_image",
Expand All @@ -189,9 +180,6 @@
"upload_image_to_project",
"upload_image_annotations",
"upload_images_from_folder_to_project",
"attach_image_urls_to_project",
"attach_video_urls_to_project",
"attach_document_urls_to_project",
# Video Section
"upload_videos_from_folder_to_project",
# Annotation Section
Expand Down
82 changes: 0 additions & 82 deletions src/superannotate/lib/app/common.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import json
import os
import sys
import time

import numpy as np
from PIL import Image
from superannotate.logger import get_default_logger
from tqdm import tqdm

logger = get_default_logger()

_PROJECT_TYPES = {"Vector": 1, "Pixel": 2}

_ANNOTATION_STATUSES = {
"NotStarted": 1,
"InProgress": 2,
"QualityCheck": 3,
"Returned": 4,
"Completed": 5,
"Skipped": 6,
}


def hex_to_rgb(hex_string):
"""Converts HEX values to RGB values
Expand Down Expand Up @@ -68,73 +53,6 @@ def id2rgb(id_map):
return color


def save_desktop_format(output_dir, classes, files_dict):
cat_id_map = {}
new_classes = []
for idx, class_ in enumerate(classes):
cat_id_map[class_["name"]] = idx + 2
class_["id"] = idx + 2
new_classes.append(class_)
with open(output_dir.joinpath("classes.json"), "w") as fw:
json.dump(new_classes, fw)

meta = {
"type": "meta",
"name": "lastAction",
"timestamp": int(round(time.time() * 1000)),
}
new_json = {}
files_path = []
(output_dir / "images" / "thumb").mkdir()
for file_name, json_data in files_dict.items():
file_name = file_name.replace("___objects.json", "")
if not (output_dir / "images" / file_name).exists():
continue

for js_data in json_data:
if "className" in js_data:
js_data["classId"] = cat_id_map[js_data["className"]]
json_data.append(meta)
new_json[file_name] = json_data

files_path.append(
{
"srcPath": str(output_dir.resolve() / file_name),
"name": file_name,
"imagePath": str(output_dir.resolve() / file_name),
"thumbPath": str(
output_dir.resolve()
/ "images"
/ "thumb"
/ ("thmb_" + file_name + ".jpg")
),
"valid": True,
}
)

img = Image.open(output_dir / "images" / file_name)
img.thumbnail((168, 120), Image.ANTIALIAS)
img.save(output_dir / "images" / "thumb" / ("thmb_" + file_name + ".jpg"))

with open(output_dir / "images" / "images.sa", "w") as fw:
fw.write(json.dumps(files_path))

with open(output_dir.joinpath("annotations.json"), "w") as fw:
json.dump(new_json, fw)

with open(output_dir / "config.json", "w") as fw:
json.dump({"pathSeparator": os.sep, "os": sys.platform}, fw)


def save_web_format(output_dir, classes, files_dict):
for key, value in files_dict.items():
with open(output_dir.joinpath(key), "w") as fw:
json.dump(value, fw, indent=2)

with open(output_dir.joinpath("classes", "classes.json"), "w") as fw:
json.dump(classes, fw)


def write_to_json(output_path, json_data):
with open(output_path, "w") as fw:
json.dump(json_data, fw, indent=2)
Expand Down
Loading