Write
Creating a TACO dataset
Declare the shared contract, describe the collection, add samples, and produce a validated folder or immutable ZIP.
01Contract
Declare the sample structure
The contract fixes the paths shared by every sample.
import taco
contract = taco.Contract(
structure=["image.tif", "label.tif"]
)02Collection
Describe the dataset
collection = taco.Collection(
contract=contract,
id="land-cover",
dataset_version="1.0.0",
description="Images and land-cover labels",
licenses=["MIT"], providers=["Asterisk Labs"],
tasks=["semantic-segmentation"],
)03Sample
Attach the assets
sample = taco.Sample(assets=[
taco.Asset("image.tif", path="image.tif"),
taco.Asset("label.tif", path="label.tif"),
])04Writer
Write and validate
with taco.open_writer(collection, "land-cover.zip") as writer:
writer.add(sample)
writer.run()
assert taco.validate("land-cover.zip").ok05Export
Write a subset
Pass sample rows returned by Dataset.sql(); the subset keeps the contract and inherits collection fields unless you replace them.
dataset = taco.open_dataset("land-cover.zip")
rows = dataset.sql("SELECT * FROM data WHERE sample_id < 100")
taco.export(
"land-cover.zip",
"land-cover-sample.zip",
samples=rows,
id="land-cover-sample",
description="First 100 land-cover samples",
)