How to export a Table

After you make revisions to a 3LC Table, you may want to export the Table to a common format such as CSV, COCO, YOLO, etc.

Exporting a Table using the tlc API

To export a 3LC Table, you can use the Table.export method from the tlc package.

import tlc

table = tlc.Table.from_url("path/to/3LC/Table")
table.export("path/to/output/folder/my_dataset.csv")

The example above will export a 3LC Table to a CSV file named my_dataset.csv in the output location you specified.

If you want to export a 3LC Table containing bounding boxes to the COCO format, you just need to use “json” as the file’s extension such as my_dataset.json.

Exporting a Table using the 3lc export command

You can also export a Table by using the 3LC CLI. In a terminal (with the 3lc Python Package installed), the command line tool can be invoked as follows:

$ 3lc export path/to/3LC/Table path/to/output/folder/my_dataset.csv

Exporting a Table to YOLO using the tlc_tools package

To export a 3LC Table or a set of Tables (such as train and val Tables) containing bounding boxes to the YOLO format, you will need another designated method in the tlc_tools package, because it will write out a number of files for images, labels, and the YAML file instead of a single file. The tlc_tools Python package provides a set of ready-to-use methods and functionalities at your disposal. You can follow the instructions in our public GitHub repository to install it.

import tlc
from tlc_tools.yolo_export import export_to_yolo

train_table = tlc.Table.from_url("path/to/train/Table")
val_table = tlc.Table.from_url("path/to/val/Table")

export_to_yolo(
    tables={"train": train_table, "val": val_table}, 
    output_url="path/to/output/folder", 
    dataset_name="my_dataset", 
    image_strategy="copy"
    )

In the export_to_yolo method, you can specify both the train and val Tables at once or just one single Table. The value of the dataset_name will be the YAML file’s name. There are several options for the argument image_strategy. The default is copy, which will copy all the images into the output folder. If you don’t want to copy the images, you can specify it as ignore.