Skip to content

Commit 75bcda7

Browse files
shondleshondlehogepodge
authored
feat: Feature/dino batching (HumanSignal#388)
* Add GroundingDINO backend * Clean comments * Feature/shondle sam with dino (HumanSignal#352) * Add baseline SAM code * Add TO DOs * Add SAM integration fixes * Add regular SAM * Add SAM capability and instructions * Update README.md * Remove whitespace * Remove whitespace * Adding env variables and code cleaning * Fix environment variable issues * Change truncation of ID * Remove exec * Adding SAM batch support * Add batch dino for multiple tasks * Add DINO Batching * Adding debug statements * Add support for more than three images at a time * Use Batching DINO Instead * Fix labelling scheme * Add batching instructions * Update README.md * Uncomment SAM download * Add batching example video * Remove extra print statements * Remove debug argument --------- Co-authored-by: shondle <�106922533+shondle@users.noreply.github.com> Co-authored-by: Chris Hoge <chris@hogepodge.com>
1 parent b52cdeb commit 75bcda7

File tree

5 files changed

+254
-44
lines changed

5 files changed

+254
-44
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/*
2+
docker-data/*

label_studio_ml/examples/grounding_dino/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ ENV PYTHONUNBUFFERED=True \
1616
COPY requirements.txt .
1717
RUN pip install --no-cache-dir -r requirements.txt
1818

19-
RUN git clone https://github.com/IDEA-Research/GroundingDINO.git
20-
WORKDIR /app/GroundingDINO
19+
RUN git clone https://github.com/yuwenmichael/Grounding-DINO-Batch-Inference.git
20+
WORKDIR /app/Grounding-DINO-Batch-Inference/GroundingDINO
2121
RUN pip -q install -e .
2222
RUN mkdir weights
23-
WORKDIR /app/GroundingDINO/weights
23+
WORKDIR /app/Grounding-DINO-Batch-Inference/GroundingDINO/weights
24+
2425
RUN wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
2526

2627
WORKDIR /app
2728
RUN wget -q https://github.com/ChaoningZhang/MobileSAM/raw/master/weights/mobile_sam.pt
2829
RUN wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
2930

30-
31+
RUN pip install olefile
3132
COPY . ./
3233

3334

34-
CMD gunicorn --preload --bind :$PORT --workers $WORKERS --threads $THREADS --timeout 0 _wsgi:app
35+
CMD gunicorn --preload --bind :$PORT --workers $WORKERS --threads $THREADS --timeout 0 _wsgi:app

label_studio_ml/examples/grounding_dino/README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Use text prompts for zero-shot detection of objects in images! Specify the detec
99
See [here](https://github.com/IDEA-Research/GroundingDINO) for more details about the pretrained GroundingDINO model.
1010

1111

12+
## Quickstart
13+
=======
1214
Quickstart
1315

1416
1. Make sure docker is installed
@@ -21,7 +23,7 @@ Example-
2123
3. Run `docker compose up`
2224
4. Check the IP of your backend using `docker ps` and add it to the Machine Learning backend in the Label Studio software. Usually this is on `http://localhost:9090`.
2325

24-
5. Edit the labelling config to the below.
26+
5. Create a project and edit the labelling config (an example is provided below). When editing the labeling config, make sure to add all rectangle labels under the RectangleLabels tag, and all corresponding brush labels under the BrushLabels tag.
2527

2628
```
2729
<View>
@@ -34,13 +36,16 @@ Example-
3436
</View>
3537
<RectangleLabels name="label" toName="image">
3638
<Label value="cats" background="yellow"/>
39+
<Label value="house" background="blue"/>
3740
</RectangleLabels>
41+
<BrushLabels name="label2" toName="image">
42+
<Label value="cats" background="yellow"/>
43+
<Label value="house" background="blue"/>
44+
</BrushLabels>
3845
</View>
3946
```
4047

41-
This may be adjusted to your needs, but please keep the promp section and some rectangle labels.
42-
43-
6. Go to an image task in one of your projects. Turn on the Auto-annotation switch. Then, type in the prompt box and press add. After this, you should receive your predictions. See the video above for a demo.
48+
6. Go to an image task in your project. Turn on the Auto-annotation switch. Then, type in the prompt box and press add. After this, you should receive your predictions. See the video above for a demo.
4449

4550

4651
## Using GroundingSAM
@@ -52,6 +57,24 @@ To do this, set `USE_SAM=True` before running.
5257
If you want to use a more efficient version of SAM, set `USE_MOBILE_SAM=True` as well.
5358

5459

60+
## Batching Inputs
61+
62+
https://github.com/HumanSignal/label-studio-ml-backend/assets/106922533/79b788e3-9147-47c0-90db-0404066ee43f
63+
64+
> Note: this is an experimental feature.
65+
66+
1. Clone the label studio branch with the added batching features.
67+
68+
`git clone -b feature/dino-support https://github.com/HumanSignal/label-studio.git`
69+
70+
2. Run this branch with `docker compose up`
71+
3. Do steps 2-5 from the [quickstart section](#quickstart), now using access code and host IP info of the newly clones Label Studio branch. GroundingSAM is supported.
72+
4. Go to the task menu inside your project and select the tasks you would like to annotate.
73+
5. Click the dropdown in the upper left hand side and select `Add Text Prompt for GroundingDINO`
74+
6. Enter in the prompt you would like to retrieve predictions for and press submit.
75+
- If your prompt is different from the label values you have assigned, you can use the underscore to give the correct label values to your prompt outputs. For example, if I wanted to select all brown cats but still give them the label value "cats" from my labeling config, my prompt would be "brown cat_cats".
76+
77+
5578
## Other Environment Variables
5679

5780
Adjust `BOX_THRESHOLD` and `TEXT_THRESHOLD` values in the Dockerfile to a number between 0 to 1 if experimenting. Defaults are set in `dino.py`. See explanation of these values in this [section](https://github.com/IDEA-Research/GroundingDINO#star-explanationstips-for-grounding-dino-inputs-and-outputs).

0 commit comments

Comments
 (0)