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
1 change: 1 addition & 0 deletions docs/source/superannotate.sdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ________
.. autofunction:: superannotate.delete_folders
.. autofunction:: superannotate.rename_folder
.. autofunction:: superannotate.upload_images_to_project
.. autofunction:: superannotate.attach_image_urls_to_project
.. autofunction:: superannotate.upload_images_from_public_urls_to_project
.. autofunction:: superannotate.upload_images_from_google_cloud_to_project
.. autofunction:: superannotate.upload_images_from_azure_blob_to_project
Expand Down
4 changes: 2 additions & 2 deletions superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def consensus(*args, **kwargs):
upload_images_from_google_cloud_to_project,
upload_images_from_public_urls_to_project,
upload_images_from_s3_bucket_to_project, upload_images_to_project,
upload_preannotations_from_folder_to_project, upload_video_to_project,
upload_videos_from_folder_to_project
attach_image_urls_to_project, upload_preannotations_from_folder_to_project,
upload_video_to_project, upload_videos_from_folder_to_project
)
from .db.search_projects import search_projects
from .db.teams import (
Expand Down
27 changes: 27 additions & 0 deletions superannotate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def main():
create_folder(command, further_args)
elif command == "upload-images":
image_upload(command, further_args)
elif command == "attach-image-urls":
attach_image_urls(command, further_args)
elif command == "upload-videos":
video_upload(command, further_args)
elif command in ["upload-preannotations", "upload-annotations"]:
Expand Down Expand Up @@ -288,6 +290,31 @@ def image_upload(command_name, args):
)


def attach_image_urls(command_name, args):
parser = argparse.ArgumentParser(prog=_CLI_COMMAND + " " + command_name)
parser.add_argument(
'--project', required=True, help='Project name to upload'
)
parser.add_argument(
'--attachments',
required=True,
help='path to csv file on attachments metadata'
)
parser.add_argument(
'--annotation_status',
required=False,
default="NotStarted",
help=
'Set images\' annotation statuses after upload. Default is NotStarted'
)
args = parser.parse_args(args)
sa.attach_image_urls_to_project(
project=args.project,
attachments=args.attachments,
annotation_status=args.annotation_status
)


def export_project(command_name, args):
parser = argparse.ArgumentParser(prog=_CLI_COMMAND + " " + command_name)
parser.add_argument(
Expand Down
12 changes: 12 additions & 0 deletions superannotate/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"Completed": 5,
"Skipped": 6
}

_UPLOAD_STATES_STR_TO_CODES = {"Initial": 1, "Basic": 2, "External": 3}
_UPLOAD_STATES_CODES_TO_STR = {1: "Initial", 2: "Basic", 3: "External"}

_USER_ROLES = {"Admin": 2, "Annotator": 3, "QA": 4, "Customer": 5, "Viewer": 6}
_AVAILABLE_SEGMENTATION_MODELS = ['autonomous', 'generic']
_MODEL_TRAINING_STATUSES = {
Expand Down Expand Up @@ -118,6 +122,14 @@ def annotation_status_str_to_int(annotation_status):
return _ANNOTATION_STATUSES[annotation_status]


def upload_state_str_to_int(upload_state):
return _UPLOAD_STATES_STR_TO_CODES[upload_state]


def upload_state_int_to_str(upload_state):
return _UPLOAD_STATES_CODES_TO_STR[upload_state]


def annotation_status_int_to_str(annotation_status):
"""Converts metadata annotation_status int value to a string

Expand Down
7 changes: 6 additions & 1 deletion superannotate/db/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tqdm import tqdm

from ..api import API
from ..common import annotation_status_str_to_int
from ..common import annotation_status_str_to_int, upload_state_int_to_str
from ..exceptions import (
SABaseException, SAExistingExportNameException,
SANonExistingExportNameException
Expand Down Expand Up @@ -123,6 +123,11 @@ def prepare_export(
"""
if not isinstance(project, dict):
project = get_project_metadata_bare(project)
upload_state = upload_state_int_to_str(project.get("upload_state"))
if upload_state == "External" and include_fuse == True:
logger.info(
"Include fuse functionality is not supported for projects containing images attached with URLs"
)
team_id, project_id = project["team_id"], project["id"]
if annotation_statuses is None:
annotation_statuses = [2, 3, 4, 5]
Expand Down
13 changes: 13 additions & 0 deletions superannotate/db/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,12 @@ def download_image(
)

project, project_folder = get_project_and_folder_metadata(project)
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
if upload_state == "External":
raise SABaseException(
0,
"The function does not support projects containing images attached with URLs"
)
img = get_image_bytes(
(project, project_folder), image_name, variant=variant
)
Expand Down Expand Up @@ -698,6 +704,13 @@ def get_image_bytes(project, image_name, variant='original'):
:return: io.BytesIO() of the image
:rtype: io.BytesIO()
"""
project, project_folder = get_project_and_folder_metadata(project)
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
if upload_state == "External":
raise SABaseException(
0,
"The function does not support projects containing images attached with URLs"
)
if variant not in ["original", "lores"]:
raise SABaseException(
0, "Image download variant should be either original or lores"
Expand Down
14 changes: 12 additions & 2 deletions superannotate/db/project_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def upload_image_to_project(
:type image_quality_in_editor: str
"""
project, project_folder = get_project_and_folder_metadata(project)
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
if upload_state == "External":
raise SABaseException(
0,
"The function does not support projects containing images attached with URLs"
)
annotation_status = common.annotation_status_str_to_int(annotation_status)
if image_quality_in_editor is None:
image_quality_in_editor = get_project_default_image_quality_in_editor(
Expand Down Expand Up @@ -121,8 +127,12 @@ def upload_image_to_project(
else:
project_folder_id = None
__create_image(
[img_name], [key], project, annotation_status, prefix,
[images_info_and_array[2]], project_folder_id
[img_name], [key],
project,
annotation_status,
prefix, [images_info_and_array[2]],
project_folder_id,
upload_state="Basic"
)

while True:
Expand Down
Loading