Skip to content

Commit b24b82c

Browse files
committed
update docs at the getting started page to resemble Tim Huff's guidance page
1 parent 0fa6244 commit b24b82c

File tree

2 files changed

+132
-122
lines changed

2 files changed

+132
-122
lines changed

docs/docs/getting-started/2-initial-setup.md

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 132 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,156 @@
1+
12
# Getting Started
23

3-
## Computer Vision powered by Natural Language
4+
## How to Build a Computer Vision Application with Groundlight's Python SDK
45

5-
Build a working computer vision system in just a few lines of python:
6+
If you're new to Groundlight, this is a good place to start. Learn how to run your first computer vision application.
67

7-
```python
8-
from groundlight import Groundlight
98

10-
gl = Groundlight()
11-
det = gl.get_or_create_detector(name="doorway", query="Is the doorway open?")
12-
img = "./docs/static/img/doorway.jpg" # Image can be a file or a Python object
13-
image_query = gl.submit_image_query(detector=det, image=img)
14-
print(f"The answer is {image_query.result}")
15-
```
169

17-
### How does it work?
10+
### What's below?
1811

19-
Your images are first analyzed by machine learning (ML) models which are automatically trained on your data. If those models have high enough [confidence](docs/guide/5-managing-confidence.md), that's your answer. But if the models are unsure, then the images are progressively escalated to more resource-intensive analysis methods up to real-time human review. So what you get is a computer vision system that starts working right away without even needing to first gather and label a dataset. At first it will operate with high latency, because people need to review the image queries. But over time, the ML systems will learn and improve so queries come back faster with higher confidence.
12+
- [Prerequisites](#prerequisites)
13+
- [Environment Setup](#environment-setup)
14+
- [Authentication](#authentication)
15+
- [Writing the code](#writing-the-code)
16+
- [Using your application](#using-your-computer-vision-application)
2017

21-
### Escalation Technology
2218

23-
Groundlight's Escalation Technology combines the power of generative AI using our Visual LLM, along with the speed of edge computing, and the reliability of real-time human oversight.
2419

25-
![diagram showing escalation technology](/img/escalation_diagram.jpg)
20+
### Prerequisites
2621

22+
Before getting started:
2723

28-
## Building a simple visual application
24+
- Make sure you have python installed
25+
- Install VSCode
26+
- Make sure your device has a c compiler. On Mac, this is provided through XCode while in Windows you can use the Microsoft Visual Studio Build Tools
2927

30-
1. Install the `groundlight` SDK. Requires python version 3.9 or higher.
28+
### Environment Setup
3129

32-
```shell
33-
pip3 install groundlight
34-
```
30+
Before you get started, you need to make sure you have python installed. Additionally, it’s good practice to set up a dedicated environment for your project.
3531

36-
1. Head over to the [Groundlight dashboard](https://dashboard.groundlight.ai/) to create an [API token](https://dashboard.groundlight.ai/reef/my-account/api-tokens). You will
37-
need to set the `GROUNDLIGHT_API_TOKEN` environment variable to access the API.
32+
You can download python from https://www.python.org/downloads/. Once installed, you should be able to run the following in the command line to create a new environment
3833

39-
```shell
40-
export GROUNDLIGHT_API_TOKEN=api_2GdXMflhJi6L_example
34+
```bash
35+
python3 -m venv gl_env
36+
```
37+
Once your environment is created, you can activate it with
38+
```bash
39+
source gl_env/bin/activate
40+
```
41+
For Linux and Mac or if you’re on Windows you can run
42+
```bash
43+
gl_env\Scripts\activate
44+
```
45+
The last step to setting up your python environment is to run
46+
```bash
47+
pip install groundlight
48+
pip install framegrab
4149
```
50+
in order to download Groundlight’s SDK and image capture libraries.
51+
52+
53+
54+
### Authentication
55+
56+
In order to verify your identity while connecting to your custom ML models through our SDK, you’ll need to create an API token.
57+
58+
1. Head over to [http://dashboard.groundlight.ai/](http://dashboard.groundlight.ai/) and create or log into your account
4259

43-
1. Create a python script.
60+
2. Once in, click on your username in the upper right hand corner of your dashboard:
4461

45-
```python title="ask.py"
46-
from groundlight import Groundlight
62+
![](https://cdn.prod.website-files.com/664b7cc2ac49aeb2da6ef127/66cfb5e41e8dd9e0dd597419_AD_4nXeh8kPRLV3V4_broECuW9z1ELIqEIyJUelCjbWdE7RFtakxaov5ZgUylZBo6g4DAgqgTP2DnSrcJ26J7-pdFA2pjjnFfYxZykniuEv0axiniev3cmZiyIjaGvyHdj-381PLhvRHsm_jd4KtXXmCOV9ClNQx.png)
4763

48-
gl = Groundlight()
49-
det = gl.get_or_create_detector(name="doorway", query="Is the doorway open?")
50-
img = "./docs/static/img/doorway.jpg" # Image can be a file or a Python object
51-
image_query = gl.submit_image_query(detector=det, image=img)
52-
print(f"The answer is {image_query.result}")
64+
3. Select API Tokens, then enter a name, like ‘personal-laptop-token’ for your api token.
65+
66+
![](https://cdn.prod.website-files.com/664b7cc2ac49aeb2da6ef127/66cfb5f8b844596360c5c460_AD_4nXfkHlRPPBcdkFFjjAAYC42LwgXe91qbwDfwFs3V8lGFXhSoSFpjUBXo7RX0vyZVYUurzEIp3kFL9H8pghpLD8omBqLGswHQJUMxGo8dBDh--e8wj4LQZcwywrt0hotsz9DoBZb5owokq2YeJlPI4_trG-nJ.png)
67+
68+
4. Copy the API Token for use in your code
69+
70+
IMPORTANT: Keep your API token secure! Anyone who has access to it can impersonate you and will have access to your Groundlight data
71+
72+
73+
```bash
74+
$env:GROUNDLIGHT_API_TOKEN="YOUR_API_TOKEN_HERE"
5375
```
76+
Or on Mac
77+
```bash
78+
export GROUNDLIGHT_API_TOKEN="YOUR_API_TOKEN_HERE"
79+
```
80+
81+
82+
### Writing the code
83+
84+
For our first demo, we’ll build a detector that checks if a trashcan is overflowing. You can copy the following code into a file inside your VSCode or check out the [github page](https://github.com/groundlight/video_tutorials/tree/main/sdk_intro).
85+
86+
You can start using Groundlight with a USB camera attached to your computer in just 15 lines of Python!
5487

55-
1. Run it!
88+
```python
89+
import groundlight
90+
import cv2
91+
from framegrab import FrameGrabber
92+
import time
5693

57-
```shell
58-
python ask.py
94+
gl = groundlight.Groundlight()
95+
96+
detector_name = "trash_detector"
97+
detector_query = "Is the trash can overflowing"
98+
99+
detector = gl.get_or_create_detector(detector_name, detector_query)
100+
101+
grabber = list(FrameGrabber.autodiscover().values())[0]
102+
103+
WAIT_TIME = 5
104+
last_capture_time = time.time() - WAIT_TIME
105+
106+
while True:
107+
frame = grabber.grab()
108+
109+
cv2.imshow('Video Feed', frame)
110+
key = cv2.waitKey(30)
111+
112+
if key == ord('q'):
113+
break
114+
# # Press enter to submit an image query
115+
# elif key in (ord('\r'), ord('\n')):
116+
# print(f'Asking question: {detector_query}')
117+
# image_query = gl.submit_image_query(detector, frame)
118+
# print(f'The answer is {image_query.result.label.value}')
119+
120+
# # Press 'y' or 'n' to submit a label
121+
# elif key in (ord('y'), ord('n')):
122+
# if key == ord('y'):
123+
# label = 'YES'
124+
# else:
125+
# label = 'NO'
126+
# image_query = gl.ask_async(detector, frame, human_review="NEVER")
127+
# gl.add_label(image_query, label)
128+
# print(f'Adding label {label} for image query {image_query.id}')
129+
130+
# Submit image queries in a timed loop
131+
now = time.time()
132+
if last_capture_time + WAIT_TIME < now:
133+
last_capture_time = now
134+
135+
print(f'Asking question: {detector_query}')
136+
image_query = gl.submit_image_query(detector, frame)
137+
print(f'The answer is {image_query.result.label.value}')
138+
139+
grabber.release()
140+
cv2.destroyAllWindows()
59141
```
142+
This code will take an image from your connected camera every minute and ask Groundlight a question in natural language, before printing out the answer.
143+
144+
145+
146+
### Using your computer vision application
147+
148+
Just like that, you have a complete computer vision application. You can change the code and configure a detector for your specific use case. Also, you can monitor and improve the performance of your detector at [http://dashboard.groundlight.ai/](http://dashboard.groundlight.ai/). Groundlight’s human-in-the-loop technology will monitor your image feed for unexpected changes and anomalies, and by verifying answers returned by Groundlight you can improve the process. At app.groundlight.ai, you can also set up text and email notifications, so you can be alerted when something of interest happens in your video stream.
149+
150+
151+
152+
### If You're Looking for More:
153+
154+
Want to deploy your Groundlight application on a dedicated device? See our guide on [how to use Groundlight with a Raspberry Pi](https://www.groundlight.ai/guides/raspberry-pi-tutorial).
155+
156+
Check out [the docs](https://code.groundlight.ai/python-sdk/) to learn how to further customize your app.

0 commit comments

Comments
 (0)