An API that returns whether a plant has a desease based on leaf images from this Kaggle challenge. The CV models can be easily trained and used for inference. FastAPI is used as web framework for building the API.
Download the dataset from here and put it into the following folder structure:
plant_detection
│
└───dataset
│
└───test
│ │ AppleCedarRust1.JPG
│ │ AppleCedarRust2.JPG
│ │ ...
│
└───train
│ │
│ └───Apple__Apple_scab
│ └───Apple__Apple_rot
│ └───...
│
└───valid
│ │
│ └───Apple__Apple_scab
│ └───Apple__Apple_rot
│ └───...
Create a new virtual environment first by executing make setup
. Secondly, install Node.js for
running the application. However, this is not required if you want to use the API only.
Making predictions for new images requires trained model files within /models
. You can execute the training script
python run.py
for training the models defined within src/models.py
. By default the batch size is 100 and the amount of epochs equals 20.
Feel free to adjust the parameters and models as you desire.
Within the project root directory run the API within you CLI as follows:
uvicorn api:api --reload
Access FastAPI UI by open your browser at http://127.0.0.1:8000/docs. Open the POST method tab and click on Try it out. You can manipulate the JSON request body as you desire.
The default JSON request body:
{
"model_path": "./models/my_cnn'",
"img_path": ",./dataset/test/PotatoHealthy1.JPG"
}
To host the dashboard and API locally run the following command within project root directory:
make run_dev
The dashboard should start at http://localhost:5000/, while the API is running at http://localhost:8000/. To interact with the API only check out the previous section.