CVRP: A Rice Image Dataset with High-Quality Annotations for Image Segmentation and Plant Phenomics Research
Multi-cultivar and multi-view rice plant image dataset (CVRP) consists of 2,303 field images with their annotated masks and 123 indoor images of individual panicles.
Annotation Workflow
To optimize the process of annotation, we combine deep learning methods with manual curation. The workflow comprises two stages: manual annotation and model-based prediction followed by manual curation.
alt text
Getting Started
Recommend python 3.7, CUDA v11.3 and Pytorch 1.10.0.
Clone
1 pip install huggingface_hub
2 huggingface-cli download CVRPDataset/Model --local-dir /your/path/to/save/Model
3 cd Model
4 git clone https://github.com/open-mmlab/mmsegmentation.git -b v1.1.2 mmsegmentation
5
6 pip install -U openmim
7 mim install mmengine
8 mim install mmcv == 2.0 .0
9
10 cd mmsegmentation
11 pip install -v -e .
12 pip install "mmdet>=3.0.0rc4"
UI
We create a web user interface for annotation based on gradio.
1 pip install gradio
2 python app.py
The UI :
Users can upload an image or use a sample image at ①.Then, they can select one of four models at ②. We recommend Mask2Former . After that, click Run .
We provide two forms of segmentation results for download at ③.
alt text
Train and Test
Creating a Dataset
Here is an example if you want to make own dataset.
① Directory structure of the dataset:
📁 CVRPDataset/
├─📁 images/
└─📁 labelme_jsons/
② Convert labelme files to mask:
python run/labelme2mask.py
now, the structure looks like:
📁 CVRPDataset/
├─📁 img_dir/
└─📁 ann_dir/
③ Split the training set and test set.
python run/split_dataset.py
now, the structure looks like:
📁 CVRPDataset/
├─📁 img_dir/
│ ├─📁 train/
│ └─📁 val/
└─📁 ann_dir/
├─📁 train/
└─📁 val/
If you have annotations in RGB format, you need
and then follow split the train set and evaluation set according to the format in ③.
You can also download our training set and validation set
here .
Dataset Configs
1 cd mmsegmentation/mmseg/datasets
2 rm -rf __init__.py # delete original file
3 wget https://huggingface.co/CVRPDataset/Model/resolve/main/dataset_configs/CVRP.py
4 wget https://huggingface.co/CVRPDataset/Model/resolve/main/dataset_configs/__init__.py
5 cd .. / .. /configs/_base_/datasets
6 wget https://huggingface.co/CVRPDataset/Model/resolve/main/dataset_configs/CVRP_pipeline.py
① If you want to register your own dataset, import and register datasets in mmseg/datasets/__init__.py
from .CVRP import CVRPDataset
Add,
1 # other datasets
2 __all__ = [ 'CVRPDataset' ]
② Register dataset class in `mmseg/datasets/CVRP.py'
1 class CVRPDataset ( BaseSegDataset ) :
2 METAINFO = {
3 'classes' : [ 'background' , 'panicle' ] ,
4 'palette' : [ [ 127 , 127 , 127 ] , [ 200 , 0 , 0 ] ]
5 }
③ Modify pipeline of data process in config/_base_/datasets/CVRP_pipeline.py
1 dataset_type = 'CVRPDataset'
2 data_root = 'CVRPDataset/'
you'll need to specify the paths for the train and evalution data directories.
1 # train_dataloader:
2 data_prefix = dict ( img_path = 'img_dir/train' , seg_map_path = 'ann_dir/train' )
3 # val_dataloader:
4 data_prefix = dict ( img_path = 'img_dir/val' , seg_map_path = 'ann_dir/val' )
Model Configs
You can generate model config files using run_configs.py
1 cd mmsegmentation
2 mkdir 'work_dirs' 'CVRP_configs' 'outputs' 'CVRPDataset'
3 python .. /run/run_configs.py --model_name deeplabv3plus -m configs/deeplabv3plus/deeplabv3plus_r101-d8_4xb4-160k_ade20k-512x512.py -d configs/_base_/datasets/CVRP_pipeline.py -c 2 -w work_dirs -s CVRP_configs
4
5 python .. /run/run_configs.py --model_name knet -m configs/knet/knet-s3_swin-l_upernet_8xb2-adamw-80k_ade20k-512x512.py -d configs/_base_/datasets/CVRP_pipeline.py -c 2 -w work_dirs -s CVRP_configs
6
7 python .. /run/run_configs.py --model_name mask2former -m configs/mask2former/mask2former_swin-l-in22k-384x384-pre_8xb2-160k_ade20k-640x640.py -d configs/_base_/datasets/CVRP_pipeline.py -c 2 -w work_dirs -s CVRP_configs
8
9 python .. /run/run_configs.py --model_name segformer -m configs/segformer/segformer_mit-b5_8xb2-160k_ade20k-512x512.py -d configs/_base_/datasets/CVRP_pipeline.py -c 2 -w work_dirs -s CVRP_configs
Also, you can download model config files
here .
1 cd CVRP_configs
2 wget https://huggingface.co/CVRPDataset/Model/resolve/main/model_configs/CVRP_mask2former.py
Train
1 cd mmsegmentation
2 python tools/train.py CVRP_configs/CVRP_mask2former.py
Also, you can download checkpoint
here .
1 cd work_dirs
2 mkdir CVRP_mask2former
3 cd CVRP_mask2former
4 wget https://huggingface.co/CVRPDataset/Model/resolve/main/checkpoint/Mask2Former.pth
Test
python ../run/test.py -d CVRPDataset/val -m CVRP_configs/CVRP_mask2former.py -pth work_dirs/CVRP_mask2former/Mask2Former.pth -o outputs/CVRP_mask2former
LabelMe
If you need to manually adjust the annotation, you can use LabelMe.
1 python run/mask2json.py
2 pip install labelme == 3.16 .7
3 labelme
Data and Code Availability
The CVRP dataset and accompanying codes are publicly available from Hugging Face at
https://huggingface.co/datasets/CVRPDataset/CVRP &
https://huggingface.co/CVRPDataset/Model ,
and Bioinformatics service in Nanjing Agricultural University at
http://bic.njau.edu.cn/CVRP.html .
Acknowledgements
We thank Mr.Zhitao Zhu, Dr. Weijie Tang, and Dr. Yunhui Zhang for their technical support.