Skip to content

Commit 13284dc

Browse files
authored
Doc updates (#25)
* Update UserGuide.md update docs to use get_or_create_detector as default instead of create_detector * Update UserGuide.md * Update UserGuide.md added add_label support * Update UserGuide.md addressing PR feedback
1 parent 156b677 commit 13284dc

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

UserGuide.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ How to build a working computer vision system in just 5 lines of python code:
99
```Python
1010
from groundlight import Groundlight
1111
gl = Groundlight()
12-
d = gl.create_detector("door", query="Is the door open?") # define with natural language
12+
d = gl.get_or_create_detector(name="door", query="Is the door open?") # define with natural language
1313
image_query = gl.submit_image_query(detector=d, image=jpeg_img) # send in an image
1414
print(f"The answer is {image_query.result}") # get the result
1515
```
@@ -28,7 +28,7 @@ The desired confidence level is set as the escalation threshold on your detector
2828
For example, say you want to set your desired confidence level to 0.95, but that you're willing to wait up to 60 seconds to get a confident response.
2929

3030
```Python
31-
d = gl.create_detector("trash", query="Is the trash can full?", confidence=0.95)
31+
d = gl.get_or_create_detector(name="trash", query="Is the trash can full?", confidence=0.95)
3232
image_query = gl.submit_image_query(detector=d, image=jpeg_img, wait=60)
3333
# This will wait until either 30 seconds have passed or the confidence reaches 0.95
3434
print(f"The answer is {image_query.result}")
@@ -40,7 +40,7 @@ Or if you want to run as fast as possible, set `wait=0`. This way you will only
4040
image_query = gl.submit_image_query(detector=d, image=jpeg_img, wait=0)
4141
```
4242

43-
You can see the confidence score returned for the image query:
43+
If the returned result was generated from an ML model, you can see the confidence score returned for the image query:
4444

4545
```Python
4646
print(f"The confidence is {image_query.result.confidence}")
@@ -107,6 +107,14 @@ gl = Groundlight(endpoint="http://localhost:6717")
107107

108108
## Advanced
109109

110+
### Explicitly create a new detector
111+
112+
Typically you'll use the ```get_or_create_detector(name: str, query: str)``` method to find an existing detector you've already created with the same name, or create a new one if it doesn't exists. But if you'd like to force creating a new detector you can also use the ```create_detector(name: str, query: str)``` method
113+
114+
```Python
115+
detector = gl.create_detector(name="your_detector_name", query="is this what we want to see?")
116+
```
117+
110118
### Retrieve an existing detector
111119

112120
```Python
@@ -141,6 +149,17 @@ image_queries = gl.list_image_queries()
141149
image_queries = gl.list_image_queries(page=3, page_size=25)
142150
```
143151

152+
### Adding labels to existing image queries
153+
154+
Groundlight lets you start using models by making queries against your very first image, but there are a few situations where you might either have an existing dataset, or you'd like to handle the escalation response programatically in your own code but still include the label to get better responses in the future. With your ```image_query``` from either ```submit_image_query()``` or ```get_image_query()``` you can add the label directly. Note that if the query is already in the escalation queue due to low ML confidence or audit thresholds, it may also receive labels from another source.
155+
156+
```Python
157+
add_label(image_query, 'YES'). # or 'NO'
158+
```
159+
160+
The only valid labels at this time are ```'YES'``` and ```'NO'```
161+
162+
144163
### Handling HTTP errors
145164

146165
If there is an HTTP error during an API call, it will raise an `ApiException`. You can access different metadata from that exception:

0 commit comments

Comments
 (0)