88from .export_from_sa_conversions import export_from_sa
99from .import_to_sa_conversions import import_to_sa
1010from .sa_conversion import (
11- degrade_json , sa_convert_project_type , split_coco , upgrade_json
11+ degrade_json , sa_convert_project_type , split_coco , upgrade_json , _toDesktop ,
12+ _toWeb
1213)
1314
1415ALLOWED_TASK_TYPES = [
@@ -486,4 +487,40 @@ def convert_json_version(input_dir, output_dir, version=2):
486487 else :
487488 raise SABaseException (0 , "'version' is either 1 or 2." )
488489
489- return converted_files
490+ 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'" )
0 commit comments