Coder Social home page Coder Social logo

tensorbay-python-sdk's Introduction

TensorBay Python SDK

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

# Method "list_dataset_names()" returns an iterator, use "list()" to transfer it to a "list".
dataset_list = list(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()

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")

Read images from the Dataset

from PIL import Image
from tensorbay.dataset import Segment

dataset_client = gas.get_dataset("DatasetName")

segment = Segment("", dataset_client)

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")

tensorbay-python-sdk's People

Contributors

yiweili4 avatar linjix avatar rexzheng324-c avatar luyao77 avatar lee-000 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.