Skip to content

Commit 5f52f94

Browse files
committed
Adding DeepForest multi agent with HuggingFace models implementation
1 parent dbd566e commit 5f52f94

36 files changed

+7443
-1
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ eggs/
1616
.installed.cfg
1717
*.egg
1818
MANIFEST
19+
20+
21+
# Environment
22+
.env
23+
24+
25+
# Testing
26+
.pytest_cache/
27+
28+
29+
# Project specific
30+
lightning_logs/
31+
.gradio/
32+
logs/

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,82 @@
1-
# deepforest-agent
1+
# DeepForest Multi-Agent System
2+
3+
The DeepForest Multi-Agent System provides ecological image analysis by orchestrating multiple AI agents that work together to understand ecological images. Simply upload an image of a forest, wildlife habitat, or ecological scene, and ask questions in natural language. You
4+
5+
## Installation
6+
7+
### 1. Clone the repository
8+
9+
```bash
10+
git clone https://github.com/weecology/deepforest-agent.git
11+
cd deepforest-agent
12+
```
13+
14+
### 2. Create and activate a Conda environment
15+
16+
```bash
17+
conda create -n deepforest_agent python=3.12.11
18+
conda activate deepforest_agent
19+
```
20+
21+
### 3. Install dependencies
22+
23+
```bash
24+
pip install -r requirements.txt
25+
pip install -e .
26+
```
27+
28+
### 4. Configure the HuggingFace Token
29+
Create a `.env` file in the root directory of the deepforest-agent project and add your HuggingFace token like below:
30+
31+
```bash
32+
HF_TOKEN="your_huggingface_token_here"
33+
```
34+
35+
You can obtain your token from [HuggingFace Access Token](https://huggingface.co/settings/tokens). Make sure the Token type is "Write".
36+
37+
## Usage
38+
39+
The DeepForest Agent runs through a Gradio web interface. To start the interface, execute:
40+
41+
```bash
42+
python app.py
43+
```
44+
45+
A link like http://127.0.0.1:7860 will appear in the terminal. Open it in your browser to interact with the agent. A public Gradio link may also be provided if available.
46+
47+
**Sample Recording of Running the System:** [Drive Link](https://drive.google.com/file/d/1gNMn-xJd48Ld3TZU4oiYvTbiWaiLsc8G/view?usp=sharing)
48+
49+
50+
## Features
51+
52+
- **Multi-Species Detection**: Automatically detects trees, birds, and livestock using specialized DeepForest models
53+
- **Tree Health Assessment**: Identifies alive and dead trees using DeepForest Tree Detector whenever user asks.
54+
- **Visual Analysis**: Dual analysis of original and annotated images using Qwen2.5-VL-3B-Instruct model
55+
- **Memory Context**: Maintains conversation history for contextual understanding across multiple queries
56+
- **Tiling Image for Visual Agent:** Larger images are tiled and processed individually for the visual agent.
57+
- **R-Tree Spatial Indexing:** Stores DeepForest Results in an R-Tree spatial index structure and use spatial queries to retrieve relevant information and present it to the user.
58+
- **Ecological Insights**: Synthesizes detection data with visual analysis and memory context for comprehensive ecological understanding
59+
- **Streaming Responses**: Real-time updates as each agent processes your query
60+
61+
62+
## Requirements
63+
64+
### Hardware Requirements
65+
- **GPU**: GPU with at least 24GB VRAM (recommended for optimal performance)
66+
- **Storage**: At least 35GB free space for model downloads
67+
68+
### API Requirements
69+
- **HuggingFace Token**: Required for model access.
70+
71+
72+
## Models Used
73+
74+
- **SmolLM3-3B**: For Memory Agent to get context, and for Detector Agent to call the tool with appropriate parameters
75+
- **Qwen2.5-VL-3B-Instruct**: Used in Visual agent for multimodal image-text understanding
76+
- **Llama-3.2-3B-Instruct**: For Ecology agents for text understanding and generation
77+
- **DeepForest Models**: For tree, bird, and livestock detection. Also used for alive/dead tree classification.
78+
79+
80+
## Multi-Agent Workflow
81+
82+
[![](https://mermaid.ink/img/pako:eNqlV9ty4jgQ_RWVt2pexmQI9_hhtwiQK4SLgVyceVBMO7giLEq2kzAk_75tSTYiM9k8LA8UpruPuk93H9tby-cLsBzrUdD1kky79xHBT9ubxSDIbM04XcTkfEUf4Scplf4mx15HAE2AuBDHIY_IN3IehUlIWfgL_0zQ9FNhHEv_jkJyIUKccQpio80dae56Q-EvIU4ETbhwyCBlSVhqP0KUkGsungLGXzJUkegw9d2VwT1vACsuNkT6O8RdcdYfVEvVY-3ck24nW-12RmPSDQX4CWlH8QuIf95N0JPM--0W4jdy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