From: 이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Wed, 7 Aug 2019 00:42:59 +0000 (+0900) Subject: [nnpackage] nnpackager -c will create compressed nnpackage (#6278) X-Git-Tag: submit/tizen/20190809.050447~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b04b6500e12104a62bbd92209aa3cff28d88c7d2;p=platform%2Fcore%2Fml%2Fnnfw.git [nnpackage] nnpackager -c will create compressed nnpackage (#6278) Use "nnpackage -c path_to_nnpackage_root" to get compressed nnpackage. Also it removed redundant parenthesis in if condition. Signed-off-by: Sanggyu Lee --- diff --git a/tools/nnpackager/nnpackager.py b/tools/nnpackager/nnpackager.py index 5d835ac..8e2805a 100755 --- a/tools/nnpackager/nnpackager.py +++ b/tools/nnpackager/nnpackager.py @@ -5,6 +5,7 @@ import os from collections import OrderedDict import sys import argparse +import shutil def verify(path): @@ -38,11 +39,27 @@ def verify(path): print("models attribute does not exist.") +def compress(path): + nnpackage_name = os.path.basename(os.path.normpath(path)) + shutil.make_archive(nnpackage_name, 'zip', path) + print("nnpackage compression is done") + + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('path', type=str, help='the path to nnpackage') parser.add_argument( '-v', '--verify', action='store_true', help="verify nnpackage (default: false)") + parser.add_argument( + '-c', + '--compress', + action='store_true', + help="compress nnpackage (default: false)") + args = parser.parse_args() - if (args.verify): + + if args.verify: verify(args.path) + + if args.compress: + compress(args.path)