Python Interface
Installation des Python Package
Das Python Package liegt als whl-Datei im Ordner <TwinCatInstallDir>\Functions\TF38xx-Machine-Learning\Utilities\ModelManagerAPI\PythonPackage.
Um das Package zu installieren, nutzen Sie pip install
<TwinCatInstallDir>\Functions\TF38xx-Machine-Learning\Utilities\ModelManagerAPI\PythonPackage\<whl-file-name>. Der Ordner enthält ggf. unterschiedliche Versionen des Package (nur, wenn Sie ein neues Setup über ein altes TwinCAT Machine Learning Setup installiert haben).
Achten Sie darauf, immer die aktuelle Version zu nutzen.
Verwenden der API
Das Package wird geladen mit
import beckhoff.toolbox as tb
Erstellen einer JSON und PlcOpenXml aus einer ONNX-Datei
tb.onnxprep("C:\\PathTo\\myONNX.onnx")
Anzeigen von Modellinformationen
tb.info("C:\\PathTo\\myONNX.json")
Custom Attributes hinzufügen
new_ca = { 'nID' : -34234, 'bTested' : True, 'fNum' : 324.3E-12, 'AnotherTreeItem' : { 'fPi' : 3.13412, 'bFalseFlag' : False }}
tb.modify_ca("C:\\PathTo\\myONNX.json","C:\\PathTo\\myONNX_ca.json", new_ca)
Model Description (Name, Version, Autor usw. eines Modells) hinzufügen
model_description = {
"new_version" : "2.3.1.0",
"new_name" : "CurrentPreControlAxis42",
"new_desc":"This is the most awesome model to control Axis42",
"new_author":"Max",
"new_tags":"awesome, ingenious, astounding",
}
tb.modify_md("C:\\PathTo\\myONNX.json", "C:\\PathTo\\myONNX_md.json",
**model_description)