Skip to content

stevefoy/DeepTurfSynth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turfgrass analysis in PyTorch

MIT License PRs Welcome

PyTorch implementation for our paper titled: Assessment of Synthetic Turfgrass Dataset Generation for Divot Detection. If you find this code useful in your research, please consider citing

Requirements

Conda was used, config as follows:

pip install -r requirements.txt

or for a local installation

pip install --user -r requirements.txt

###manual install conda create enviroment conda install -c conda-forge pytorch-gpu Note: Add opencv via torchvision, I had issues on mid training crashes on dataloader code conda install torchvision

Main Features

  • This code base is build on the shoulders of giants, please see Acknowledgement below
  • A json config file with a lot of possibilities for parameter tuning,
  • Supports various models, losses, Lr schedulers, data augmentations and datasets,

So, what's available ?

Models in code used

  • (Deeplab V3+) Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation [Paper]
  • (GCN) Large Kernel Matter, Improve Semantic Segmentation by Global Convolutional Network [Paper]
  • (UperNet) Unified Perceptual Parsing for Scene Understanding [Paper]
  • (DUC, HDC) Understanding Convolution for Semantic Segmentation [Paper]
  • (PSPNet) Pyramid Scene Parsing Network [Paper]
  • (ENet) A Deep Neural Network Architecture for Real-Time Semantic Segmentation [Paper]
  • (U-Net) Convolutional Networks for Biomedical Image Segmentation (2015): [Paper]
  • (SegNet) A Deep ConvolutionalEncoder-Decoder Architecture for ImageSegmentation (2016): [Paper]
  • (FCN) Fully Convolutional Networks for Semantic Segmentation (2015): [Paper]

Datasets

Various datasets, each has it own dataloader code.

  • CityScapes: First download the images and the annotations (there is two types of annotations, Fine gtFine_trainvaltest.zip and Coarse gtCoarse.zip annotations, and the images leftImg8bit_trainvaltest.zip) from the official website cityscapes-dataset.com, extract all of them in the same folder, and use the location of this folder in config.json for training.
  • Sugar beet:
  • Clover Weed:
  • Our Synthetic Turfgrass dataset https://www.zenodo.org/record/8030582
  • Our real Trufgrass: Release TBC

Train and Test

To Train the network use the following, note the configs folder contains all the configuration used.

python train.py --config ./configs/XXXXXX.json 

Resume on the .pth chekpoints.

python train.py --config config.json --resume ./saved/XXProjectXX/best_model.pth --eval true

tensorboard was stable in pyTorch 2 but it vey system dependant. Need to install tensorboard

tensorboard --logdir saved

Data augmentation

Data augmentations are implemented here \base\base_dataset.py

  • Note: class BaseDataSet(Dataset)
  • Transforms.ColorJitter(brightness=0.xxx, contrast=0.xxx, saturation=0.xx, hue=0)]
  • The current ROI in this repo is set to 400x400 pixels
  • Analysis is done outside of this repo on the data to select augmentation parms.
  • Augmentation of the dataset are saved in augmentation folder see config files

Code structure

The code structure is based on pytorch-template

pytorch-template/
│
├── train.py - main script to start training
├── trainer.py - the main trained
│
│
├── dataloader/ - loading the data for different segmentation datasets
│
├── models/ - contains models for paper here
│
├── configs/ - contains configs files for training and test for paper here
│
├── saved/
│   ├── runs/ - trained models are saved here
│   └── log/ - default logdir for tensorboard and logging output
│
├── base/ - abstract base classes
│   ├── base_data_loader.py
│   ├── base_model.py
│   ├── base_dataset.py - All the data augmentations are implemented here
│   └── base_trainer.py
│  
└── utils/ - small utility functions
    ├── losses.py - losses used in training the model
    ├── metrics.py - evaluation metrics used
    └── lr_scheduler - learning rate schedulers 

ToDo List

  • Baseline pytorch import
  • Conda env setup with repo
  • Test pspnet, enet , deeplabv3 on cityscapes
  • Add sugarbeet dataset pipeline
  • Add grassclover dataset pipeline
  • Add synthetic dataset pipeline
  • Add real dataset pipeline
  • Google colab training tested and worked
  • conda env
  • docker support with

Acknowledgement

Cite

@inproceedings{IMVIP2023,
    author = {Stephen Foy and Simon McLoughlin},
    title = {Assessment of Synthetic Turfgrass Dataset Generation for Divot Detection},
    booktitle = {Irish Machine Vision and Image Processing Conference Proceedings 2023},
    editor = {Peter Corcoran},
    year = {2023},
    address = {Galway, Ireland},
    publisher = {Irish Pattern Recognition and Classification Society},
    isbn = {978-0-9934207-8-8},
    pages = {9-16},
}