Skip to main content

Graviti TensorBay Python SDK

Project description

TensorBay Python SDK

Pre-commit Unit Test Documentation Status Downloads Coverage Status GitHub Slack PyPI PyPI - Python Version


IMPORTANT: TensorBay system underwent a huge refactoring, which broke the downward compatibility of OpenAPI and SDK. As a result, the SDK under version v1.6.0 does not work anymore.
Please update tensorbay SDK to v1.6.0 or a higher version.


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.

Installation

pip3 install tensorbay

Documentation

More information can be found on the documentation site

Usage

An AccessKey is needed to communicate with TensorBay. Please visit this page to get an AccessKey first.

Authorize a client object

from tensorbay import GAS
gas = GAS("<YOUR_ACCESSKEY>")

Create a Dataset

gas.create_dataset("DatasetName")

List Dataset names

dataset_names = gas.list_dataset_names()

Upload images to the Dataset

from tensorbay.dataset import Data, 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("SegmentName")

segment.append(Data("0000001.jpg"))
segment.append(Data("0000002.jpg"))

dataset_client = gas.upload_dataset(dataset, jobs=8)

# TensorBay provides dataset version control feature, commit the uploaded data before using it.
dataset_client.commit("Initial commit")

Read images from the Dataset

from PIL import Image

dataset = Dataset("DatasetName", gas)
segment = dataset[0]

for data in segment:
    with data.open() as fp:
        image = Image.open(fp)
        width, height = image.size
        image.show()

Delete the Dataset

gas.delete_dataset("DatasetName")

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorbay-1.15.0rc1.tar.gz (232.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensorbay-1.15.0rc1-py3-none-any.whl (341.2 kB view details)

Uploaded Python 3

File details

Details for the file tensorbay-1.15.0rc1.tar.gz.

File metadata

  • Download URL: tensorbay-1.15.0rc1.tar.gz
  • Upload date:
  • Size: 232.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.14.0 CPython/3.8.2

File hashes

Hashes for tensorbay-1.15.0rc1.tar.gz
Algorithm Hash digest
SHA256 6dc9aa00f5b911b95ea03013ebd299b9a2728d5f7d6965bd126511c2282c5268
MD5 2bd45147b5d2f32e77443d9b94d8de57
BLAKE2b-256 3b0ae52278f51f7587c393a1fd25a54b3e84892dac25a00a8edecd2055055457

See more details on using hashes here.

File details

Details for the file tensorbay-1.15.0rc1-py3-none-any.whl.

File metadata

  • Download URL: tensorbay-1.15.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 341.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.14.0 CPython/3.8.2

File hashes

Hashes for tensorbay-1.15.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 5726de053554cc331c271bebf46e72cf94fcff322bc737ba58da50e7f0b0e6fe
MD5 2e2a28a5fbd815b6f350b0fb5d8179c5
BLAKE2b-256 e91559684f0f7354f1cb92a1fc928053359222b1d7bc3bfa0bae0ee03e0ca611

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page