This repository contains the code for training and evaluating a UNet model for coffee leaf rust segmentation. The model is trained using the COFFEE dataset and can be used to segment coffee leaf rust from images, and many other datasets.
The COFFEE dataset is organized into three main directories: train, val, and test. Each directory contains subdirectories for images and masks. The images are in JPG format, and their corresponding masks are in PNG format. The masks are binary images where the regions of interest are represented as white (pixel value 255) and the background as black (pixel value 0). the dimensions used are 224*224px.
- Python 3.x
- TensorFlow
- scikit-image
- matplotlib
-
Clone the repository:
git clone https://github.com/username/U-net-for-plant-segmentation.git
-
Navigate to the repository directory:
cd unet-coffee-segmentation
-
Install Dependencies
pip install -r requirements.txt
To train the UNet model, run the train.py script:
python train.py
This script will load the COFFEE dataset, train the model, and save the trained model weights to a file named modelunetcoffee.h5.
To evaluate the trained model on the test dataset, run the evaluate.py script:
python evaluate.py
This script will load the trained model, evaluate its performance on the test dataset, and print the test loss and accuracy.
Coffee dataset :
Plant village (tomato) dataset :
To make predictions using the trained model, you can use the predict.py script:
python predict.py --image_path /path/to/image.jpg
Replace /path/to/image.jpg with the path to the image for which you want to generate a segmentation mask.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to reach out to me if you have any questions or suggestions!