Export¶

While Tables are designed to be used directly in model training, one might want to export the modified data into a common format such as CSV or COCO, or to a custom format. This can be achieved by using the built-in exporters in the CLI and Python API, or by custom iteration.

Built-in exporters¶

Built-in exporters can be used through the Python API or CLI, and currently CSV, COCO, YOLO and JSON are supported output formats.

Table.export()¶

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

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 the table rows to a CSV file named my_dataset.csv in the specified output location.

If you want to export a 3LC Table containing bounding boxes to the COCO format, use ā€œjsonā€ as the file’s extension such as "my_dataset.json".

Using the 3LC CLI¶

In a terminal (with the tlc Python Package installed), the command line tool can be invoked as follows:

3lc export path/to/table.json <output-path>

The output format will be deduced from the extension of <output-path> and the contents of the table, but can also be explicitly specified using the --format option. For more details, use

3lc export --help

In-memory export¶

To export the data in a tlc.Table to a Pandas DataFrame, use

df_from_table = table.to_pandas()

This will return the rows of the Table in a Pandas dataframe.

Custom format¶

To export to a custom format, iterate over the tlc.Table directly and write the data to your desired format. Here we assume you have a function my_export_fn that performs the necessary steps to serialize and write the data.

table = Table.from_url(input_url)

my_table_dict = {"col1": [], "col2": []}
for sample in table:
    my_table_dict["col1"] = sample[0]
    my_table_dict["col2"] = sample[1]

my_export_fn(my_table_dict)