Skip to content

Commit 3f4c007

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Merge branch 're-design-sdk' of https://github.com/superannotateai/superannotate-python-sdk into re-design-sdk
2 parents 23d4629 + 96fa813 commit 3f4c007

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/superannotate/lib/app/input_converters/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def export_annotation(
224224
def import_annotation(
225225
input_dir,
226226
output_dir,
227-
dataset_format,
227+
dataset_format = "superannotate",
228228
dataset_name="",
229229
project_type="Vector",
230230
task="object_detection",

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def upload_images(
9191
project: str,
9292
folder: str,
9393
extensions: str = constances.DEFAULT_IMAGE_EXTENSIONS,
94-
set_annotation_status: str = constances.AnnotationStatus.NOT_STARTED.value,
94+
set_annotation_status: str = constances.AnnotationStatus.NOT_STARTED.name,
9595
exclude_file_patterns=constances.DEFAULT_FILE_EXCLUDE_PATTERNS,
9696
recursive_subfolders=False,
9797
image_quality_in_editor=None,
@@ -129,7 +129,11 @@ def upload_image(image_path: str):
129129
return ProcessedImage(uploaded=False, path=image_path, entity=None)
130130

131131
paths = []
132-
for extension in extensions.strip().split(","):
132+
133+
if isinstance(extensions,str):
134+
extensions = extensions.strip().split(",")
135+
136+
for extension in extensions:
133137
if recursive_subfolders:
134138
paths += list(Path(folder).rglob(f"*.{extension.lower()}"))
135139
if os.name != "nt":
@@ -164,7 +168,7 @@ def upload_image(image_path: str):
164168
uploaded_image_entities.append(processed_image.entity)
165169
else:
166170
failed_images.append(processed_image.path)
167-
progress_bar.update(1)
171+
progress_bar.update(1)
168172

169173
for i in range(0, len(uploaded_image_entities), 500):
170174
self.controller.upload_images(
@@ -258,30 +262,33 @@ def _upload_annotations(
258262
if not task:
259263
task = "object_detection"
260264

265+
annotations_path = folder
261266
with tempfile.TemporaryDirectory() as temp_dir:
262-
import_annotation(
263-
input_dir=folder,
264-
output_dir=temp_dir,
265-
dataset_format=format,
266-
dataset_name=data_set_name,
267-
project_type=constances.ProjectType.get_name(
268-
project["project"].project_type
269-
),
270-
task=task,
271-
)
272-
classes_path = f"{temp_dir}/classes/classes.json"
267+
if format != 'SuperAnnotate':
268+
import_annotation(
269+
input_dir=folder,
270+
output_dir=temp_dir,
271+
dataset_format=format,
272+
dataset_name=data_set_name,
273+
project_type=constances.ProjectType.get_name(
274+
project["project"].project_type
275+
),
276+
task=task,
277+
)
278+
annotations_path = temp_dir
279+
classes_path = f"{folder}/classes/classes.json"
273280
self.controller.create_annotation_classes(
274281
project_name=project_name,
275282
annotation_classes=json.load(open(classes_path)),
276283
)
277-
annotation_paths = get_annotation_paths(temp_dir)
284+
annotation_paths = get_annotation_paths(annotations_path)
278285
chunk_size = 10
279286
with tqdm(total=len(annotation_paths)) as progress_bar:
280287
for i in range(0, len(annotation_paths), chunk_size):
281288
response = self.controller.upload_annotations_from_folder(
282289
project_name=project["project"].name,
283290
folder_name=folder_name,
284-
folder_path=temp_dir,
291+
folder_path=annotations_path,
285292
annotation_paths=annotation_paths[
286293
i : i + chunk_size # noqa: E203
287294
],

src/superannotate/lib/core/usecases.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,13 +3593,16 @@ def execute(self):
35933593
if export["name"] == self._export_name:
35943594
export_id = export["id"]
35953595
break
3596+
if not export_id:
3597+
raise AppException("Export not found.")
35963598

35973599
while True:
35983600
export = self._service.get_export(
35993601
team_id=self._project.team_id,
36003602
project_id=self._project.uuid,
36013603
export_id=export_id,
36023604
)
3605+
36033606
if export["status"] == ExportStatus.IN_PROGRESS.value:
36043607
print("Waiting 5 seconds for export to finish on server.")
36053608
time.sleep(5)

0 commit comments

Comments
 (0)