Export Filenames

Lightly supports many different export formats, so you can easily export selected images to your favorite labeling tool. Check out the chapter Export to see all supported formats. Here, we will show how you can download the filenames and full images to your machine again.

Exporting Filenames to a Text File

After a run successfully terminates, the Lightly Worker will have created a tag with the name initial-tag in your dataset. You can export and download the filenames for further processing with the following Python code:

from lightly.api import ApiWorkflowClient

# Create the Lightly client to connect to the API.
client = ApiWorkflowClient(token="MY_LIGHTLY_TOKEN", dataset_id="MY_DATASET_ID")

filenames = client.export_filenames_by_tag_name(
    tag_name="initial-tag"  # name of the tag in the dataset
)
with open("filenames-of-initial-tag.txt", "w") as f:
    f.write(filenames)

Downloading the Full Images

It is also possible to directly download the actual files themselves and store them on disk.

from lightly.api import ApiWorkflowClient

# Create the Lightly client to connect to the API.
client = ApiWorkflowClient(token="MY_LIGHTLY_TOKEN", dataset_id="MY_DATASET_ID")
client.download_dataset(
    output_dir="./my/output/path/",  # path to where the files should be saved
    tag_name="initial-tag",  # name of the tag in the dataset
)

What’s Next