Skip to content

a unet model trained for the semantic segmentation of leaf images πŸƒ

License

Notifications You must be signed in to change notification settings

gvil-research/leaf-segmentation-unet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

leaf-segmentation-unet

a unet model trained for the semantic segmentation of leaf images

folder structure

.
β”œβ”€β”€ 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

output samples

1 2 3

input images are from the dataset of Plant Pathology 2021 Challenge

instructions

train from scratch

  • prepare dataset

    linux users can run get_dataset.sh instead of first three steps

    1. cd into ./preprocess

    2. download DenseLeaves.zip from here

    3. unzip the downloaded file as ./preprocess/DenseLeaves/

    4. 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 epoch
  • best_val_weights.pth - weights saved when the model obtained minimum validation loss

use pretrained (prediction)

  • 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

acknowledgement

  • DenseLeaves dataset - Michigan State University visit
  • Plant Pathology 2021 dataset - Kaggle

update log

2021-06-24: first code upload, most of the code is really bad (I wrote them a while ago). I shall refactor them soon.

Releases

No releases published

Packages

No packages published