def test_dumps(self): contents = { "CLASSIFICATION": {"category": "cat", "attributes": {"gender": "male"}}, "BOX2D": [ { "box2d": {"xmin": 1, "ymin": 1, "xmax": 2, "ymax": 2}, "category": "dog", "attributes": {"gender": "female"}, } ], } label = Label() label.classification = Classification.loads(contents["CLASSIFICATION"]) label.box2d = [LabeledBox2D.loads(contents["BOX2D"][0])] assert label.dumps() == contents
from tensorbay.dataset import Dataset from tensorbay.label import Classification # Use AuthData to organize a dataset by the "Dataset" class before importing. dataset = Dataset("<DATASET_NAME>") # TensorBay uses "segment" to separate different parts in a dataset. segment = dataset.create_segment() images = cloud_client.list_auth_data("<data/images/>") labels = cloud_client.list_auth_data("<data/labels/>") for auth_data, label in zip(images, labels): with label.open() as fp: auth_data.label.classification = Classification.loads(json.load(fp)) segment.append(auth_data) dataset_client = gas.upload_dataset(dataset, jobs=8) """""" """Create local storage config""" gas.create_local_storage_config( name="<LOCAL_STORAGE_CONFIG>", file_path="<path/to/dataset>", endpoint="<external IP address of the local storage service>", ) """""" """Create authorized local storage dataset""" dataset_client = gas.create_dataset("<DATASET_NAME>", config_name="<LOCAL_STORAGE_CONFIG>") """"""
def test_loads(self): contents = {"category": "cat", "attributes": {"gender": "male"}} classification = Classification.loads(contents) assert classification.category == "cat" assert classification.attributes == {"gender": "male"}