Skip to content

Logging Media

Simpcat supports logging audio and image media alongside scalar metrics. Media is uploaded to object storage and displayed in the web UI’s media panel.

Wrap audio data in simpcat.Audio and pass it to log():

import numpy as np
import simpcat
run = simpcat.init(project="tts")
# From a numpy array (float32, -1 to 1)
audio = np.random.randn(22050).astype(np.float32) # 1 second at 22050 Hz
simpcat.log({"sample": simpcat.Audio(audio, sample_rate=22050, caption="generated")})
# From a file path
simpcat.log({"reference": simpcat.Audio("/path/to/audio.wav", caption="ground truth")})
  • data_or_pathnp.ndarray (float32 waveform) or str (path to WAV file)
  • caption — Optional caption displayed in the UI (default: "")
  • sample_rate — Sample rate in Hz (default: 22050)

Wrap image data in simpcat.Image:

import numpy as np
import simpcat
run = simpcat.init(project="vision")
# From a numpy array (HWC uint8 or float 0-1)
img = np.random.randint(0, 255, (256, 256, 3), dtype=np.uint8)
simpcat.log({"prediction": simpcat.Image(img, caption="epoch 5")})
# From a PIL Image
from PIL import Image as PILImage
pil_img = PILImage.open("result.png")
simpcat.log({"output": simpcat.Image(pil_img)})
# From a file path
simpcat.log({"input": simpcat.Image("/path/to/image.png")})
  • data_or_pathnp.ndarray, PIL Image, or str (path to image file)
  • caption — Optional caption displayed in the UI

Pass a list of media objects under the same key:

samples = [simpcat.Audio(wav, sample_rate=22050) for wav in batch_outputs]
simpcat.log({"samples": samples})

Each item is uploaded separately and displayed as a gallery in the media panel.