Manual Model Upload

The example demonstrates Trains tracking of a manually configured model created with TensorFlow, including model snapshots (checkpoint models), hyperparameters, and output to the console. When the script runs, it creates an experiment named Model configuration and upload, which is associated with the examples project.


This example shows two ways to connect a configuration, using the same Trains Python Client package method, Task.connect_configuration.

Connect a configuration file by calling the Task.connect_configuration method, providing the file's path. Trains Server stores a copy of the file.

# Connect a local configuration file
config_file = os.path.join('..', '..', 'reporting', 'data_samples', 'sample.json')
config_file = task.connect_configuration(config_file)

Or, create a configuration dictionary and call that same Task.connect_configuration method, providing the dictionary.

model_config_dict = {
    'value': 13.37,
    'dict': {'sub_value': 'string', 'sub_integer': 11},
    'list_of_ints': [1, 2, 3, 4],
model_config_dict = task.connect_configuration(model_config_dict)

If the configuration changes, Trains track it.

model_config_dict['new value'] = 10
model_config_dict['value'] *= model_config_dict['new value']

In the Trains Web (UI), the manually connected configuration appears in the ARTIFACTS tab, Input Model area.

You can see that new value is tracked. The configuration parameter value is 133.7 (10 its original value of 13.37), and the parameter new value is now in the configuration.

In the Trains Web (UI), the output model's configuration appears in the ARTIFACTS tab, Output Model area.

The output model has the same configuration that was manually connected to the Task.

In the model details (which appear when you click the model name in the ARTIFACTS tab, Output Model area), you can see the configuration, the NETWORK tab.

This is the same configuration you see in the ARTIFACTS tabs, Output Model area.

Class label enumeration

To connect class label enumeration, create a dictionary of class labels and value, and then call the Task.connect_label_enumeration method, providing it the dictionary.

# store the label enumeration of the training model
labels = {'background': 0, 'cat': 1, 'dog': 2}

In the model details, you can see the class label enumeration in the LABELS tab.

Output model

Trains logs the following output model information:

  • The output model location (URL)
  • Model snapshots / checkpoint model locations (URLs)
  • The experiment creating the model
  • Other general information about the model.

These appear in the model details GENERAL tab.

tempdir = tempfile.mkdtemp(), os.path.join(tempdir, "model"))