Skip to content

Commit 5171358

Browse files
committed
Add description of beetle detection script,
replace notebook as recommended use
1 parent 959a8e5 commit 5171358

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ carabidae_beetle_processing/
4646
├── scripts/
4747
| ├── 2018_neon_beetles_get_individual_images.py # Crop beetles from group images
4848
| ├── Figure6and10.R # NEON data analysis and visualization
49+
| ├── beetle_detection.py # Grounding-Dino-based detection of beetles
4950
| ├── calipers_vs_toras.py # Human vs. automated measurement comparison
5051
| ├── inter_annotator.py # Inter-annotator agreement analysis
5152
| ├── resizing_individual_beetle_images.py # Resize individual images with uniform scaling
52-
| └── upload_dataset_to_hf.py # Upload datasets to Hugging Face
53+
| └── upload_dataset_to_hf.py # Upload datasets to Hugging Face
5354
├── .gitignore # Git ignore patterns
5455
├── CITATION.cff # Citation metadata
5556
├── LICENSE # MIT License
@@ -141,11 +142,27 @@ python upload_dataset_to_hf.py \
141142

142143
**Notebook:** `grounding_dino.ipynb`
143144

144-
Advanced pipeline using **Grounding DINO** for automated beetle detection and segmentation.
145+
Advanced pipeline using **Grounding DINO** for automated beetle detection and segmentation. `scripts/beetle_detection.py` is this notebook converted to a runnable script. An example minimal run (passing only required parameters) is provided below:
146+
147+
```console
148+
python scripts/beetle_detection.py \
149+
--csv_path data/metadata.csv \
150+
--image_dir data/group_images \
151+
--save_folder data/individual_images \
152+
--output_csv data/processed.csv
153+
```
154+
155+
Additional optional parameters that can be passed are as follows:
156+
- `model_id`: Model ID for Grounding-DINO, default is `IDEA-Research/grounding-dino-base`.
157+
- `text`: Text prompt for detection, default is `"a beetle."`.
158+
- `box_threshold`: Box threshold for detection, default is `0.2`.
159+
- `text_threshold`: Text threshold for detection,default is `0.2`.
160+
- `padding`: Padding factor for cropping, default is `0.1`.
161+
- `iou_threshold`: IoU threshold for Non-Maximum Suppression (NMS), default is `0.6`.
145162

146163
**Workflow:**
147164
1. Load beetle measurements from the [2018 NEON Ethanol-preserved Ground Beetles dataset](https://huggingface.co/datasets/imageomics/2018-NEON-beetles)
148-
2. Initialize Grounding DINO model (IDEA-Research/grounding-dino-base)
165+
2. Initialize Grounding DINO model
149166
3. For each image:
150167
- Detect beetles using text prompt ("a beetle")
151168
- Filter detections based on adaptive area thresholds
@@ -290,13 +307,17 @@ python 2018_neon_beetles_get_individual_images.py \
290307

291308
### 2. Zero-Shot Object Detection
292309

293-
Run the Jupyter notebook for automated beetle detection:
310+
Run `scripts/beetle_detection.py` (or `notebook grounding_dino.ipynb`) for automated beetle detection.
294311

295-
```bash
296-
jupyter notebook grounding_dino.ipynb
312+
```console
313+
python scripts/beetle_detection.py \
314+
--csv_path data/metadata.csv \
315+
--image_dir data/group_images \
316+
--save_folder data/individual_images \
317+
--output_csv data/processed.csv
297318
```
298319

299-
**Key Configuration Variables** (modify in notebook):
320+
**Key Configuration Variables** (as in notebook):
300321

301322
```python
302323
# Data paths

0 commit comments

Comments
 (0)