Skip to content

Log video

Comet's videos offer you the flexibility to log and visualize videos from a variety of formats, including .mp4, .mov, .wmv, .gif, and file-like object.

Example of Video panel
Example of logged video displayed in the Comet UI

Comet allows you to access, download, and visualize logged videos for a single experiment, and also compare multiple videos across many experiments.

The following method can be used to log videos:

The following panel can be used to visualize videos:

In addition all the videos logged to an Experiment can be view in the Single Experiment page tabs:

For example, you could...

Review any video samples that are incorrectly predicted by the model to identify possible issues with low resolution, motion blur, or occlusions.

Log a video

The examples below showcase how to log an example video of a waterfall from file and file-like object.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import comet_ml
import requests

# Initialize the Comet Experiment
comet_ml.init()
exp = comet_ml.Experiment()

# Define an example video
video_url = "https://cdn.pixabay.com/video/2020/04/24/37088-413229662_large.mp4"
response = requests.get(video_url)
filepath = "/tmp/example.mp4"
with open(filepath, 'wb+') as f:
    f.write(response.content)

# Log video
exp.log_video(file=filepath, name="Example video from filepath", format="mp4")

By specifying the format argument, you ask Comet to validate the provided file for the given format.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import io
import comet_ml
import requests

# Initialize the Comet Experiment
comet_ml.init()
exp = comet_ml.Experiment()

# Define an example video
video_url = "https://cdn.pixabay.com/video/2020/04/24/37088-413229662_large.mp4"
response = requests.get(video_url)
filepath = "/tmp/example.mp4"
video_object = io.BytesIO(response.content)

# Log video
exp.log_video(file=video_object, name="Example video from object", format="mp4")

Using a file-like object allows you to avoid saving the model to disk.

By specifying the format argument, you indicate to Comet which format to use to create the video.

You can optionally specify a step or epoch argument to define in which point of the model training the video has been logged.

Additionally, you could use the overwrite argument to overwrite any existing model with the same name or add a metadata argument to log extra information (such as tags) in a JSON format.

Apr. 29, 2024