Skip to content

Logging images#

You can log either a single image or a series of images.

Supported data formats include:

  • Image file formats, such as PNG, JPEG, JPG, GIF, BMP and WebP
  • Matplotlib, Seaborn, and PIL figures
  • NumPy arrays
  • TensorFlow and PyTorch tensors

Logging single image#

Use the upload() method to log an image file from disk:


Logging series of images#

To log a series of images, instead of upload(), use the log() method.

If you supply a path to a file, use a File constructor.

Each log() call appends an image to the series, so you want to use it inside a loop.

from import File

for name in misclassified_images_names:
    y_pred = ...
    y_true = ...

In the app, you can display and navigate the logged images in a gallery view.

Viewing a series of images in Neptune

Logging Matplotlib, Seaborn, and PIL figures#

You can log Matplotlib, Seaborn, and PIL images as regular images.

When you log a figure object directly (instead of a path to a file), you don't need the File constructor.

To upload a Matplotlib figure (matplotlib.figure.Figure) as an image:

# Import matplotlib
import matplotlib.pyplot as plt

# Generate figure
fig = plt.figure(figsize=(7, 9))

# Log figure to run

To log a series of Matplotlib images, use log() inside a loop:

for epoch in range(params["iterations"]):
    plt_fig = get_histogram()

See example in Neptune ≫

To upload a Searborn figure, access its .figure property:

# Import Seaborn
import seaborn as sns

# Generate chart
seaborn_fig = ...

# Convert Seaborn object to Matplotlib format (matplotlib.Figure)
figure = seaborn_fig.figure

# Log figure to run

To log a series of Seaborn figures, use log() inside a loop:

for epoch in range(params["iterations"]):
    figure = seaborn_fig.figure

See example in Neptune ≫

To upload a PIL image from memory:

image1 ="representation-learning.jpg")
image2 ="RL-agents-1.jpg")

# Log image to run

You can also log a series of PIL images:

for epoch in range(images_nr):
    pil_image ="path_to_image")

See example in Neptune ≫