Skip to content

Commit 2973c4e

Browse files
committed
remove convert platform
1 parent d5c6881 commit 2973c4e

File tree

4 files changed

+2
-93
lines changed

4 files changed

+2
-93
lines changed

superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def consensus(*args, **kwargs):
8787
)
8888
from .input_converters.conversion import (
8989
coco_split_dataset, convert_project_type, export_annotation,
90-
import_annotation, convert_json_version, convert_platform
90+
import_annotation, convert_json_version
9191
)
9292

9393
from .old_to_new_format_convertor import update_json_format

superannotate/input_converters/conversion.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from .export_from_sa_conversions import export_from_sa
99
from .import_to_sa_conversions import import_to_sa
1010
from .sa_conversion import (
11-
degrade_json, sa_convert_project_type, split_coco, upgrade_json, _toDesktop,
12-
_toWeb
11+
degrade_json, sa_convert_project_type, split_coco, upgrade_json
1312
)
1413

1514
ALLOWED_TASK_TYPES = [
@@ -488,39 +487,3 @@ def convert_json_version(input_dir, output_dir, version=2):
488487
raise SABaseException(0, "'version' is either 1 or 2.")
489488

490489
return converted_files
491-
492-
493-
def convert_platform(input_dir, output_dir, platform_type):
494-
"""
495-
Converts from Desktop App to Web or reverse'.
496-
497-
:param input_dir: Path to the dataset folder that you want to convert.
498-
:type input_dir: Pathlike(str or Path)
499-
:param output_dir: Path to the folder, where you want to have converted dataset.
500-
:type output_dir: Pathlike(str or Path)
501-
:param platform_type: Output platform 'Desktop' or 'Web'.
502-
:type platform_type: str
503-
504-
:return: List of converted files
505-
:rtype: list
506-
"""
507-
param_info = [
508-
(input_dir, 'input_dir', (str, Path)),
509-
(output_dir, 'output_dir', (str, Path)),
510-
(platform_type, 'platform_type', str)
511-
]
512-
for param in param_info:
513-
_type_sanity(param[0], param[1], param[2])
514-
515-
if isinstance(input_dir, str):
516-
input_dir = Path(input_dir)
517-
if isinstance(output_dir, str):
518-
output_dir = Path(output_dir)
519-
output_dir.mkdir(parents=True, exist_ok=True)
520-
521-
if platform_type == 'Web':
522-
_toWeb(input_dir, output_dir)
523-
elif platform_type == 'Desktop':
524-
_toDesktop(input_dir, output_dir)
525-
else:
526-
raise SABaseException(0, "'platform_type' is either 'Desktop' or 'Web'")

superannotate/input_converters/sa_conversion.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,13 @@ def _update_json_format(old_json_path, project_type):
296296

297297
new_json_data["metadata"] = dict.fromkeys(meta_keys)
298298

299-
#set image name
300299
suffix = "___objects.json" if project_type == "Vector" else "___pixel.json"
301-
# image_name = os.path.basename(old_json_path).split(suffix)[0]
302300
image_name = str(old_json_path.name).split(suffix)[0]
303301
metadata = new_json_data["metadata"]
304302
metadata["name"] = image_name
305303

306304
for item in old_json_data:
307305
object_type = item.get("type")
308-
#add metadata
309306
if object_type == "meta":
310307
meta_name = item["name"]
311308
if meta_name == "imageAttributes":
@@ -317,10 +314,8 @@ def _update_json_format(old_json_path, project_type):
317314
metadata["lastAction"] = dict.fromkeys(["email", "timestamp"])
318315
metadata["lastAction"]["email"] = item.get("userId")
319316
metadata["lastAction"]["timestamp"] = item.get("timestamp")
320-
#add tags
321317
elif object_type == "tag":
322318
new_json_data["tags"].append(item.get("name"))
323-
#add comments
324319
elif object_type == "comment":
325320
item.pop("type")
326321
item["correspondence"] = item["comments"]
@@ -329,7 +324,6 @@ def _update_json_format(old_json_path, project_type):
329324
comment.pop("id")
330325
item.pop("comments")
331326
new_json_data["comments"].append(item)
332-
#add instances
333327
else:
334328
new_json_data["instances"].append(item)
335329

@@ -384,22 +378,3 @@ def _degrade_json_format(new_json_path):
384378
sa_loader.append(tag)
385379

386380
return sa_loader
387-
388-
389-
def _toWeb(input_dir, output_dir):
390-
json_files = list(input_dir.glob('*.json'))
391-
for json_file in json_files:
392-
file_name = '%s___objects' % json_file.name
393-
json_data = json.load(open(json_file))
394-
json_data['comments'] = []
395-
write_to_json(output_dir / file_name, json_data)
396-
397-
398-
def _toDesktop(input_dir, output_dir):
399-
json_files = list(input_dir.glob('*.json'))
400-
401-
for json_file in json_files:
402-
file_name = str(json_file.name).replace('___objects', '')
403-
json_data = json.load(open(json_file))
404-
del json_data['comments']
405-
write_to_json(output_dir / file_name, json_data)

tests/converter_test/test_platform_converter.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)