### Query Documentation Example Source: https://docs.graviti.com/dev-doc/tools/api-center/examples/data-mining To get additional information not directly present on the page, perform an HTTP GET request with the 'ask' query parameter to dynamically query the documentation. ```http GET https://docs.graviti.com/dev-doc/tools/api-center/examples/data-mining.md?ask= ``` -------------------------------- ### Crontab Schedule Examples Source: https://docs.graviti.com/guide/tensorbay/action/schedule-crontab See practical examples of crontab syntax for common scheduling needs. These examples demonstrate how to specify dates, times, and recurring intervals for automated tasks. ```bash # Examples: 0 0 1 * * # the firth day of a month 10 6 * * 1-5 # every Monday to Friday at 6:10 a.m. ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/action/schedule-crontab To get more information not present on the page, make an HTTP GET request to the current URL with the 'ask' query parameter. This allows for dynamic querying of documentation. ```http GET https://docs.graviti.com/guide/tensorbay/action/schedule-crontab.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/collaboration/log Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific and self-contained. ```http GET https://docs.graviti.com/guide/tensorbay/collaboration/log.md?ask= ``` -------------------------------- ### Init.py Example for Metrics Package Source: https://docs.graviti.com/apps/sextant/metrics This __init__.py file makes the Evaluator class available as a Python package. ```python from .Evaluator import Evaluator all = ["Evaluator"] ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/quickstart-team Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query the documentation. Use this when the answer is not explicitly present, requires clarification, or needs related documentation. ```http GET https://docs.graviti.com/guide/tensorbay/quickstart-team.md?ask= ``` -------------------------------- ### Example Directory Structure for Custom Metrics Source: https://docs.graviti.com/apps/sextant/metrics This illustrates the required file structure for a custom metrics algorithm repository. ```python (yourgithubrepo_root) -- __init.py -- Evaluator.py -- requirements.txt ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/dev-doc/tools To get information not directly present on a page, make an HTTP GET request to the page URL with an 'ask' query parameter containing your question. The response includes the answer and relevant excerpts. ```http GET https://docs.graviti.com/dev-doc/tools.md?ask= ``` -------------------------------- ### Requirements.txt Example for Dependencies Source: https://docs.graviti.com/apps/sextant/metrics Specify additional Python package dependencies for your custom metrics algorithm here. ```python numpy=1.21.0 ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/visualization To get additional information not directly present on a page, perform an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and in natural language. Use this for clarifications or to retrieve related documentation. ```HTTP GET https://docs.graviti.com/guide/tensorbay/visualization.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/action Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific, self-contained, and written in natural language. ```http GET https://docs.graviti.com/guide/tensorbay/action.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/tensorbay/data Perform an HTTP GET request on the current page URL with the `ask` query parameter to get answers to specific questions. The question should be self-contained and in natural language. Use this for clarification or to retrieve related documentation. ```http GET https://docs.graviti.com/guide/tensorbay/data.md?ask= ``` -------------------------------- ### HTTP GET Request for Dynamic Documentation Query Source: https://docs.graviti.com/apps/sextant/start-to-evaluate To get additional information not directly present on the page, perform an HTTP GET request to the current page URL with the `ask` query parameter. The question should be specific and in natural language. ```http GET https://docs.graviti.com/apps/sextant/start-to-evaluate.md?ask= ``` -------------------------------- ### Dataset Label Catalog Output Example Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Example of a successful HTTP 200 response when retrieving a dataset's label catalog. The output details the structure of available labels and their categories. ```json # Response status HttpStatus 200 # Response result { "catalog": { "BOX2D": { "attributes": [ { "name": "color" } ], "categories": [ { "description": "hello", "name": "car" } ] } } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/opendataset/issue Perform an HTTP GET request to query the documentation dynamically. Use the `ask` query parameter with a specific, self-contained question in natural language to get direct answers and relevant excerpts. ```http GET https://docs.graviti.com/guide/opendataset/issue.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/opendataset/fork To get additional information not directly available on the page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and self-contained. ```HTTP GET https://docs.graviti.com/guide/opendataset/fork.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/guide/tensorbay/collaboration/manage Perform an HTTP GET request on a documentation URL with the `ask` query parameter to ask a question. The question should be specific and in natural language. Use this when the answer is not explicitly present, for clarification, or to retrieve related sections. ```http GET https://docs.graviti.com/guide/tensorbay/collaboration/manage.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.graviti.com/apps/groundtruth-tools/annotate-pictures Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. ```http GET https://docs.graviti.com/apps/groundtruth-tools/annotate-pictures.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/tensorbay/collaboration/dataset-manage To get information not explicitly present on the page, make an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```http GET https://docs.graviti.com/guide/tensorbay/collaboration/dataset-manage.md?ask= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.graviti.com/dev-doc/tools/graviti-open-api/dataset-operation Use this method to ask specific questions about the documentation. Append your question to the URL as the 'ask' parameter. The response will include a direct answer and relevant excerpts. ```http GET https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.graviti.com/dev-doc/tools/graviti-open-api/data-operation Use this GET request to query the documentation index for specific information. Replace '' with your natural language query. ```http GET https://docs.graviti.com/dev-doc/tools/api-center/data-operation.md?ask= ``` -------------------------------- ### API Response Example Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Example of a successful HTTP response (200 OK) for an API operation, typically indicating the request was processed correctly. ```http HttpStatus 200 {} ``` -------------------------------- ### 404 Error Response Example Source: https://docs.graviti.com/dev-doc/tools/api-center Example of a 404 HTTP status response, indicating a resource was not found. It includes the error code and a descriptive message. ```http # Response status HttpStatus 404 # Response result { "code": "ResourceNotExist", "message": "dataset not exist!" } ``` -------------------------------- ### Box2D Example Output Format Source: https://docs.graviti.com/apps/sextant/start-to-evaluate This JSON structure represents an example output for Box2D detection, detailing bounding box coordinates (xmin, ymin, xmax, ymax) and the corresponding category for detected objects. ```json { "BOX2D": [ { "box2d": { "xmin": 1, "ymin": 2, "xmax": 3, "ymax": 4 }, "category": "cat" }, { "box2d": { "xmin": 5, "ymin": 4, "xmax": 6, "ymax": 9}, "category": "dog" } ] } ``` -------------------------------- ### Query Documentation with `ask` Parameter Source: https://docs.graviti.com/guide/tensorbay/data/authorize Perform an HTTP GET request on a documentation URL with the `ask` query parameter to retrieve specific information. The question should be clear and in natural language. ```http GET https://docs.graviti.com/guide/tensorbay/data/authorize.md?ask= ``` -------------------------------- ### List Datasets Source: https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation Use this endpoint to retrieve a list of datasets owned by the user. Supports pagination and filtering by name. Individual users get datasets from personal accounts, while team users get datasets from enterprise accounts. ```bash curl --location --request GET '{service}/v1/datasets?offset=0&limit=10'\ --header 'x-token: {your_accesskey}'\ --header 'Content-Type: application/json' ``` -------------------------------- ### Evaluator.py Example for Custom Metrics Source: https://docs.graviti.com/apps/sextant/metrics This example shows the basic structure of the Evaluator class, including initialization and methods for evaluating data and retrieving results. Ensure your implementation adheres to the specified return types (float or curve). ```python import numpy as np class Evaluator: def __init__(self): """ You can initialize your model here """ ... evaluate_one_data(self, input_source: dict, input_target: dict) -> dict: """ Do the evaluation job :param input_source: Ground truth boxes in one image :param input_target:Target boxes in the same image :return: A dict containing evaluation on one image and each category within it. """ ... def get_result(self) -> dict: """Overall evaluation. Returns: A dict containing overall evaluation on all images and all categories. """ ``` ```python { 'scope':1,//1-data级别;2-dataset级别 'overall': { 'mAP':0.123, // Float类型返回 'pr':{ 'x':[1,0.5], 'y':[1,0.5]//x数据将在前端渲染为横轴数据,y数据将在前端渲染为纵轴数据,x和y均为list,且长度一致。 } }, 'categories': { '{your_category}': { 'mAP': np.mean([1, 2, 3]).tolist(), } } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/opendataset/download Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query the documentation. The question should be specific and in natural language. Use this when the answer is not explicitly present or for clarification. ```http GET https://docs.graviti.com/guide/opendataset/download.md?ask= ``` -------------------------------- ### Query GroundTruth Documentation Source: https://docs.graviti.com/apps/groundtruth-tools Perform an HTTP GET request to query the documentation dynamically. Use this when information is not explicitly present or requires clarification. ```http GET https://docs.graviti.com/apps/groundtruth-tools.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.graviti.com/guide/tensorbay/version/annotation Perform an HTTP GET request to a specific page URL with an 'ask' query parameter to dynamically query the documentation. This is useful when the answer is not explicitly present on the page, requires clarification, or needs related documentation sections. ```http GET https://docs.graviti.com/guide/tensorbay/version/annotation.md?ask= ``` -------------------------------- ### Perform HTTP GET Request to Query Documentation Source: https://docs.graviti.com/guide Use this method to query documentation dynamically when information is not directly available. The question should be specific and self-contained. The response includes the answer and relevant excerpts. ```http GET https://docs.graviti.com/guide.md?ask= ``` -------------------------------- ### Fusion Datasets Output Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Example of the response structure for fusion datasets when acquiring labels, including frame details. ```json # Response status HttpStatus 200 { "segmentName": "" "type": 1, "labels": [ { "frameId": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "order": 1, "frame": [ { "sensorName": "camera_car", "remotePath": "fusion_data_car2.jpg", "timestamp":1609430400, "label": { } }, { "sensorname": "camera_car", "remotePath": "fusion_data_car3.jpg", "timestamp":1609430401, "label": { } } ] } ], "offset": 0, "recordSize": 1, "totalCount": 1 } ``` -------------------------------- ### Get Dataset Note Source: https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation Get the note of a dataset. Supports retrieval by draft number or commit information. ```APIDOC ## GetNote **Get note** Get the note of a dataset **Request path** > **GET** /v1/datasets/{id}/notes **Request parameter** **Path** | Name | Descriptions | Value | | ---- | ------------ | ---------- | | id | Yes | Dataset ID | **Query** | Name | Type | Required | Descriptions | | ----------- | ------ | -------- | --------------------------------------------------------------------------------------------------- | | draftNumber | int | No | Draft number. Only one of draft and commit should exist, but they should not exist at the same time | | commit | string | No | Commit ID, commit tag, or branch name | **Request Instance** ``` curl --location --request GET '{service}/v1/datasets/154e35bae8954f09969ef8c9445efd2c/notes?draftNumber=1' \ --header 'x-token: {your_access_key}' \ --header 'Content-Type: application/json' ``` **Output** ``` # Response status HttpStatus 200 # Response result { "isContinuous": true, "binPointCloudFields": [ "X", "Y", "Z", "Intensity" ] } ``` ``` -------------------------------- ### Get Policy for Data Upload Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Acquire upload credentials for S3. This endpoint is used to get the necessary policy and authentication details before transferring data. ```bash curl --location --request GET '{service}/v1/datasets/154e35bae8954f09969ef8c9445efd2c/policies?expired=60&draftNumber=1' \ --header 'x-token: {your_accesskey}'\ --header 'Content-Type: application/json' ``` -------------------------------- ### Prepare Dataset and Branch for Training Source: https://docs.graviti.com/dev-doc/tools/api-center/examples/model-training Initializes the MNIST dataset, enables caching, and creates a training branch and an update label draft in TensorBay. ```python mnist_dataset = TensorBayDataset("MNIST", gas) mnist_dataset.enable_cache() mnist_dataset_client = gas.get_dataset("MNIST") mnist_dataset_client.create_branch("training") mnist_dataset_client.create_draft("update label") ``` -------------------------------- ### Initialize and Load Model for Label Update Source: https://docs.graviti.com/dev-doc/tools/api-center/examples/model-training Loads a pre-trained model from a local file and prepares the TensorBay dataset and client for updating labels. ```python if __name__ == "__main__": BTACH_SIZE = 64 EPOCHS = 3 ACCESS_KEY = os.environ.get("secret.accesskey") gas = GAS(ACCESS_KEY) to_tensor = transforms.ToTensor() normalization = transforms.Normalize(mean=[0.485], std=[0.229]) my_transforms = transforms.Compose([to_tensor, normalization]) model_dataset = TensorBayDataset("MNIST_MODEL", gas) data = model_dataset[0][0] with open(f"./model.pth", "wb") as fp: # Path where data is stored locally fp.write(data.open().read()) model = NeuralNetwork() model.load_state_dict(torch.load("model.pth", map_location=torch.device("cpu"))) logging.info(model) ``` -------------------------------- ### Get Dataset Source: https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation Retrieves details of a specific dataset by its ID. ```APIDOC ## GetDataset ### Description Request path ### Method GET ### Endpoint /v1/datasets/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Dataset ID ### Request Example ```bash curl --location --request GET '{service}/v1/datasets/154e35bae8954f09969ef8c9445efd2c' \ --header 'x-token: {your_accesskey}' \ --header 'Content-Type: application/json' ``` ### Response #### Success Response (200) - **name** (string) - Dataset name - **type** (int) - Dataset type (0 for normal, 1 for Fusion) - **defaultBranch** (string) - Default branch name - **commitId** (string) - Commit ID - **updateTime** (int) - Update timestamp - **owner** (string) - Owner of the dataset #### Response Example ```json { "name": "my-great-data-set", "type": 1, "defaultBranch": "main", "commitId": "00000000000000000000000000000000", "updateTime": 1604977282, "owner": "" } ``` ``` -------------------------------- ### Normal Dataset Output Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Example of the response structure for a normal dataset when acquiring labels. ```json # Response status HttpStatus 200 { "segmentName": "", "type": 0, "labels": [ { "remotePath": "data_car.jpg", "label": { } } ], "offset": 0, "recordSize": 1, "totalCount": 1 } ``` -------------------------------- ### Create Model Dataset with TensorBay Source: https://docs.graviti.com/dev-doc/tools/api-center/examples/model-training Use this script to create a new dataset for storing model training data. It requires the TensorBay Python client and an access key. The script checks if the dataset already exists to prevent errors. ```python import logging import os from tensorbay import GAS logging.basicConfig(level=logging.INFO) dataset_name = "MNIST_MODEL" ACCESS_KEY = os.environ.get("secret.accesskey") gas = GAS(ACCESS_KEY) try: gas.create_dataset(dataset_name) logging.info(f"Created dataset {dataset_name} Successfully") except: logging.info(f"{dataset_name} aleady exists.") ``` -------------------------------- ### Dataset Segment Response Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation Example of a normal dataset segment response, including segment details, offset, record size, and total count. ```json # Response status HttpStatus 200 { "segments": [ { "name": "car", "description": "this is car" }, { "name": "graviti", "description": "this is a segment" } ], "offset": 0, "recordSize": 2, "totalCount": 10 } ``` -------------------------------- ### Create a Dataset Source: https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation Creates a new TensorBay dataset with version control. The dataset name must be unique. Can optionally configure storage using authenticated storage or regions. ```curl curl --location --request POST '{service}/v1/datasets' \ --header 'x-token: {your_accesskey}' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "my first dataset", "type": 0, "storageConfig": { "name": "aws_1", "path": "graviti" } }' ``` -------------------------------- ### Create Dataset Draft Source: https://docs.graviti.com/dev-doc/tools/api-center/dataset-operation Create a TensorBay dataset draft on a specified branch. Only one draft can exist per branch. The default branch is 'main'. ```curl curl --location --request POST '{service}/v1/datasets/154e35bae8954f09969ef8c9445efd2c/drafts' \ --header 'x-token: {your_accesskey}' \ --header 'Content-Type: application/json' \ --data-raw '{ "title": "my first draft", "branchName": "main" }' ``` -------------------------------- ### Create Draft with Description in Python SDK Source: https://docs.graviti.com/release-note Set a description when creating a new draft using `VersionControlClient.create_draft`. This allows you to provide initial context for the draft. ```python from tensorbay.client import VersionControlClient # Assuming 'vcs' is an instance of VersionControlClient new_description = "Initial description for the new draft." draft = vcs.create_draft(description=new_description) ``` -------------------------------- ### Error Code Return Type Example Source: https://docs.graviti.com/dev-doc/tools/api-center Illustrates the standard JSON structure for API error responses. This format is used when requests generate an error. ```json { "code": "error_code", "message": "***" } ``` -------------------------------- ### UploadSensor Source: https://docs.graviti.com/dev-doc/tools/api-center Create a sensor. ```APIDOC ## UploadSensor ### Description Create a sensor. ### Method POST ### Endpoint /sensors ``` -------------------------------- ### PutCallback API Response Example Source: https://docs.graviti.com/dev-doc/tools/api-center/data-operation A successful PutCallback request returns an empty JSON object with an HTTP 200 status code, indicating the callback was processed. ```json # Response status HttpStatus 200 # Response result {} ``` -------------------------------- ### Create and Train a Neural Network Source: https://docs.graviti.com/dev-doc/tools/api-center/examples/model-training This code defines a neural network, prepares datasets, trains the model using PyTorch, and saves the model state. ```python train_segment = MNISTSegment(mnist_dataset, segment_name="train", transform=my_transforms) test_segment = MNISTSegment(mnist_dataset, segment_name="test", transform=my_transforms) train_dataloader = DataLoader(train_segment, batch_size=BTACH_SIZE, num_workers=10) test_dataloader = DataLoader(test_segment, batch_size=BTACH_SIZE, num_workers=10) device = "cuda" if torch.cuda.is_available() else "cpu" logging.info(f"Using {device} device") model = NeuralNetwork().to(device) logging.info(model) loss_fn = nn.CrossEntropyLoss() optimizer = torch.optim.SGD(model.parameters(), lr=1e-3) for epoch in range(EPOCHS): logging.info(f"Epoch {epoch+1}\n-------------------------------") train(train_dataloader, model, loss_fn, optimizer) test(test_dataloader, model, loss_fn) logging.info("Done!") torch.save(model.state_dict(), "model.pth") logging.info("Saved PyTorch Model State to model.pth") ```