报错提示:
RuntimeError: BlobReader error: The version of imported blob doesn't match graph_transformer
解决方法:
这是因为你的模型版本和openvino版本不匹配,用下面这个代码看一下你的模型要求哪个版本的openvino。
#!/usr/bin/env python3
# coding=utf-8
import argparse
import json
from pathlib import Path
import depthai as dai
parser = argparse.ArgumentParser()
parser.add_argument("blob_path", type=str, help="blob's path")
args = parser.parse_args()
def get_info(tensor):
return {
"name": tensor.name,
"dataType": tensor.dataType.name,
"dims": tensor.dims[::-1],
"numDimensions": tensor.numDimensions,
"offset": tensor.offset,
"order": tensor.order.name,
"strides": tensor.strides,
}
blobPath = Path(args.blob_path)
net = dai.OpenVINO.Blob(blobPath.as_posix())
networkInputs = net.networkInputs
for name, networkInput in networkInputs.items():
networkInputs[name] = get_info(networkInput)
networkOutputs = net.networkOutputs
for name, networkOutput in networkOutputs.items():
networkOutputs[name] = get_info(networkOutput)
print("Supported OpenVINO versions:")
for version in dai.OpenVINO.getVersions():
print("\t" + version.name)
print("Blob OpenVINO Version: {}".format(net.version.name))
print("OpenVINO version of blob is supported: {}".format(net.version in dai.OpenVINO.getVersions()))
print("")
blob_info = json.dumps(
{
"networkInputs": networkInputs,
"networkOutputs": networkOutputs,
"openvinoVersion": net.version.name
},
sort_keys=True,
indent=4,
)
print(f"{blobPath.name}: \n", blob_info)
blobPath.with_suffix(".json").write_text(blob_info)
下面这个是官方默认的获取OAK设备blob信息的代码:
#!/usr/bin/env python3
# coding=utf-8
import argparse
import json
from pathlib import Path
import depthai as dai
parser = argparse.ArgumentParser()
parser.add_argument("blob_path", type=str, help="blob's path")
args = parser.parse_args()
def get_info(tensor):
return {
"name": tensor.name,
"dataType": tensor.dataType.name,
"dims": tensor.dims[::-1],
"numDimensions": tensor.numDimensions,
"offset": tensor.offset,
"order": tensor.order.name,
"strides": tensor.strides,
}
blobPath = Path(args.blob_path)
net = dai.OpenVINO.Blob(blobPath.as_posix())
networkInputs = net.networkInputs
for name, networkInput in networkInputs.items():
networkInputs[name] = get_info(networkInput)
networkOutputs = net.networkOutputs
for name, networkOutput in networkOutputs.items():
networkOutputs[name] = get_info(networkOutput)
blob_info = json.dumps(
{"networkInputs": networkInputs, "networkOutputs": networkOutputs},
sort_keys=True,
indent=4,
)
print(f"{blobPath.name}: \n", blob_info)
blobPath.with_suffix(".json").write_text(blob_info)