TensorBay Python SDK is a python library to access TensorBay
and manage your datasets.
It provides:
- A pythonic way to access your TensorBay resources by TensorBay OpenAPI.
- An easy-to-use CLI tool
gas(Graviti AI service) to communicate with TensorBay. - A consistent dataset format to read and write your datasets.
pip3 install tensorbayMore information can be found on the documentation site
An AccessKey is needed to communicate with TensorBay. Please visit this page to get an AccessKey first.
fromtensorbayimportGASgas=GAS("<YOUR_ACCESSKEY>")gas.create_dataset("DatasetName")dataset_names=gas.list_dataset_names()fromtensorbay.datasetimportData, Dataset# Organize the local dataset by the "Dataset" class before uploading.dataset=Dataset("DatasetName")
# TensorBay uses "segment" to separate different parts in a dataset.segment=dataset.create_segment()
segment.append(Data("0000001.jpg"))
segment.append(Data("0000002.jpg"))
dataset_client=gas.upload_dataset(dataset)
# TensorBay provides dataset version control feature, commit the uploaded data before using it.dataset_client.commit("Initial commit")fromPILimportImagefromtensorbay.datasetimportSegmentdataset_client=gas.get_dataset("DatasetName")
segment=Segment("", dataset_client)
fordatainsegment:
withdata.open() asfp:
image=Image.open(fp)
width, height=image.sizeimage.show()gas.delete_dataset("DatasetName")