This is a Django-based API that provides machine learning capabilities for PlantAI. It allows you to to identify and diagnose plants.
The Django Machine Learning API project is licensed under the MIT License. For more details, please see the LICENSE file.
Follow these steps to install and set up the Django Machine Learning API ():
-
Clone the repository:
git clone https://github.com/Aeidle/PlantAI_API.git
-
Change into the project directory:
cd PlantAI_API
-
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # for macOS/Linux venv\Scripts\activate # for Windows
-
Install the required dependencies:
pip install -r requirements.txt
-
Perform database migrations:
python manage.py migrate # If the above command did not work, you can try running the following two commands instead: python manage.py makemigrations python manage.py migrate
Follow these steps to run the Django Machine Learning API:
-
Make sure your virtual environment is activated (if you created one).
-
Start the development server:
python manage.py runserver
-
The API will now be accessible locally at
http://localhost:8000/
. Use a tool like Postman to send requests to the API endpoints.
- Endpoint:
/file/upload/
- Method:
POST
- URL:
http://localhost:8000/file/upload/
- Headers:
key: X-API-Key
,value: Your API Key
- Request Format:
- The API expects an RGB image (squared for best results).
- The following fields should be provided in the body:
key: file
,value: your image file
key: type
,value: fruit or leaf
key: name
,value: if fruit, write 'none'. If leaf, write the name of the plant with the first letter in uppercase and in singular form (e.g., Potato). If the name is composed, write both first letters in uppercase separated by an underscore (e.g., Bell_Pepper)
.
- Response Format:
- The API will return a JSON response containing the 3 best results.
- Each result will have the following keys:
key: name
,value: plant_name
key: condition
,value: healthy or disease name
key: type
,value: fruit or leaf
To obtain your API Key
, visit www.plantai.com or your local host after running the server locally.
Contributions are welcome! If you'd like to contribute to the Django Machine Learning API project, please follow these steps:
-
Fork the repository on GitHub.
-
Create a new branch with a descriptive name:
git checkout -b <branch_name>
-
Make your desired changes to the codebase.
-
Commit your changes:
git commit -m "<commit_message>"
-
Push the changes to your forked repository:
git push origin <branch_name>
-
Open a pull request on the original repository and describe your changes.