Artifacts Reporting

The example demonstrates storing artifacts with experiments by uploading them to a specified location. This includes artifacts which are registered and dynamically synchronized if they change as the experiment runs, and artifacts which are one-time static uploads.

You can set a default output destination in your configuration file (see sdk.development.default_output_uri), provide an output destination location when initializing the Task (see the output_uri parameter in the Task.init method), set it per experiment in the Trains Web (UI), EXECUTION tab. These artifact storage destinations are the same as the destination for checkpoint models (model snapshots); however, they are not the same as the destination for debug samples (see Logger.set_default_upload_destination).

When the script runs, it creates an experiment named artifacts example, which is associated with the examples project. Trains reports these plots in the Trains Web (UI), experiment details, ARTIFACTS tab.

Dynamic artifacts

To upload (register) dynamic artifacts, use the Task.register_artifact method. Data audition is the primary use of registered artifacts.

Pandas DataFrames

Currently, Trains supports registering Pandas DataFrames as dynamically synchronized artifacts.

For example, create a Pandas DataFrame and register it.

df = pd.DataFrame(
        'num_legs': [2, 4, 8, 0],
        'num_wings': [2, 0, 0, 0],
        'num_specimen_seen': [10, 2, 1, 8]
    index=['falcon', 'dog', 'spider', 'fish']

# Register Pandas object as artifact to watch
# (it will be monitored in the background and automatically synced and uploaded)
task.register_artifact('train', df, metadata={'counting': 'legs', 'max legs': 69}))

You can change the artifact and it will update in Trains Server, or retrieve the artifact by calling the Task.get_registered_artifacts method.

# change the artifact object
df.sample(frac=0.5, replace=True, random_state=1)
# or access it from anywhere using the Task's get_registered_artifacts()
Task.current_task().get_registered_artifacts()['train'].sample(frac=0.5, replace=True, random_state=1)

Static artifacts

To upload static artifacts, use the Task.upload_artifact method.

Pandas DataFrames

Store Pandas DataFrames as static, as well as, dynamic artifacts.

# add and upload pandas.DataFrame (onetime snapshot of the object)
task.upload_artifact('Pandas', artifact_object=df)

Local files

Store local files.

# add and upload local file artifact
task.upload_artifact('local file', artifact_object=os.path.join('data_samples', 'dancing.jpg'))


Store dictionaries. Trains stores them as JSON files.

# add and upload dictionary stored as JSON)
task.upload_artifact('dictionary', df.to_dict())

Numpy objects

Store Numpy objects. Trains stores them as NPZ files.

# add and upload Numpy Object (stored as .npz file)
task.upload_artifact('Numpy Eye', np.eye(100, 100))

Image files

Store image files. Trains stores them as PNG files.

# add and upload Image (stored as .png file)
im ='data_samples', 'dancing.jpg'))
task.upload_artifact('pillow_image', im)


Store a folder, and the files it contains.

# add and upload a folder, artifact_object should be the folder path
task.upload_artifact('local folder', artifact_object=os.path.join('data_samples'))


Use wildcards to store selected files in a folder.

# add and upload a wildcard
task.upload_artifact('wildcard jpegs', artifact_object=os.path.join('data_samples', '*.jpg'))