Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -26,6 +26,7 @@ Instruction-prompted object detection with vision-language models via vLLM. Desi
|
|
| 26 |
|---|---|---|
|
| 27 |
| `qwen3vl-detect.py` | **Stable** | Standard zero-shot detection |
|
| 28 |
| `qwen3vl-detect-fewshot.py` | **Experimental** | One-shot in-context example — pass an example image + its labelled output to demonstrate the task |
|
|
|
|
| 29 |
|
| 30 |
The script name says `qwen3vl` because the bbox-output convention (`bbox_2d` JSON normalised to 0-1000) is the Qwen-VL family standard, but the script is mostly model-agnostic — you can pass any vLLM-supported VLM via `--model` and adjust the prompt accordingly.
|
| 31 |
|
|
@@ -77,9 +78,46 @@ Return a JSON array.
|
|
| 77 |
|
| 78 |
Empirical lessons:
|
| 79 |
|
|
|
|
| 80 |
- **Keep prompts positive-only.** Telling the model what to *find* works better than "ignore X" clauses, which can trigger over-conservative empty outputs on busy pages.
|
| 81 |
- **Give the model a broad taxonomy and filter the output post-hoc** rather than narrowing the prompt. Asking for 7 categories then `label in {"Photograph", "Illustration"}` produces better detections on the categories you care about than asking for just those 2 classes upfront.
|
| 82 |
-
- **Sub-labels are descriptive prose**, not constrained. The model uses them for colour ("blue nitrile"), material ("white N95 respirator"), reference designators ("R246", "U201"), or transcribed text (actual headline text on a newspaper page).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
## Hardware notes
|
| 85 |
|
|
@@ -113,6 +151,23 @@ These public datasets were generated with the recommended config (Qwen3.6-35B-A3
|
|
| 113 |
| `davanstrien/qwen3.6-cppe5-20samples` | `rishitdagli/cppe-5` (medical PPE photos, 5 classes) | Detect Coverall/Face_Shield/Gloves/Goggles/Mask | Labelling-grade boxes (within ~10 px of GT on most items). Descriptive sub-labels ("white N95 respirator", "blue nitrile") |
|
| 114 |
| `davanstrien/qwen3.6-beyond-words-20samples` | `biglam/loc_beyond_words` (WW1-era newspapers, 7 classes) | Detect Photograph/Illustration/Map/Comics/Editorial Cartoon/Headline/Advertisement | Mixed — clean per-element detection on most pages, occasional empty output on the densest layouts. Notable: `sub_label` often contains transcribed headline text |
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
## Known limitations
|
| 117 |
|
| 118 |
- **Bbox precision varies by model and image.** On natural-object photos (PPE, products, animals), boxes are often within 10 px of ground truth. On dense document layouts, boxes are looser and occasionally model gives up on a page entirely.
|
|
|
|
| 26 |
|---|---|---|
|
| 27 |
| `qwen3vl-detect.py` | **Stable** | Standard zero-shot detection |
|
| 28 |
| `qwen3vl-detect-fewshot.py` | **Experimental** | One-shot in-context example — pass an example image + its labelled output to demonstrate the task |
|
| 29 |
+
| `inspect-detections.py` | **Utility** | Render a side-by-side PNG of model detections vs ground truth (when source has GT) for each row of an output dataset. Used to generate all visual comparisons in this README. |
|
| 30 |
|
| 31 |
The script name says `qwen3vl` because the bbox-output convention (`bbox_2d` JSON normalised to 0-1000) is the Qwen-VL family standard, but the script is mostly model-agnostic — you can pass any vLLM-supported VLM via `--model` and adjust the prompt accordingly.
|
| 32 |
|
|
|
|
| 78 |
|
| 79 |
Empirical lessons:
|
| 80 |
|
| 81 |
+
- **Enumerate the class set in the prompt** when you have one. Listing the 23 ENA24 species or the 5 CPPE-5 PPE classes explicitly in the prompt constrains the model's label vocabulary and cuts class drift (e.g. "Squirrel" vs "Eastern Gray Squirrel").
|
| 82 |
- **Keep prompts positive-only.** Telling the model what to *find* works better than "ignore X" clauses, which can trigger over-conservative empty outputs on busy pages.
|
| 83 |
- **Give the model a broad taxonomy and filter the output post-hoc** rather than narrowing the prompt. Asking for 7 categories then `label in {"Photograph", "Illustration"}` produces better detections on the categories you care about than asking for just those 2 classes upfront.
|
| 84 |
+
- **Sub-labels are descriptive prose**, not constrained. The model uses them for colour ("blue nitrile"), material ("white N95 respirator"), behaviour/posture, reference designators ("R246", "U201"), or transcribed text (actual headline text on a newspaper page).
|
| 85 |
+
|
| 86 |
+
### Example prompts used in the worked examples
|
| 87 |
+
|
| 88 |
+
The exact prompt strings that produced the example datasets below — copy and adapt:
|
| 89 |
+
|
| 90 |
+
**Wildlife (ENA24, 23 species):**
|
| 91 |
+
```
|
| 92 |
+
Detect every distinct animal, person, or vehicle visible in this camera trap photo.
|
| 93 |
+
For each, return a JSON object with "bbox_2d": [x1, y1, x2, y2] (coordinates normalised
|
| 94 |
+
to 0-1000), "label" (one of: Bird, Eastern Gray Squirrel, Eastern Chipmunk, Woodchuck,
|
| 95 |
+
Wild Turkey, White_Tailed_Deer, Virginia Opossum, Eastern Cottontail, Human, Vehicle,
|
| 96 |
+
Striped Skunk, Red Fox, Eastern Fox Squirrel, Northern Raccoon, Grey Fox, Horse, Dog,
|
| 97 |
+
American Crow, Chicken, Domestic Cat, Coyote, Bobcat, American Black Bear), and
|
| 98 |
+
"sub_label" (a short description, e.g. behaviour, posture, or partial-visibility note).
|
| 99 |
+
Return a JSON array.
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
**Medical PPE (CPPE-5, 5 classes):**
|
| 103 |
+
```
|
| 104 |
+
Detect every piece of medical personal protective equipment (PPE) visible in this
|
| 105 |
+
image. For each, return a JSON object with "bbox_2d": [x1, y1, x2, y2] (coordinates
|
| 106 |
+
normalised to 0-1000), "label" (exactly one of: Coverall, Face_Shield, Gloves,
|
| 107 |
+
Goggles, Mask), and "sub_label" (a short colour or material descriptor). Return a
|
| 108 |
+
JSON array. Each object must be a distinct visible item; do not return overlapping
|
| 109 |
+
or duplicate boxes.
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
**Historical newspapers (Beyond Words, 7 classes):**
|
| 113 |
+
```
|
| 114 |
+
Detect every distinct visual element on this historical newspaper page. For each,
|
| 115 |
+
return a JSON object with "bbox_2d": [x1, y1, x2, y2] (coordinates normalised to
|
| 116 |
+
0-1000), "label" (one of: Photograph, Illustration, Map, Comics/Cartoon, Editorial
|
| 117 |
+
Cartoon, Headline, Advertisement), and "sub_label" (a short description of the
|
| 118 |
+
content). Return a JSON array. Each object must be a distinct visible region; do
|
| 119 |
+
not return overlapping or duplicate boxes.
|
| 120 |
+
```
|
| 121 |
|
| 122 |
## Hardware notes
|
| 123 |
|
|
|
|
| 151 |
| `davanstrien/qwen3.6-cppe5-20samples` | `rishitdagli/cppe-5` (medical PPE photos, 5 classes) | Detect Coverall/Face_Shield/Gloves/Goggles/Mask | Labelling-grade boxes (within ~10 px of GT on most items). Descriptive sub-labels ("white N95 respirator", "blue nitrile") |
|
| 152 |
| `davanstrien/qwen3.6-beyond-words-20samples` | `biglam/loc_beyond_words` (WW1-era newspapers, 7 classes) | Detect Photograph/Illustration/Map/Comics/Editorial Cartoon/Headline/Advertisement | Mixed — clean per-element detection on most pages, occasional empty output on the densest layouts. Notable: `sub_label` often contains transcribed headline text |
|
| 153 |
|
| 154 |
+
## Inspecting outputs
|
| 155 |
+
|
| 156 |
+
`inspect-detections.py` renders side-by-side PNGs of model detections vs ground truth (when available) so you can eyeball quality before trusting the dataset. Runs locally (no GPU needed) — installs matplotlib + datasets via uv on first invocation.
|
| 157 |
+
|
| 158 |
+
```bash
|
| 159 |
+
uv run https://huggingface.co/datasets/uv-scripts/vlm-object-detection/raw/main/inspect-detections.py \
|
| 160 |
+
davanstrien/qwen3.6-ena24-20samples \
|
| 161 |
+
--split train \
|
| 162 |
+
--source davanstrien/ena24-detection \
|
| 163 |
+
--source-split train \
|
| 164 |
+
--max-rows 20
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
The `--source` flag is optional but recommended when the source dataset has bbox ground truth — the script will read the source's `objects.category` ClassLabel feature to recover human-readable class names (which get stripped from the output dataset's features on `push_to_hub` round-trip). Without `--source`, only the model detections panel is rendered.
|
| 168 |
+
|
| 169 |
+
PNGs are written to `/tmp/<output-slug>-viz/` by default (override with `--out-dir`). Each file is `row{i}_id{image_id}.png`. Per-row text summary (detection counts, label histogram, bbox value range) is printed to stdout.
|
| 170 |
+
|
| 171 |
## Known limitations
|
| 172 |
|
| 173 |
- **Bbox precision varies by model and image.** On natural-object photos (PPE, products, animals), boxes are often within 10 px of ground truth. On dense document layouts, boxes are looser and occasionally model gives up on a page entirely.
|