a unet model trained for the semantic segmentation of leaf images
.
βββ dataset
βΒ Β βββ note.md
βββ model
βΒ Β βββ pretrained
βΒ Β βΒ Β βββ download.md
βΒ Β βββ __init__.py
βΒ Β βββ model.py
βββ preprocess
βΒ Β βββ generate_dataset.py
βΒ Β βββ __init__.py
βΒ Β βββ README.md
βββ test
βΒ Β βββ get_testset.sh
βββ utilities
βΒ Β βββ __init__.py
βΒ Β βββ utility.py
βββ get_dataset.sh
βββ get_pretrained.sh
βββ LICENSE
βββ predict.py
βββ README.md
βββ requirements.txt
βββ train.py
input images are from the dataset of Plant Pathology 2021 Challenge
-
prepare dataset
linux users can run
get_dataset.sh
instead of first three steps-
cd into
./preprocess
-
download
DenseLeaves.zip
from here -
unzip the downloaded file as
./preprocess/DenseLeaves/
-
run
python generate_dataset.py
The newly processed dataset is now saved at
./dataset
-
-
cd back to project root and run
python train.py
to train the model
When training, the model saves the weights in the ./model/pretrained
model.
latest_weights.pth
- weights saved at the end of the last epochbest_val_weights.pth
- weights saved when the model obtained minimum validation loss
- download pretrained weights
linux users can run get_pretrained.sh
(make sure gdown
is installed -- pip install gdown
)
others can download the weights from links provided in this file
- specify test image location
edit the TEST_DIR
variable in predict.py
to specify custom images or download a sample dataset by running get_testset.sh
in ./test
folder.
tip: if the segmentation results are not satisfactory, modify the mask threshold values in
predict.py
file
- DenseLeaves dataset - Michigan State University visit
- Plant Pathology 2021 dataset - Kaggle
2021-06-24: first code upload, most of the code is really bad (I wrote them a while ago). I shall refactor them soon.