A project for digitizing herbarium specimen labels by combining modern visual grounding and large language models in a single extraction pipeline. The system uses zero-shot object localization (Grounding DINO) to find label regions and large language-and-vision models (LLVMs) to extract and structure textual information from those regions. Supported providers in the codebase include Google (Gemini via google-genai), OpenAI (GPT family), Groq (LLaMA-family models served via the Groq API), and Ollama (local or remote Ollama-hosted models).
herbarium_label_reader/
├── app.py # Gradio web app (single & batch interfaces)
├── extract_data.py # Hydra-driven experiment runner / batch extractor
├── evaluate.py # Script to compare extracted CSVs with ground truth
├── evaluate_all.sh # Helper for running multiple evaluations
├── run_experiments.sh # Example hydra multirun invocation
├── webapp/ # Webapp helpers (process_request.py)
├── preprocessors/ # Preprocessor implementations (Grounding DINO)
├── llms/ # Wrappers for Gemini/OpenAI/Groq/Ollama models
├── requirements.txt
└── config.yaml # Default hydra configuration
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
.env file at the project root. The application and scripts call load_dotenv(), and the following environment variables are commonly required depending on which providers you use:# For OpenAI models
OPENAI_API_KEY=...
# For Google Gemini (google-genai)
GEMINI_API_KEY=...
# For Groq
GROQ_API_KEY=...
To run experiments on a dataset of herbarium labels:
./run_experiments.sh /path/to/dataset/images /path/to/output_directory
Notes:
run_experiments.sh invokes extract_data.py under hydra multirun. Outputs go into the hydra sweep directory (see config.yaml hydra.sweep.dir and printed output path).extract_data.py reads image paths from the list pointed to by config.image_list and the dataset root at config.dataset_path (see config.yaml). Adjust config.yaml or pass overrides via hydra/CLI if needed.You can run a single extraction job (no sweep) by calling the script with hydra overrides, for example:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=gemini-2.5-pro
# Or use Ollama models:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=ollama:gemma4:31b
# Or remote Ollama server:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=ollama:gemma4:31b remote_server=http://localhost:11434
The script saves a CSV named extracted_data.csv inside the hydra-run output directory.
The evaluation script compares extracted data against ground truth data. Use it as follows:
python evaluate.py \
--extracted_csv /path/to/results/extracted_data.csv \
--ground_truth_csv /path/to/ground_truth/label_data.csv \
--output_csv /path/to/output/evaluation_results.csv
The web application provides two main interfaces for processing herbarium labels:
To launch the web app:
python app.py
Access the application at http://localhost:7860
The extracted data is saved in CSV format with the following fields:
MIT License — see LICENSE file for details.
1 commits
Python
98.9%
Shell
1.1%
A project for digitizing herbarium specimen labels by combining modern visual grounding and large language models in a single extraction pipeline. The system uses zero-shot object localization (Grounding DINO) to find label regions and large language-and-vision models (LLVMs) to extract and structure textual information from those regions. Supported providers in the codebase include Google (Gemini via google-genai), OpenAI (GPT family), Groq (LLaMA-family models served via the Groq API), and Ollama (local or remote Ollama-hosted models).
herbarium_label_reader/
├── app.py # Gradio web app (single & batch interfaces)
├── extract_data.py # Hydra-driven experiment runner / batch extractor
├── evaluate.py # Script to compare extracted CSVs with ground truth
├── evaluate_all.sh # Helper for running multiple evaluations
├── run_experiments.sh # Example hydra multirun invocation
├── webapp/ # Webapp helpers (process_request.py)
├── preprocessors/ # Preprocessor implementations (Grounding DINO)
├── llms/ # Wrappers for Gemini/OpenAI/Groq/Ollama models
├── requirements.txt
└── config.yaml # Default hydra configuration
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
.env file at the project root. The application and scripts call load_dotenv(), and the following environment variables are commonly required depending on which providers you use:# For OpenAI models
OPENAI_API_KEY=...
# For Google Gemini (google-genai)
GEMINI_API_KEY=...
# For Groq
GROQ_API_KEY=...
To run experiments on a dataset of herbarium labels:
./run_experiments.sh /path/to/dataset/images /path/to/output_directory
Notes:
run_experiments.sh invokes extract_data.py under hydra multirun. Outputs go into the hydra sweep directory (see config.yaml hydra.sweep.dir and printed output path).extract_data.py reads image paths from the list pointed to by config.image_list and the dataset root at config.dataset_path (see config.yaml). Adjust config.yaml or pass overrides via hydra/CLI if needed.You can run a single extraction job (no sweep) by calling the script with hydra overrides, for example:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=gemini-2.5-pro
# Or use Ollama models:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=ollama:gemma4:31b
# Or remote Ollama server:
python extract_data.py dataset_path=/absolute/path/to/dataset image_list=data/handwritten.txt n_images=50 llm.model_name=ollama:gemma4:31b remote_server=http://localhost:11434
The script saves a CSV named extracted_data.csv inside the hydra-run output directory.
The evaluation script compares extracted data against ground truth data. Use it as follows:
python evaluate.py \
--extracted_csv /path/to/results/extracted_data.csv \
--ground_truth_csv /path/to/ground_truth/label_data.csv \
--output_csv /path/to/output/evaluation_results.csv
The web application provides two main interfaces for processing herbarium labels:
To launch the web app:
python app.py
Access the application at http://localhost:7860
The extracted data is saved in CSV format with the following fields:
MIT License — see LICENSE file for details.
1 commits
Python
98.9%
Shell
1.1%