Detection - DINO-X

Usage Pattern

First of all, make sure you have installed this SDK by pip:

pip install dds-cloudapi-sdk

Then trigger the algorithm through DetectionTask:

from dds_cloudapi_sdk import Config
from dds_cloudapi_sdk import Client
from dds_cloudapi_sdk import TextPrompt
from dds_cloudapi_sdk.task.dinox import DinoxTask

# Step 1: initialize the config
token = "Your API token here"
config = Config(token)

# Step 2: initialize the client
client = Client(config)

# Step 3: run the task by DetectionTask class
image_url = "https://algosplt.oss-cn-shenzhen.aliyuncs.com/test_files/tasks/dinox/08.jpg"
# if you are processing local image file, upload them to DDS server to get the image url
# image_url = client.upload_file("/path/to/your/prompt/image.png")

task = DinoxTask(
    image_url=image_url,
    prompts=[TextPrompt(text="<prompt_free>")] # or specific prompts like 'vessel.cutting.person'
)

client.run_task(task)
result = task.result


objects = result.objects  # the list of detected objects
for idx, obj in enumerate(objects):

    print(obj.category)  # "person"

    print(obj.bbox)  # [132.2875213623047, 4.497652053833008, 444.68719482421875, 530.9923706054688]

    print(obj.mask.counts)  # RLE compressed to string, ]o`gg0=[95K3M4L4M3L4M2N3L3N2N3M2N3M2N2N2N2N2M3N3M2N3L3N2N3M2N2N2N2O1N2N2N2O0O2N...

    print(obj.pose) # [307.07562255859375, 140.30242919921875, 1, 0, 318.3280029296875, 124.33451080322266, 1,0 ...]

    print(obj.hand) # null

    break

API Reference

class DinoxTask(image_url, prompts, bbox_threshold=0.25, iou_threshold=0.8, targets=None)[source]
Parameters:
  • image_url (str)

  • prompts (List[TextPrompt])

  • bbox_threshold (float)

  • iou_threshold (float)

  • targets (List[DetectionTarget])

class TextPrompt(*, text, is_positive=True)[source]

A text prompt.

Parameters:
  • text (str) – the str content of the prompt

  • is_positive (bool) – whether the prompt is positive, default to True

text: str

the str content of the prompt

is_positive: bool

whether the prompt is positive, default to True

property type

constant string ‘text’ for TextPrompt.

class TaskResult(*, objects)[source]

The task result of Dinox task.

Parameters:

objects (List[DinoxObject])

objects: List[DinoxObject]

a list of detected objects of DinoxObject