This repository contains detailed information on our IEEE RA-L paper entitled AV4GAINsp: An Efficient Dual-Camera System for Identifying Defective Kernels of Cereal Grains.
All codes are stored in src
folder, and the detailed train and test scripts can be found in the corresponding sub-folder README.md:
- recognition (The recognition code of our proposed three-stage framework, thanks for TASN providing the trilinear attention code)
- mmdetection (Faster RCNN, YoloX, Mask RCNN, RTMDet)
- SAM
Please read src/eval/README.md
.
-
For single-kernel images, the dataset (processed oriented and single-kernel images) can be found (below).
-
For raw images, we have provided XML files in VOC format and JSON files in COCO format. It should be noted that the XML file corresponds to annotations for a single image, while the JSON file corresponds to annotations for two sides combined.You can also convert XML files to JSON files through
parsexml.py
andmakecoco.py
.
- Recognition: google drive (450M) including training checkpoints.
- Faster R-CNN: google drive (960M) including training checkpoints.
- YoloX: google drive (870M) including training checkpoints.
- Mask R-CNN: google drive (1G) including training checkpoints.
- RTMDet: google drive (1.2G) including training checkpoints.
- SAM: google drive (1.G) including training checkpoints.
- Sample Collection
- Crops are harvested and transported into the grain centers
- Raw grains are sampled to extract laboratory samples
- Laboratory samples are further pre-processed by using handed tools, such as sieves, fans, tweezers
- Image Acquisition
- Grain kernels are fed into our device
- Our framework can produce a number of single-kernel images
- Image Annotation (during using our device, this stage is replaced by our Recognition model)
- single-kernel images are annotated by six human experts
Feeding | Transporting | Capturing | Recycling | |
---|---|---|---|---|
Paper | ![]() |
![]() |
![]() |
![]() |
GIF | ![]() |
![]() |
![]() |
![]() |
-
$I_{up}$ and$I_{do}$ are fed into our three-stage framework- 1,
$I_{up}$ and$I_{do}$ are tiled into 15 overlapping patches, with each patch having 1500$\times$1500 pixels. - 2, Two raw images can produce a total of 30 patches
- 1,
-
Stage-Detection:
- 1, Each patch is fed into an object detection model (
$\phi_{d}$ , YoloX only doing detection without classification) to detect all kernel images - 2, All patches from
$I_{up}$ can obtain$M_{up}$ kernel images that are saved into UPDetRes - 3, All patches from
$I_{do}$ can obtain$M_{do}$ kernel images that are saved into DoDetRes
- 1, Each patch is fed into an object detection model (
-
Stage-Pair:
- All kernels in UPDetRes and DoDetRes are paired according to their centroid position and spatial distance, obtaining
$M=\max(M_{up},M_{do})$ single-kernel images, with each single-kernel image has two views
- All kernels in UPDetRes and DoDetRes are paired according to their centroid position and spatial distance, obtaining
-
Stage-Recognition:
- 1, Two views in a single-kernel images are horizontally merged into an image
- 2, Image is fed into the classification model (
$\phi_{c}$ , ResNet with imbalanced losses)
- We employ our framework (stage: detection and pair) to generate a vast number of candidate single-kernel images, and these images are used for building high-quality dataset: GrainDet.
- we have engaged a team of six experienced annotators:
-
- Four senior inspectors with 5-10 years of inspection experience and currently working in authoritative quality inspection centers;
-
- Two experts with over 10 years of experience and holding leadership positions in the quality inspection center, who are also involved in the development of several national standards related to cereal grains.
-
- The annotation for each kernel involves multiple steps to ensure consistency and accuracy:
-
- If all 4 senior inspectors assign the same label, then the label is confirmed (more than 99.9% of kernels are annotated in this step);
-
- In case where 3 of 4 senior inspectors assign the same label, then two experts are consulted to reach a final agreement and confirm the label;
-
- The remaining images are discarded.
-
- To maintain the high quality of our dataset, we exclusively include samples from step1 and step2 samples in our GrainDet.
Our dataset, called GrainDet, involves three types of cereal grains: wheat, rice and sorghum.
- For wheat data, we annotated about
$80K$ single-kernel images, including$48K$ normal grains and$32K$ images for six types of defective grains and impurities. - For rice data, we annotated about
$24K$ single-kernel images, including$15K$ normal grains and$9K$ images for six types of defective grains and impurities. - For sorghum data, we annotated about
$40K$ single-kernel images, including$24K$ normal grains and$16K$ images for six types of defective grains and impurities..
Species | Category | Abbreviation |
---|---|---|
Wheat, Rice, Sorghum | Normal grains | NOR |
Wheat, Rice, Sorghum | Sprouted grains | SD |
Wheat, Rice, Sorghum | Fusarium & Shrivele grains | F&S |
Wheat, Rice, Sorghum | Broken grains | BN |
Wheat, Rice, Sorghum | Grains attacked by pests | AP |
Wheat, Rice, Sorghum | Impurities | IM |
Wheat | Black point grains | BP |
Rice | Unripe grains | UN |
Sorghum | Heated grains | HD |
NOR | SD | FS | BP/HD/UN | MY | BN | AP | IM | |
---|---|---|---|---|---|---|---|---|
Wheat | ![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
Rice | ![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
Sorghum | ![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
NOR | SD | FS | BP/HD/UN | MY | BN | AP | IM | Total | |
---|---|---|---|---|---|---|---|---|---|
Wheat | 48.1K | 5.1k | 5.1k | 1.4k | 5.2k | 5.8k | 5.2k | 4k | 80K |
Rice | 16k | 1.1k | 1.2k | 1.2k | 1.2k | 1.2k | 1.2k | 1.6k | 24.7K |
Sorghum | 24k | 3.6k | 1.4k | 0.2k | 3.6k | 3.6k | 3.6k | 1.2k | 41K |
- GrainDet-Wheat (80k, 7.6GB), including three folders: train (56K) / val (8K) / test (16K)
- GrainDet-Rice (24.7k, 1.7GB), including three folders: train (17K) / val (2.3K) / test (4.9K)
- GrainDet-Sorghum (41k, 2.4GB), including three folders: train (28.8K) / val (4K) / test (8K)
The script is used for obtaining the confusion matrix and kappa statistics.
calc_kappa.py
- GrainDet-Wheat-Kappa test (12k, 1.2GB), including three folders: train (28.8K) / val (4K) / test (8K)
If our paper has been of assistance, we would appreciate it if you could consider citing it in your work.
@article{fan2023av4gainsp,
title={AV4GAInsp: An Efficient Dual-Camera System for Identifying Defective Kernels of Cereal Grains},
author={Fan, Lei and Ding, Yiwen and Fan, Dongdong and Wu, Yong and Chu, Hongxia and Pagnucco, Maurice and Song, Yang},
journal={IEEE Robotics and Automation Letters},
year={2023},
publisher={IEEE}
}
@inproceedings{fan2022grainspace,
title={GrainSpace: A Large-scale Dataset for Fine-grained and Domain-adaptive Recognition of Cereal Grains},
author={Fan, Lei and Ding, Yiwen and Fan, Dongdong and Di, Donglin and Pagnucco, Maurice and Song, Yang},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={21116--21125},
year={2022}
}
@article{fan2023annotated,
title={An annotated grain kernel image database for visual quality inspection},
author={Fan, Lei and Ding, Yiwen and Fan, Dongdong and Wu, Yong and Chu, Hongxia and Pagnucco, Maurice and Song, Yang},
journal={Scientific Data},
volume={10},
number={1},
pages={778},
year={2023},
publisher={Nature Publishing Group UK London}
}
@incollection{fan2023ai4graininsp,
title={Identifying the Defective: Detecting Damaged Grains for Cereal Appearance Inspection},
author={Fan, Lei and Ding, Yiwen and Fan, Dongdong and Wu, Yong and Pagnucco, Maurice and Song, Yang},
booktitle={ECAI 2023},
year={2023},
publisher={IOS Press}
}