Skip to content

Commit

Permalink
add names of input and output nodes of onnx graph (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
djdameln committed Dec 2, 2021
1 parent e48835f commit 310b6e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion anomalib/core/callbacks/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def on_train_end(self, trainer, pl_module: LightningModule) -> None: # pylint:
onnx_path = os.path.join(self.dirpath, self.filename + ".onnx")
height, width = self.input_size
torch.onnx.export(
pl_module.model, torch.zeros((1, 3, height, width)).to(pl_module.device), onnx_path, opset_version=11
pl_module.model,
torch.zeros((1, 3, height, width)).to(pl_module.device),
onnx_path,
opset_version=11,
input_names=["input"],
output_names=["output"],
)
optimize_command = "mo --input_model " + onnx_path + " --output_dir " + self.dirpath
os.system(optimize_command)

0 comments on commit 310b6e4

Please sign in to comment.