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
50 changes: 29 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,41 @@ Authentication

.. code-block:: python

>>> from superannotate import SAClient
# by environment variable SA_TOKEN
>>> sa_client = SAClient()
# by token
>>> sa_client = SAClient(token='<team token>')
# by config file
# default path is ~/.superannotate/config.json
>>> sa_client = SAClient(config_path='~/.superannotate/dev_config.json')
from superannotate import SAClient
# by environment variable SA_TOKEN
sa_client = SAClient()
# by token
sa_client = SAClient(token='<team token>')
# by config file
# default path is ~/.superannotate/config.json
sa_client = SAClient(config_path='~/.superannotate/dev_config.json')

Using superannotate
-------------------

.. code-block:: python

>>> from superannotate import SAClient
>>> sa_client =SAClient()
>>> project = 'Dogs'
>>> sa_client.create_project(
from superannotate import SAClient


sa_client =SAClient()

project = 'Dogs'

sa_client.create_project(
project_name=project,
project_description='Test project generated via SDK',
project_type='Vector'
)
>>> sa_client.create_annotation_class(
project=project,
name='dog',
color='#F9E0FA',
class_type='tag'
)
>>> sa_client.attach_items(

sa_client.create_annotation_class(
project=project,
name='dog',
color='#F9E0FA',
class_type='tag'
)

sa_client.attach_items(
project=project,
attachments=[
{
Expand All @@ -64,7 +70,8 @@ Using superannotate
}
]
)
>>> sa_client.upload_annotations(

sa_client.upload_annotations(
project=project,
annotations=[
{
Expand All @@ -75,7 +82,8 @@ Using superannotate
}
]
)
>>> sa_client.get_annotations(project=project, items=['dog.jpeg'])

sa_client.get_annotations(project=project, items=['dog.jpeg'])

Installation
------------
Expand Down
52 changes: 44 additions & 8 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,49 @@ SuperAnnotate Python SDK allows access to the platform without web browser:

.. code-block:: python

from superannotate import SAClient

sa = SAClient()

sa.create_project("Example Project 1", "example", "Vector")

sa.upload_images_from_folder_to_project("Example Project 1", "<path_to_my_images_folder>")
from superannotate import SAClient


sa_client =SAClient()

project = 'Dogs'

sa_client.create_project(
project_name=project,
project_description='Test project generated via SDK',
project_type='Vector'
)

sa_client.create_annotation_class(
project=project,
name='dog',
color='#F9E0FA',
class_type='tag'
)

sa_client.attach_items(
project=project,
attachments=[
{
'url': 'https://drive.google.com/uc?export=download&id=1ipOrZNSTlPUkI_hnrW9aUD5yULqqq5Vl',
'name': 'dog.jpeg'
}
]
)

sa_client.upload_annotations(
project=project,
annotations=[
{
'metadata': {'name': 'dog.jpeg'},
'instances': [
{'type': 'tag', 'className': 'dog'}
]
}
]
)

sa_client.get_annotations(project=project, items=['dog.jpeg'])

----------

Expand All @@ -50,7 +86,7 @@ SDK is available on PyPI:
pip install superannotate


The package officially supports Python 3.6+ and was tested under Linux and
The package officially supports Python 3.7+ and was tested under Linux and
Windows (`Anaconda <https://www.anaconda.com/products/individual#windows>`_) platforms.

For more detailed installation steps and package usage please have a look at
Expand Down
3 changes: 3 additions & 0 deletions docs/source/superannotate.sdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ ________
.. automethod:: superannotate.SAClient.delete_project
.. automethod:: superannotate.SAClient.rename_project
.. _ref_get_project_metadata:
.. automethod:: superannotate.SAClient.get_project_by_id
.. automethod:: superannotate.SAClient.get_project_metadata
.. automethod:: superannotate.SAClient.get_project_image_count
.. automethod:: superannotate.SAClient.search_folders
.. automethod:: superannotate.SAClient.assign_folder
.. automethod:: superannotate.SAClient.unassign_folder
.. automethod:: superannotate.SAClient.get_folder_by_id
.. automethod:: superannotate.SAClient.get_folder_metadata
.. automethod:: superannotate.SAClient.create_folder
.. automethod:: superannotate.SAClient.delete_folders
Expand Down Expand Up @@ -68,6 +70,7 @@ Items
______

.. automethod:: superannotate.SAClient.query
.. automethod:: superannotate.SAClient.get_item_by_id
.. automethod:: superannotate.SAClient.search_items
.. automethod:: superannotate.SAClient.download_annotations
.. automethod:: superannotate.SAClient.attach_items
Expand Down
3 changes: 2 additions & 1 deletion src/superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import sys


__version__ = "4.4.7dev7"
__version__ = "4.4.8dev2"



sys.path.append(os.path.split(os.path.realpath(__file__))[0])
Expand Down
11 changes: 11 additions & 0 deletions src/superannotate/lib/app/interface/sdk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ def __init__(
):
super().__init__(token, config_path)

def get_project_by_id(self, project_id: int):
"""Returns the project metadata

:param project_id: the id of the project
:type project_id: int

:return: project metadata
:rtype: dict
"""
response = self.controller.get_project_by_id(project_id=project_id)

def get_folder_by_id(self, project_id: int, folder_id: int):
"""Returns the folder
:param folder_id: the id of the folder
Expand Down
3 changes: 3 additions & 0 deletions src/superannotate/lib/core/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"ImageEntity",
"BaseItemEntity",
"VideoEntity",
"PointCloudEntity",
"TiledEntity",
"ClassificationEntity",
"DocumentEntity",
# Utils
"AttachmentEntity",
Expand Down
4 changes: 3 additions & 1 deletion src/superannotate/lib/infrastructure/services/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from lib.core.exceptions import AppException
from lib.core.exceptions import BackendError
from lib.core.service_types import ClassificationResponse
from lib.core.service_types import DocumentResponse
from lib.core.service_types import ImageResponse
from lib.core.service_types import ItemListResponse
from lib.core.service_types import PointCloudResponse
Expand Down Expand Up @@ -36,14 +37,15 @@ class ItemService(BaseItemService):
ProjectType.VIDEO: VideoResponse,
ProjectType.TILED: TiledResponse,
ProjectType.PIXEL: ImageResponse,
ProjectType.DOCUMENT: DocumentResponse,
ProjectType.POINT_CLOUD: PointCloudResponse,
}

def get_by_id(self, item_id, project_id, project_type):

params = {"project_id": project_id}

content_type = self.PROJECT_TYPE_RESPOSE_MAP[project_type]
content_type = self.PROJECT_TYPE_RESPONSE_MAP[project_type]

response = self.client.request(
url=self.URL_GET_BY_ID.format(image_id=item_id),
Expand Down