# Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
model = args.model
- model_bin = None
- model_name, model_ext = os.path.splitext(model)
- log.info(f"Loading network files:\n\t{model}")
- if model_ext == ".xml":
- # Read .bin weights for IR format only
- model_bin = model_name + ".bin"
- log.info(f"\n\t{model_bin}")
- net = ie.read_network(model=model, weights=model_bin)
+ log.info(f"Loading network:\n\t{model}")
+ net = ie.read_network(model=model)
assert len(net.input_info.keys()) == 1, "Sample supports only single input topologies"
assert len(net.outputs) == 1, "Sample supports only single output topologies"
# Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
model = args.model
- model_bin = None
- model_name, model_ext = os.path.splitext(model)
- log.info(f"Loading network files:\n\t{model}")
- if model_ext == ".xml":
- # Read .bin weights for IR format only
- model_bin = model_name + ".bin"
- log.info(f"\n\t{model_bin}")
- net = ie.read_network(model=model, weights=model_bin)
+ log.info(f"Loading network:\n\t{model}")
+ net = ie.read_network(model=model)
assert len(net.input_info.keys()) == 1, "Sample supports only single input topologies"
assert len(net.outputs) == 1, "Sample supports only single output topologies"
# ---1. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format ---
model = args.model
- model_bin = None
- model_name, model_ext = os.path.splitext(model)
- log.info(f"Loading network files:\n\t{model}")
- if model_ext == ".xml":
- # Read .bin weights for IR format only
- model_bin = model_name + ".bin"
- log.info(f"\n\t{model_bin}")
- net = ie.read_network(model=model, weights=model_bin)
+ log.info(f"Loading network:\n\t{model}")
+ net = ie.read_network(model=model)
func = ng.function_from_cnn(net)
ops = func.get_ordered_ops()
# -----------------------------------------------------------------------------------------------------
# Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
model = args.model
- model_bin = None
- model_name, model_ext = os.path.splitext(model)
- log.info(f"Loading network files:\n\t{model}")
- if model_ext == ".xml":
- # Read .bin weights for IR format only
- model_bin = model_name + ".bin"
- log.info(f"\n\t{model_bin}")
- net = ie.read_network(model=model, weights=model_bin)
+ log.info(f"Loading network:\n\t{model}")
+ net = ie.read_network(model=model)
assert len(net.input_info.keys()) == 1, "Sample supports only single input topologies"
assert len(net.outputs) == 1, "Sample supports only single output topologies"
raise Exception("Path to the model {} doesn't exist or it's a directory".format(model))
model_ = model.encode()
- if not (fnmatch(model, "*.onnx") or fnmatch(model, "*.prototxt")):
+ if not (fnmatch(model, "*.onnx") or fnmatch(model, "*.prototxt")) and weights:
weights = os.fspath(weights)
if not os.path.isfile(weights):
raise Exception("Path to the weights {} doesn't exist or it's a directory".format(weights))
net = ie.read_network(model=test_net_xml, weights=test_net_bin)
assert isinstance(net, IENetwork)
+ net = ie.read_network(model=test_net_xml)
+ assert isinstance(net, IENetwork)
+
def test_read_network_as_path():
ie = IECore()
net = ie.read_network(model=test_net_xml, weights=Path(test_net_bin))
assert isinstance(net, IENetwork)
+ net = ie.read_network(model=Path(test_net_xml))
+ assert isinstance(net, IENetwork)
+
def test_read_network_from_onnx():
ie = IECore()