docs/src/integrations/tensorflow.md
The TensorFlow integration is maintained in the lance-format/lance-tensorflow project.
The main Lance Python package no longer includes lance.tf. Install
lance-tensorflow and import lance_tensorflow instead.
pip install lance-tensorflow
Use lance_tensorflow.from_lance to create a tf.data.Dataset from a Lance
dataset.
from lance_tensorflow import from_lance
ds = from_lance(
"s3://my-bucket/my-dataset",
columns=["image", "label"],
filter="split = 'train'",
batch_size=256,
)
for batch in ds:
print(batch["label"])
If you want tf.data.Dataset.from_lance, register the convenience methods
explicitly after importing lance_tensorflow.
import tensorflow as tf
import lance_tensorflow
lance_tensorflow.register_tensorflow_dataset()
ds = tf.data.Dataset.from_lance("s3://my-bucket/my-dataset")
Replace old imports:
import lance.tf.data
ds = lance.tf.data.from_lance(uri)
with:
from lance_tensorflow import from_lance
ds = from_lance(uri)
See the lance-tensorflow README for the current installation and compatibility details.