Skip to content

Commit 4b8ad23

Browse files
committed
New Answer-Modes section
1 parent 09446a1 commit 4b8ad23

15 files changed

+86
-80
lines changed

docs/docs/answer-modes/1-binary-detectors.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# [BETA] Multi-Class Detectors
2+
3+
If you want to classify images into multiple categories, you can create a multi-class detector.
4+
5+
```python
6+
from groundlight import ExperimentalApi
7+
gl_exp = ExperimentalApi()
8+
9+
# highlight-start
10+
class_names = ["Golden Retriever", "Labrador Retriever", "German Shepherd", "Other"]
11+
detector = gl_exp.create_multiclass_detector(
12+
name="dog-breed-detector",
13+
query="What kind of dog is this?",
14+
class_names=class_names,
15+
)
16+
# highlight-end
17+
```
18+
19+
:::tip
20+
We recommend adding an "Other" class to your multi-class detector to handle cases where the image does not belong to any of the pre-defined classes.
21+
:::
22+
23+
<!-- :::note
24+
Multi-Class Detectors are available on [Business and Enterprise plans](https://www.groundlight.ai/pricing).
25+
::: -->
26+
27+
## Submit an Image Query to a Multi-Class Detector
28+
29+
Now that you have created a multi-class detector, you can submit an image query to it.
30+
31+
```python notest
32+
from groundlight import ExperimentalApi
33+
gl_exp = ExperimentalApi()
34+
35+
detector = gl_exp.get_detector_by_name("dog-breed-detector")
36+
37+
# highlight-start
38+
# Classify the breed of a dog in an image
39+
image_query = gl_exp.submit_image_query(detector, "path/to/image.jpg")
40+
# highlight-end
41+
42+
print(f"Result: {image_query.result.label}")
43+
print(f"Confidence: {image_query.result.confidence}")
44+
```
45+
46+
Multi-class detectors return a `label` attribute in the result object, which contains the predicted class label. The `label` attribute will be one of the class names provided when creating the detector. The `confidence` attribute represents the confidence level in the predicted class, which is a value between `1/len(class_names)` and 1.
47+
48+
## Add a label to a Multi-Class Detector
49+
50+
To provide ground truth labels for multi-class detectors, you can specify the label of the correct class.
51+
52+
```python notest
53+
from groundlight import ExperimentalApi
54+
gl_exp = ExperimentalApi()
55+
56+
# highlight-start
57+
# Add a multi-class label to the image query from the previous example
58+
gl_exp.add_label(image_query, label="German Shepherd")
59+
# highlight-end
60+
```

docs/docs/guide/5-detector-modes.md docs/docs/answer-modes/3-counting-detectors.md

+4-70
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# Detector Answer Modes
2-
Groundlight offers several detector modalities to suit different computer vision tasks. While previous examples have focused on binary classification, this guide will walk you through using counting and multi-class detectors. Let's explore how these different modes can be used via the Groundlight SDK.
3-
4-
## Counting Detectors
1+
# Counting Detectors
52

63
Counting detectors are used to count the number of objects in an image. Groundlight's counting detectors also return bounding boxes around the objects they count.
74

@@ -30,7 +27,7 @@ The `confidence_threshold` parameter sets the minimum confidence level required
3027
Counting Detectors are available on [Business and Enterprise plans](https://www.groundlight.ai/pricing).
3128
:::
3229

33-
### Submit an Image Query to a Counting Detector
30+
## Submit an Image Query to a Counting Detector
3431

3532
Now that you have created a counting detector, you can submit an image query to it.
3633

@@ -95,7 +92,7 @@ def draw_bounding_boxes(image_path, rois):
9592
```
9693
:::
9794

98-
### Add a label to a Counting Detector
95+
## Add a label to a Counting Detector
9996

10097
The Groundlight API allows you to add labels to image queries, including Region of Interest (ROI) data.
10198
When adding a label to a counting detector, if you include ROIs, the number of ROIs should match
@@ -115,67 +112,4 @@ roi3 = gl_exp.create_roi("car", (0.6, 0.5), (0.8, 0.9))
115112
rois = [roi1, roi2, roi3]
116113
gl_exp.add_label(image_query, label=len(rois), rois=rois)
117114
# highlight-end
118-
```
119-
120-
## [BETA] Multi-Class Detectors
121-
122-
If you want to classify images into multiple categories, you can create a multi-class detector.
123-
124-
```python
125-
from groundlight import ExperimentalApi
126-
gl_exp = ExperimentalApi()
127-
128-
# highlight-start
129-
class_names = ["Golden Retriever", "Labrador Retriever", "German Shepherd", "Other"]
130-
detector = gl_exp.create_multiclass_detector(
131-
name="dog-breed-detector",
132-
query="What kind of dog is this?",
133-
class_names=class_names,
134-
)
135-
# highlight-end
136-
```
137-
138-
:::tip
139-
We recommend adding an "Other" class to your multi-class detector to handle cases where the image does not belong to any of the pre-defined classes.
140-
:::
141-
142-
<!-- :::note
143-
Multi-Class Detectors are available on [Business and Enterprise plans](https://www.groundlight.ai/pricing).
144-
::: -->
145-
146-
### Submit an Image Query to a Multi-Class Detector
147-
148-
Now that you have created a multi-class detector, you can submit an image query to it.
149-
150-
```python notest
151-
from groundlight import ExperimentalApi
152-
gl_exp = ExperimentalApi()
153-
154-
detector = gl_exp.get_detector_by_name("dog-breed-detector")
155-
156-
# highlight-start
157-
# Classify the breed of a dog in an image
158-
image_query = gl_exp.submit_image_query(detector, "path/to/image.jpg")
159-
# highlight-end
160-
161-
print(f"Result: {image_query.result.label}")
162-
print(f"Confidence: {image_query.result.confidence}")
163-
```
164-
165-
Multi-class detectors return a `label` attribute in the result object, which contains the predicted class label. The `label` attribute will be one of the class names provided when creating the detector. The `confidence` attribute represents the confidence level in the predicted class, which is a value between `1/len(class_names)` and 1.
166-
167-
### Add a label to a Multi-Class Detector
168-
169-
To provide ground truth labels for multi-class detectors, you can specify the label of the correct class.
170-
171-
```python notest
172-
from groundlight import ExperimentalApi
173-
gl_exp = ExperimentalApi()
174-
175-
# highlight-start
176-
# Add a multi-class label to the image query from the previous example
177-
gl_exp.add_label(image_query, label="German Shepherd")
178-
# highlight-end
179-
```
180-
181-
<!-- TODO: text, object detection modes -->
115+
```
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Answer Modes",
3+
"position": 3
4+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Detector Answer Modes
2+
3+
Groundlight offers several detector modalities to suit different computer vision tasks. While previous examples have focused on binary classification, this guide will walk you through using counting and multi-class detectors. Let's explore how these different modes can be used via the Groundlight SDK.
4+
5+
1. [Binary Detectors](1-binary-detectors.md)
6+
2. [Multi-class Detectors](2-multi-class-detectors.md)
7+
3. [Counting Detectors](3-counting-detectors.md)
8+
9+
<!-- TODO: text, object detection modes -->

docs/docs/guide/4-submitting-image-queries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ image_query = gl.get_image_query(id=image_query.id)
7373
# highlight-end
7474
```
7575

76-
See this [guide](./8-async-queries.md) for more information on ImageQueries submitted asynchronously.
76+
See this [guide](./7-async-queries.md) for more information on ImageQueries submitted asynchronously.
7777

7878
### (Advanced) Get the first available answer, regardless of confidence
7979
`ask_ml` evaluates an image with Groundlight and returns the first answer Groundlight can provide, agnostic of confidence. There is no wait period when using this method. It is called `ask_ml` because our machine learning models are earliest on our escalation ladder and thus always the fastest to respond.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/docs/guide/_category_.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"label": "Guide",
3-
"position": 3
3+
"position": 4
44
}

docs/docs/guide/guide.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ On the following pages, we'll guide you through the process of building applicat
66
- **[Grabbing images](2-grabbing-images.md)**: Understand the intricacies of how to submit images from various input sources to Groundlight.
77
- **[Working with detectors](3-working-with-detectors.md)**: Learn how to create, configure, and use detectors in your Groundlight-powered applications.
88
- **[Submitting image queries](4-submitting-image-queries.md)**: Submit images to Groundlight for analysis and retrieve the results.
9-
- **[Detector answer modes](5-detector-modes.md)**: Answer counting and multi-classification queries with Groundlight.
10-
- **[Confidence levels](6-managing-confidence.md)**: Master how to control the trade-off of latency against accuracy by configuring the desired confidence level for your detectors.
11-
- **[Handling errors](7-handling-errors.md)**: Understand how to handle and troubleshoot HTTP errors (`ApiException`) that may occur while using Groundlight.
12-
- **[Asynchronous queries](8-async-queries.md)**: Groundlight makes it easy to submit asynchronous queries. Learn how to submit queries asynchronously and retrieve the results later.
13-
- **[Using Groundlight on the edge](9-edge.md)**: Discover how to deploy Groundlight in edge computing environments for improved performance and reduced latency.
14-
- **[Alerts](10-alerts.md)**: Learn how to set up alerts to notify you via text (SMS) or email when specific conditions are met in your visual applications.
9+
- **[Confidence levels](5-managing-confidence.md)**: Master how to control the trade-off of latency against accuracy by configuring the desired confidence level for your detectors.
10+
- **[Handling errors](6-handling-errors.md)**: Understand how to handle and troubleshoot HTTP errors (`ApiException`) that may occur while using Groundlight.
11+
- **[Asynchronous queries](7-async-queries.md)**: Groundlight makes it easy to submit asynchronous queries. Learn how to submit queries asynchronously and retrieve the results later.
12+
- **[Using Groundlight on the edge](8-edge.md)**: Discover how to deploy Groundlight in edge computing environments for improved performance and reduced latency.
13+
- **[Alerts](9-alerts.md)**: Learn how to set up alerts to notify you via text (SMS) or email when specific conditions are met in your visual applications.
1514

1615

1716
By exploring these resources and sample applications, you'll be well on your way to building powerful visual applications using Groundlight's computer vision and natural language capabilities.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"label": "Alternative Deployment Options",
3-
"position": 5,
3+
"position": 6,
44
"collapsed": false
55
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"label": "Sample Applications",
3-
"position": 4
3+
"position": 5
44
}

0 commit comments

Comments
 (0)