Skip to main content

The SDK for calling deepdataspace cloud API.

Project description

dds-cloudapi-sdk


The Python SDK for the DDS Cloud API.

License PyPI python PyPI version PyPI - Downloads


The dds-cloudapi-sdk is a Python package designed to simplify interactions with the DDS Cloud API. It features:

  • Straightforward APIs
  • Unified interfaces
  • Handy utilities

Installation

You can get the SDK library directly from PyPi:

pip install dds-cloudapi-sdk

Quick Start

Below is a straightforward example for the popular IVP algorithm:

# 1. Initialize the client with your API token.
from dds_cloudapi_sdk import Config
from dds_cloudapi_sdk import Client

token = "Your API Token Here"
config = Config(token)
client = Client(config)

# 2. Upload local image to the server and get the URL.
infer_image_url = "https://dev.deepdataspace.com/static/04_a.ae28c1d6.jpg"
# infer_image_url = client.upload_file("path/to/infer/image.jpg")  # you can also upload local file for processing
prompt_image_url = infer_image_url  # use the same image for prompt

# 3. Create a task with proper parameters.
from dds_cloudapi_sdk.tasks import IVPTask
from dds_cloudapi_sdk.tasks import RectPrompt
from dds_cloudapi_sdk.tasks import LabelTypes

task = IVPTask(
    prompt_image_url=prompt_image_url,
    prompts=[RectPrompt(rect=[475.18, 550.20, 548.10, 599.92], is_positive=True)],
    infer_image_url=infer_image_url,
    infer_label_types=[LabelTypes.BBox, LabelTypes.Mask],  # infer both bbox and mask
)
# task.set_request_timeout(10)  # set the request timeout in seconds,default is 5 seconds

# 4. Run the task and get the result.
client.run_task(task)

# 5. Parse the result.
from dds_cloudapi_sdk.tasks.ivp import TaskResult

result: TaskResult = task.result

mask_url = result.mask_url  # the image url with all masks drawn on
objects = result.objects  # the list of detected objects
for idx, obj in enumerate(objects):
    # get the detection score
    print(obj.score)  # 0.42

    # get the detection bbox
    print(obj.bbox)  # [635.0, 458.0, 704.0, 508.0]

    # get the detection mask, it's of RLE format
    print(obj.mask.counts)  # ]o`f08fa14M3L2O2M2O1O1O1O1N2O1N2O1N2N3M2O3L3M3N2M2N3N1N2O...

    # convert the RLE format to RGBA image
    mask_image = task.rle2rgba(obj.mask)
    print(mask_image.size)  # (1600, 1170)

    # save the image to file
    mask_image.save(f"data/mask_{idx}.png")

For more details on using the SDK, please refer to the DDS CloudAPI SDK Reference

3. Apply for an API Token

Our API is in private beta. Contact us at deepdataspace_dm@idea.edu.cn to apply for a free API token.
Please include a brief introduction to your research or project and how you plan to use the API in your application.
We're dedicated to supporting academic research and education and welcome any questions or suggestions.

4. License

This project is released under the Apache 2.0 License.

Copyright 2023-present, IDEA

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Project details


Download files

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

Source Distribution

dds-cloudapi-sdk-0.2.3.tar.gz (18.9 kB view details)

Uploaded Source

File details

Details for the file dds-cloudapi-sdk-0.2.3.tar.gz.

File metadata

  • Download URL: dds-cloudapi-sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for dds-cloudapi-sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1704d29b554de073f5f5108ede43e7ca05cce7a1f5fcf3b9f8c45cddc8ceb24d
MD5 8b3d8145735cfec27731d3114d1429f1
BLAKE2b-256 8fd5defc4d94fc57709f5c02108daefcf5ead6f6680f67433a5a41ab602f4258

See more details on using hashes here.

Supported by

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