Previous
Create a dataset
Label your dataset images with tags for classification or bounding boxes for object detection. You need a dataset with images before you can annotate.
Tags are labels that apply to an entire image. Use them when you are building a classification model – for example, labeling images as “good-part” or “defective-part”.
Web UI:
good-part) and press Enter.To tag multiple images at once, use the SDK to add tags programmatically (see the code example below).
async def main():
viam_client = await connect()
data_client = viam_client.data_client
binary_data_ids = ["binary-data-id-1", "binary-data-id-2"]
await data_client.add_tags_to_binary_data_by_ids(
tags=["good-part"],
binary_ids=binary_data_ids,
)
print("Tags added.")
viam_client.close()
binaryIDs := []string{"binary-data-id-1", "binary-data-id-2"}
err = dataClient.AddTagsToBinaryDataByIDs(
ctx,
[]string{"good-part"},
binaryIDs,
)
if err != nil {
logger.Fatal(err)
}
fmt.Println("Tags added.")
You can get binary data IDs by querying for images using the data client’s
binary_data_by_filter method, which returns objects that include the binary
data ID.
Choose tag names that are clear, consistent, and descriptive. Use lowercase with
hyphens (for example, good-part, defective-part, no-part). Avoid vague names like
type1 or other.
Bounding boxes mark the location of specific objects within an image. Use them when you are building an object detection model – for example, detecting packages on a conveyor belt.
Web UI:
package).Draw tight bounding boxes that closely fit the object. Do not include excessive background. If an image contains multiple objects, draw a separate bounding box for each one.
async def main():
viam_client = await connect()
data_client = viam_client.data_client
bbox_id = await data_client.add_bounding_box_to_image_by_id(
binary_id="binary-data-id-1",
label="package",
x_min_normalized=0.15,
y_min_normalized=0.20,
x_max_normalized=0.85,
y_max_normalized=0.90,
)
print(f"Added bounding box: {bbox_id}")
viam_client.close()
bboxID, err := dataClient.AddBoundingBoxToImageByID(
ctx,
"binary-data-id-1",
"package",
0.15, // x_min_normalized
0.20, // y_min_normalized
0.85, // x_max_normalized
0.90, // y_max_normalized
)
if err != nil {
logger.Fatal(err)
}
fmt.Printf("Added bounding box: %s\n", bboxID)
Coordinates are normalized 0.0-1.0, where (0.0, 0.0) is the top-left corner and (1.0, 1.0) is the bottom-right corner.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!