comet-ml / issue-tracking

Questions, Help, and Issues for Comet ML
https://www.comet.ml
85 stars 7 forks source link

How to fetch an image logged to an experiment on Comet ML? #518

Closed kirilllzaitsev closed 11 months ago

kirilllzaitsev commented 1 year ago

Before Asking:

What is your question related to?

What is your question?

I want to fetch an image once logged to an experiment on Comet ML for displaying it with matplotlib. How can I do that?

Code

Please paste a code snippet if your question requires it!   

What have you tried?

dsblank commented 11 months ago

You can fetch all of the assets in the Comet Python SDK with a two-step process:

First, get the asset list:

https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/APIExperiment/#apiexperimentget_asset_list

>>> from comet_ml.api import API
>>> api = API()
>>> x = api.get("myworkspace/project1/experiment_key")
>>> assets = x.get_asset_list()

Then you can get the asset by its asset ID:

https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/APIExperiment/#apiexperimentget_asset

>>> api_experiment.get_asset("298378237283728", return_type="binary")

Does that help? You can do this in a Python program, or in a Comet Python Panel.

kirilllzaitsev commented 11 months ago

Yes, thank you, it works.