Aidge Model Explorer#

Plugin#

class aidge_model_explorer.AidgeAdapter#

Adapter for converting ONNX models or aidge_core.GraphView objects into ModelExplorerGraphs format, for use in the ModelExplorer GUI.

This adapter supports .onnx files and uses internal converters to transform models into the graph structure expected by the frontend.

Variables:

metadata (AdapterMetadata) – Metadata about the adapter, including name, description, source repository, and supported file extensions.

__init__()#

Initialize the AidgeAdapter.

convert(model_path: str, settings: Dict) ModelExplorerGraphs#

Convert an ONNX model file to a ModelExplorerGraphs object.

Parameters:
  • model_path (str) – Path to the ONNX model file.

  • settings (Dict) – Dictionary of visualization or conversion settings.

Returns:

A dictionary containing a list of converted graphs under the key ‘graphs’.

Return type:

ModelExplorerGraphs

Raises:

RuntimeError – If the file extension is not supported.

convert_graphview(model: GraphView, settings: Dict, name: str = '', converter_config: ConverterConfig | None = None) ModelExplorerGraphs#

Convert an in-memory aidge_core.GraphView object to ModelExplorerGraphs.

Parameters:
  • model (GraphView) – The graph view to convert.

  • settings (Dict) – Dictionary of visualization or conversion settings.

  • name (str, optional) – Optional name for the graph. Defaults to ‘’.

  • converter_config (Optional[ConverterConfig]) – Optional configuration object defining custom attributes and metadata.

Returns:

A dictionary containing a list of converted graphs under the key ‘graphs’.

Return type:

ModelExplorerGraphs

Custom configuration#

The Aidge plugin allow for user to add their own attribute and metadata.

Attribute refers to properties attached and displayed at the node level. Metadata refers to properties attached and displayed at the edge level.

class aidge_model_explorer.CustomOutMetadata(metadata_name: str, metadata_callable: MetadataCallable)#

Bases: object

A configuration container for customizing output metadata in the ModelExplorer GUI.

Parameters:
  • metadata_name (str) – The name of the metadata field to display.

  • metadata_callable (MetadataCallable) – A callable that extracts the metadata value from a node and its output tensor. If the callable returns None, the metadata will not be displayed.

__init__(metadata_name: str, metadata_callable: MetadataCallable) None#
metadata_callable: MetadataCallable#
metadata_name: str#
class aidge_model_explorer.CustomAttribute(attr_name: str, attr_callable: AttributeCallable)#

Bases: object

A configuration container for customizing node attributes in the ModelExplorer GUI.

Parameters:
  • attr_name (str) – The name of the attribute field to display.

  • attr_callable (AttributeCallable) – A callable that extracts an attribute value from a node. If the callable returns None, the attribute will not be added.

__init__(attr_name: str, attr_callable: AttributeCallable) None#
attr_callable: AttributeCallable#
attr_name: str#
class aidge_model_explorer.MetadataCallable(*args, **kwargs)#

Bases: Protocol

A callable protocol that takes an aidge_core.Node and an aidge_core.Tensor and returns a string to be stored as output metadata in the ModelExplorer GUI.

This callable is invoked for every output tensor of a node. If it returns None, no metadata attribute will be added for that tensor.

Example usage:

def extract_tensor_name(node: aidge_core.Node, tensor: aidge_core.Tensor) -> Optional[str]:
    return tensor.name if tensor.name else None

metadata_fn: MetadataCallable = extract_tensor_name
Parameters:
Returns:

A string representing the metadata value to store, or None if no metadata should be created.

Return type:

Optional[str]

__init__(*args, **kwargs)#
class aidge_model_explorer.AttributeCallable(*args, **kwargs)#

Bases: Protocol

A callable protocol that, given an aidge_core.Node, returns a string value to be stored as an attribute in the ModelExplorer GUI.

This callable will be invoked on every node. If it returns None, no attribute will be created for that node.

Example usage:

def get_label(node: aidge_core.Node) -> Optional[str]:
    return node.label if node.has_label else None

callable_instance: AttributeCallable = get_label
Parameters:

node (aidge_core.Node) – A node in the Aidge model graph.

Returns:

A string representing the attribute to store, or None if no attribute should be created.

Return type:

Optional[str]

__init__(*args, **kwargs)#
class aidge_model_explorer.ConverterConfig#

Configuration object for customizing the ModelExplorer GUI.

This class stores user-defined functions that compute additional metadata or attributes for nodes and their output tensors in a model graph.

Variables:
  • custom_output_metadata (List[CustomOutMetadata]) – A list of output metadata definitions, each specifying a name and a callable that extracts metadata from a node and its output tensor.

  • custom_attributes (List[CustomAttribute]) – A list of custom attribute definitions, each specifying a name and a callable that extracts an attribute from a node.

__init__()#

Initialize an empty ConverterConfig with no custom metadata or attributes.

add_attribute(attr_name: str, attr_callable: AttributeCallable) None#

Add a custom attribute extractor for nodes.

Parameters:
  • attr_name (str) – The name of the attribute field to be displayed in the GUI.

  • attr_callable (AttributeCallable) – A callable that takes a node and returns a string to be used as an attribute. If it returns None, no attribute will be added.

add_output_metadata(meta_data_name: str, meta_data_callable: MetadataCallable) None#

Add a custom output metadata extractor.

Parameters:
  • meta_data_name (str) – The name of the metadata field to be displayed in the GUI.

  • meta_data_callable (MetadataCallable) – A callable that takes a node and one of its output tensors, and returns a string to be used as metadata. If it returns None, no metadata will be added.

Config#

Method related to the creation of a Model Explorer config with function to load an Aidge GraphView.

aidge_model_explorer.config() ModelExplorerConfig#

Create a new config object.

class aidge_model_explorer.AidgeExplorerConfig#

Stores the data to be visualized in Model Explorer.

__init__() None#
add_graphview(graphview: GraphView, name: str, converter_config: ConverterConfig | None = None) ModelExplorerConfig#

Add a aidge_core.GraphView to the list of graph to visualize

Parameters:
  • graphview (aidge_core.GraphView) – Graph view to add to the list

  • name (str) – Name to give to the graph in the model explorer interface

  • converter_config (ConverterConfig, optional) – Configuration for the converter that let the user define custom attributes, default=None

Returns:

Return a reference to itself

Return type:

ModelExplorerConfig

Visualization#

Methods to call to visualize the graph using custom wrapper arround Model Explorer

aidge_model_explorer.visualize(graphview, name, host='localhost', port=8080, no_open_in_browser=False, embed=False) None#
aidge_model_explorer.show_ext_server(graphview, name, host='localhost', port=8080, no_open_in_browser=False) None#
aidge_model_explorer.show_in_notebook(graphview, name, host='localhost', port=8080, embed=True) None#