PestGuardian is a web-based application designed to assist farmers and gardeners in identifying pests in their crops and providing actionable recommendations for their elimination. By leveraging advanced computer vision and natural language processing, PestGuardian allows users to upload images of pests, detects the pests using a state-of-the-art YOLO model, and generates practical elimination methods using web search and AI-driven recommendations.
This project combines cutting-edge technologies to create a user-friendly tool that simplifies pest management, making it accessible even to those without extensive technical expertise.
Technology | Purpose |
---|---|
Streamlit | Creates the interactive web interface for user interaction. |
Ultralytics YOLO | Detects pests in uploaded images using the YOLO model. |
LangChain & LangChain-Ollama | Powers natural language processing with the Qwen2.5 model for generating recommendations. |
GoogleSerperAPIWrapper | Performs web searches to find pest elimination methods. |
LangGraph | Orchestrates the workflow of pest detection, web search, and recommendation generation. |
nest_asyncio | Handles asynchronous operations for smooth execution in the browser. |
To run PestGuardian locally, follow these steps:
-
Clone the repository:
git clone https://github.com/armanjscript/PestGuardian.git
-
Navigate to the project directory:
cd PestGuardian
-
Install dependencies:
- If a
requirements.txt
file is provided, install the dependencies using:pip install -r requirements.txt
- If not, install the required libraries manually:
pip install streamlit ultralytics langchain langchain-ollama langgraph google-serper nest-asyncio
- If a
-
Set up environment variables:
- Obtain a Serper API key from Serper.dev for web searching.
- Set the environment variable
SERPER_API_KEY
:export SERPER_API_KEY=your_api_key_here
-
Download the YOLO model:
- Place the YOLO model file (
best.pt
) in the project directory. - If you don’t have the model, you can:
- Train your own YOLO model using Ultralytics.
- Use a pre-trained model suitable for pest detection, ensuring compatibility with Ultralytics YOLO.
- Place the YOLO model file (
-
Run the application:
streamlit run main.py
-
Upload an image:
- Open the web interface in your browser (typically at
http://localhost:8501
). - Use the file uploader to upload an image of pests in your garden or farm (supported formats:
.jpg
,.jpeg
,.png
).
- Open the web interface in your browser (typically at
-
View results:
- The application will:
- Detect pests using the YOLO model.
- Search for elimination methods using the Serper API.
- Generate recommendations using the OllamaLLM (Qwen2.5 model).
- Results, including detected pests and recommendations, will be displayed in the interface.
- Expand the “View detailed search results” section to see additional information from the web search.
- The application will:
- Image Upload: User uploads an image of a garden with visible pests.
- Pest Detection: The YOLO model analyzes the image and identifies pests (e.g., aphids, beetles).
- Web Search: The application searches for elimination methods for each detected pest using the Serper API.
- Recommendation Generation: The Qwen2.5 model processes the search results and generates concise, practical recommendations.
- Result Display: The interface shows the detected pests, recommendations, and optional detailed search results.
We welcome contributions to PestGuardian! To contribute:
- Open an issue on the GitHub repository to report bugs or suggest features.
- Submit a pull request with your changes, ensuring they follow the project’s coding standards and include documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions, feedback, or support, please:
- Email: [armannew73@gmail.com]
- Open an issue on the GitHub repository.
PestGuardian is an evolving project with several planned enhancements:
- Improve pest detection accuracy by fine-tuning the YOLO model with diverse datasets.
- Add multilingual support for recommendations to reach a broader audience.
- Integrate additional APIs for comprehensive pest information.
- Enhance the user interface for a more intuitive and engaging experience.
- Missing YOLO model: Ensure
best.pt
is in the project directory. Check Ultralytics documentation for model training or acquisition. - API key issues: Verify that the
SERPER_API_KEY
is correctly set in your environment. - Dependency errors: Ensure all required libraries are installed and compatible with your Python version (recommended: Python 3.8+).
- Async issues: The application uses
nest_asyncio
to handle asynchronous operations, but ensure your environment supports async execution.