Logging Media

LitLogger supports uploading images, text files, and videos that are displayed alongside your metrics in the experiment view. For new code, prefer the dict-style wrappers Image, Text, and Video.

Using the Experiment API

import litlogger
from litlogger import Image, Text, Video

experiment = litlogger.init(name="media-demo")

experiment["preview"] = Image("generated.png")
experiment["notes"] = Text("epoch 0 summary")
experiment["video_preview"] = Video("preview.mp4")

experiment["samples"].append(Image("sample-0.png"), step=0)
experiment["captions"].append(Text("reconstruction"), step=0)
experiment["clips"].append(Video("sample-0.mp4"), step=0)

Legacy Helper API

The legacy helper method log_media remains available for existing code, but new standalone code should prefer the dict-style wrappers.

Logging Images

import litlogger
from litlogger.types import MediaType

exp = litlogger.init(name="my-experiment")

exp.log_media("sample_output", "generated.png", step=0)

exp.log_media(
    name="reconstruction",
    path="recon.jpg",
    kind=MediaType.IMAGE,
    step=10,
    caption="Epoch 10 reconstruction",
)

Logging Text

exp.log_media("predictions", "predictions.txt", kind=MediaType.TEXT, step=5)

Logging Video

exp.log_media("rollout", "preview.mp4", kind=MediaType.VIDEO, step=5)

Supported Types

MediaType File extensions Description
IMAGE .png, .jpg, .jpeg, .gif, .bmp, .webp Displayed as images in the experiment view
TEXT .txt, .csv, .json, .log Displayed as text in the experiment view
VIDEO .mp4, .mov, .avi, .webm Displayed as videos in the experiment view

When kind is not provided, LitLogger guesses the type from the file's MIME type. If the type cannot be determined, a ValueError is raised.

Deprecated Compatibility Logger

LightningLogger is deprecated. For Lightning or Fabric integrations, prefer lightning:lightning.pytorch.loggers.LitLogger for metrics, files, and model artifacts. For media uploads, use the standalone Experiment API directly; the upstream lightning:lightning.pytorch.loggers.LitLogger does not expose a log_media helper.

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close