GUI
The TwinCAT 3 Machine Learning Model Manager is the central UI for the editing of ML model description files. The tool is integrated in Visual Studio and can be opened via the menu bar under TwinCAT > Machine Learning.
Required Visual Studio version The graphic interface of the TwinCAT 3 Machine Learning Model Manager is compatible with Visual Studio 2017 and 2019 as well as the TcXaeShell. If you use a different version, you can run the interface as a standalone executable. This is located in <TwinCATInstallDir>\3.1\Components\TcMachineLearning\ML_VS_Extension\ ModelManagerStandalone.exe. |
As an alternative to the editing of ML model description files via the interface of the TwinCAT 3 Machine Learning Model Manager, you can also use a command line tool, see CLI, or a Python library, see Python API.
Conversion of ML model files
A conversion tool for ML model description files is located on the Convert tool tab. XML and ONNX files can be selected and converted to XML or BML format.
Notice | |
Conversion of Beckhoff BML back to XML is not provided for The objective of Beckhoff BML is to represent the content as a not freely readable binary file. Therefore, the conversion process from Beckhoff BML to Beckhoff XML is not provided for. |
The File Browser is opened via Select files and ML model description files can be selected (multi-selection is possible by Ctrl + click). Selected ML model files are listed on the left-hand side with their path and file name. Files can be removed from the list again with Remove selected from list.
Listed ML model description files can be selected in the left-hand list (multi-selection is possible with Ctrl + click here, too) and converted with Convert files into the format selected in the drop-down menu. The converted files are saved in the converted file path. The default path is <TwinCATPath>\Functions\TF38xx-Machine-Learning\ConvertToolFiles. The converted file path can be opened in the File Browser by clicking Open converted file path.
The path can be changed with Select converted files path. The change is retained even after restarting the PC.
Creating a multi-engine description
To create a multi-engine, multiple ML model description files must be loaded with Select files. The entries are then visible, engine-based, in the list on the left-hand side. If several engines already exist in a description file, they are listed individually in the list.
The MergeReferenceName field is freely editable. A reference name for the selected engine can be entered here so that this engine is addressable in the PLC via this reference, cf. PredictRef and GetEngineIdFromRef. If the EngineId is used in the PLC instead of the reference name, the rule is that the uppermost engine in the list bears the ID = 0 and those that follow it accordingly 1, 2, 3 and so on.
Using the IsIncluded checkbox you can specify whether or not a selected engine should be included in the merged description file.
The position of the engines in the list can be manipulated in the central section of the user interface. Selected engines can be moved up or down in the list (up and down arrow). Any number of engines can be selected at the same time. Also, using the cross symbol, any number of engines can be manipulated at the same time with regard to the IsIncluded checkbox. If two engines are selected, their places can be swapped using the round double-arrow symbol. Engines can be removed from the list using the recycle bin symbol.
The name of the merged ML description file can be entered in the text box in the central section. With Merge, the file is generated and saved in the file path <TwinCATPath>\Functions\TF38xx-Machine-Learning\MergeToolFiles. The path can be changed with Select target path.
Extracting multi-engine descriptions
Using the Extract tool it is possible to separate merged description files again. An ML model description file can be loaded using Select file to extract. All engines that it contains appear in the list on the left-hand side. If an engine is selected, it can be converted to a discrete ML description file using Extract. The name of the newly generated file is to be entered using the text box. If the Auto file name checkbox is active, the string in the text box is appended to the original file name. If the checkbox is inactive, only the string in the text box is used as the new file name. The newly generated file is saved in the file path <TwinCATPath>\Functions\TF38xx-Machine-Learning\ExtractToolFiles. The path can be changed with Select target path.
Creating metadata for the model
The Configuration tool tab displays the configurator for:
An ML description file can be selected using Select file and then edited. After editing, the original file is overwritten using Save changes.
The Custom Attributes are edited using the buttons:
- Add attribute entry: Adds an attribute to the selected tree item. The tree item must be selected in the left-hand list.
- If an attribute is created, then the name, the data type and the value or values respectively must be specified.
- Attributes are deleted by selecting the attribute and pressing the Delete button.
- Add tree entry: Adds a tree item under the selected tree item (as a subtree item).
- Rename tree entry: The selected tree item can be renamed.
- Remove tree entry: The selected tree item incl. the subtree items is deleted.
The editing area for Input and Output Transformations can be enabled by activating the Trafo active checkbox. Depending on the number of inputs and outputs, a corresponding number of rows is offered, in each of which scaling and offset are to be entered, cf. XML Tag Auxiliary Specifications. A value from a list of numbers from the clipboard can be entered as an offset or scaling using the Paste Scaling and Paste Offset buttons. The number sequence can be separated by comma, semicolon or space. Only the number of numbers in the list must match the number of inputs or outputs respectively.
The Producer and Target Version Information is set automatically by the TwinCAT 3 ML Model Manager. The Target Version is determined automatically on the basis of the feature set of the model description file used. If an older ML Runtime version is used to load this model file, a warning message appears when executing the Configure method.
The number of inputs and outputs of the model as well as the model type are displayed in the lower right area of the window. This cannot be edited and is only for information.