This web application is built using FastAPI and provides crop recommendations based on various environmental inputs such as NPK levels, temperature, humidity, and rainfall. It leverages a pre-trained machine learning model for predictions, and it can be deployed locally or in a cloud environment.
Before you begin, ensure you have the following installed on your system:
- Python 3.7 or higher
piporcondapackage manager
First, clone the repository to your local machine:
git https://github.com/meshachaderele/crop-recommendation.git
cd crop-recommendationEnsure that all the required dependencies are installed. The project includes a requirements.txt file that lists all necessary packages.
-
Create a virtual environment (optional but recommended):
python3 -m venv venv
-
Activate the virtual environment:
- For Windows:
venv\Scripts\activate
- For Mac/Linux:
source venv/bin/activate
- For Windows:
-
Install the dependencies from the
requirements.txtfile:pip install -r requirements.txt
If you are using Conda, create and activate a Conda environment:
conda create --name crop_recommendation python=3.11
conda activate crop_recommendationThen install the dependencies:
pip install -r requirements.txtEnsure you have your configuration file (config.yaml) set up correctly. This file contains settings like the model file path and other configuration parameters needed for the app to work.
If you do not have the config.yaml, you can create it by copying the sample template (if available) and adjusting the values.
Once everything is set up, you can start the application. Navigate to the app folder, and use uvicorn to run the FastAPI application.
Run the following command in your terminal:
uvicorn app:app --reloadThis will start the development server with hot reloading enabled.
- The app will be accessible at
http://127.0.0.1:8000/in your browser. - The
--reloadflag ensures that the server automatically reloads whenever you make changes to the code.
- Open your browser and navigate to
http://127.0.0.1:8000/. - Fill out the form with the necessary inputs (such as NPK levels, temperature, etc.).
- Submit the form, and the app will display the recommended crop along with an associated image.
- Input Form: A simple HTML form allows users to input various environmental parameters.
- Machine Learning Model: The app uses a pre-trained machine learning model to predict the most suitable crop.
- Image Display: The recommended crop is shown along with an associated image.