Skip to content

Commit e4a5b4d

Browse files
committed
add dry option
1 parent f9c7d6f commit e4a5b4d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

cli/blobconverter/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def __download_from_response(resp, fpath: Path):
194194

195195

196196
def compile_blob(blob_name, version=None, shaves=None, req_data=None, req_files=None, output_dir=None, url=None,
197-
use_cache=True, compile_params=None, data_type=None, download_ir=False, zoo_type=None):
197+
use_cache=True, compile_params=None, data_type=None, download_ir=False, zoo_type=None, dry=False):
198198
if shaves is None:
199199
shaves = __defaults["shaves"]
200200
if url is None:
@@ -225,6 +225,7 @@ def compile_blob(blob_name, version=None, shaves=None, req_data=None, req_files=
225225
url_params = {
226226
'version': version,
227227
'no_cache': not use_cache,
228+
'dry': dry,
228229
}
229230
data = {
230231
"myriad_shaves": str(shaves),
@@ -288,6 +289,9 @@ def compile_blob(blob_name, version=None, shaves=None, req_data=None, req_files=
288289
print(response.text)
289290
response.raise_for_status()
290291

292+
if dry:
293+
return response.json()
294+
291295
blob_path.parent.mkdir(parents=True, exist_ok=True)
292296
if download_ir:
293297
blob_path = blob_path.with_suffix('.zip')
@@ -489,6 +493,7 @@ def __run_cli__():
489493
parser.add_argument('--compile-params', help="Additional params to use when compiling a model to MyriadX blob")
490494
parser.add_argument('--converter-url', dest="url", help="URL to BlobConverter API endpoint used for conversion")
491495
parser.add_argument('--no-cache', dest="use_cache", action="store_false", help="Omit .cache directory and force new compilation of the blob")
496+
parser.add_argument('--dry', dest="dry", action="store_true", help="Instead of compiling the blob, return compilation commands (for manual conversion)")
492497
parser.add_argument('--zoo-list', action="store_true", help="List all models available in OpenVINO Model Zoo")
493498
parser.add_argument('--download-ir', action="store_true", help="Downloads OpenVINO IR files used to compile the blob. Result path points to a result ZIP archive")
494499

@@ -498,7 +503,7 @@ def __run_cli__():
498503

499504
common_args = {
500505
arg: getattr(args, arg)
501-
for arg in ["shaves", "data_type", "output_dir", "version", "url", "compile_params", "download_ir", "zoo_type"]
506+
for arg in ["shaves", "data_type", "output_dir", "version", "url", "compile_params", "download_ir", "zoo_type", "use_cache", "dry"]
502507
}
503508
if args.zoo_list:
504509
return zoo_list()

cli/blobconverter/test.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@
99
if not use_cache and Path(blobconverter.__defaults["output_dir"]).exists():
1010
shutil.rmtree(blobconverter.__defaults["output_dir"])
1111

12-
result = blobconverter.from_zoo(name="mobilenet-ssd", use_cache=use_cache)
12+
result = blobconverter.from_zoo(name="mobilenet-ssd", use_cache=use_cache, dry=True)
13+
print(result)
14+
15+
result = blobconverter.from_openvino(
16+
xml="../../face-detection-retail-0004.xml", # get from https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/face-detection-retail-0004/FP16/face-detection-retail-0004.xml
17+
bin="../../face-detection-retail-0004.bin", # get from https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/face-detection-retail-0004/FP16/face-detection-retail-0004.bin
18+
data_type="FP16",
19+
shaves=5,
20+
use_cache=use_cache,
21+
)
22+
print(result)
23+
24+
result = blobconverter.from_zoo(name="mobilenet-ssd", use_cache=use_cache, dry=True)
1325
print(result)
1426

1527
result = blobconverter.from_openvino(

cli/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='blobconverter',
7-
version='1.2.4',
7+
version='1.2.5',
88
description='The tool that allows you to convert neural networks to MyriadX blob',
99
long_description=io.open("README.md", encoding="utf-8").read(),
1010
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)