??AI for Cannabis: Detection and Classification of Cannabis Seeds ??
Cannabis cultivation is subject to strict regulations, particularly concerning the chemical composition of the plant, specifically THC content. Accurate detection and classification of cannabis seeds help ensure compliance with legal thresholds for THC, particularly distinguishing between industrial hemp (low THC) and marijuana (high THC).
In regions where cannabis is legalized for medicinal or recreational use, seed detection can help authorities and producers comply with legal standards.
The cannabis industry relies heavily on product quality and consistency. Detecting and classifying cannabis seeds accurately helps maintain seed purity, which is essential for producing crops with consistent characteristics. This is important for both recreational and medicinal cannabis, where specific strains are cultivated for desired effects or therapeutic properties.
Cannabis is a genetically diverse plant with numerous subspecies, each offering different medicinal and psychoactive effects. Accurately identifying and classifying seeds based on their variety ensures that the genetic integrity of a strain is maintained across generations, which is crucial for breeding programs and the development of new strains.
To develop seed detection and classification models the following research approaches were considered:
Overview of Today's Research Paper
The study presented by a research team from United States ???? two month ago in the paper "Detection and Classification of Cannabis Seeds Using RetinaNet and Faster R-CNN" outlines a deep learning approach to detect and classify 17 varieties of cannabis seeds using advanced models such as RetinaNet and Faster R-CNN. The study utilized a dataset of 3,319 high-resolution images of cannabis seeds and compared the performance of different object detection models to automate seed classification, which has traditionally been labour-intensive and error-prone.
In the figure above: the process includes data annotation, dataset splitting, and augmentation. The object detection model uses classification and regression layers for seed variety identification and bounding box prediction. Performance is evaluated using IoU, mAP, recall, and F1 score for both detection and classification tasks.
In the figure above: The diagram illustrates the bottom–up pathway (stages 1–4) and the top–down pathway (C2–C4) with 3 × 3 convolution layers producing feature maps P2, P3, and P4. The 2x upsampling block integrates features, resulting in predictions for the input image containing cannabis seeds.
In the figure below: The input image undergoes feature extraction via a ResNet backbone, producing a high-dimensional feature map. This map is subsequently processed by the region proposal network (RPN), which employs sliding window mechanisms to propose candidate object regions. These regions are refined through bounding box regression and softmax classification within the Faster R-CNN module, culminating in precise object detection predictions.
1. Dataset Composition
The dataset consisted of 3,319 high-resolution images, categorized into 17 different cannabis seed varieties. The images were captured using an iPhone 13 Pro and annotated with bounding boxes using the Grounding DINO model to automate the labelling process.
Seed varieties included:
The image counts per variety was variable, ranging from 49 to 554 images.
In the figure above: The seeds, ranging from 2 to 5 mm in size, include (a) AK47, (b) Gelato, (c) Gorilla Purple, (d) KDKT, and (e) Sour Diesel Auto.
In the figure above: the high-resolution images (3024 × 4032 pixels, 72 dpi) display cannabis seeds with bounding boxes annotated for object detection. The precise annotations facilitate the training and evaluation of detection models, capturing seeds typically ranging from 2 to 5 mm in size.
2. Model Architectures
The study compared two prominent deep learning models for object detection: RetinaNet (a one-stage detector) and Faster R-CNN (a two-stage detector).
3. Performance Metrics
Inference Speed: The RetinaNet models processed around 14.5–16.1 frames per second (FPS), while the Faster R-CNN with a ResNeXt101 backbone achieved the fastest processing speed of 17.5 FPS.
Per-Class Performance: The models showed varying performance across the 17 cannabis seed varieties, with certain models excelling in specific classes, e.g., RetinaNet was more accurate for complex seeds like 'AK47', 'Gorilla Purple', and 'Sour Diesel Auto'.
In the figure above: Top row: KKV seeds. Bottom row: SDA seeds. From left to right: ground truth, predictions from RetinaNet with ResNet50 backbone, ResNet101 backbone, and ResNeXt101 backbone. KKV seeds are shown in orange, and SDA seeds are shown in red. The ResNet101 backbone demonstrates superior performance across both classes.
In the figure above: The models’ predictions are shown along with the ground truth labels. BBA seeds are shown in blue, and SKA seeds are shown in red.
4. Data Augmentation
Data augmentation techniques, such as random horizontal/vertical flips, colour adjustments, and blur operations, were applied to improve the model's ability to generalize to unseen data, which was crucial for the training process.
5. Experimental Setup
Both RetinaNet and Faster R-CNN were trained for 100 epochs using the stochastic gradient descent (SGD) optimizer. Learning rates were set at 0.02 for Faster R-CNN and 0.01 for RetinaNet.
Different loss functions were applied to enhance the training, with RetinaNet using Focal Loss and L1 loss for regression, while Faster R-CNN used cross-entropy and IoU loss for classification and bounding box regression.
6. Comparison with Previous Work
This study extended the authors’ previous work, which focused solely on Faster R-CNN with a ResNet50 backbone, by adding RetinaNet and additional backbone architectures, offering a more comprehensive evaluation of state-of-the-art methods.
RetinaNet improved upon the previous mAP scores and added deeper insights into performance-speed trade-offs, making it more suitable for real-world cannabis seed detection applications.
Citation
Islam, T.; Sarker, T.T.; Ahmed, K.R.; Lakhssassi, N. Detection and Classification of Cannabis Seeds Using RetinaNet and Faster R-CNN. Seeds 2024, 3, 456-478. https://doi.org/10.3390/seeds3030031
What's on
If you'd like to receive the regular 'AI in Agriculture' newsletter in your inbox, simply add your email to my mailing list.
AI for Cannabis Phenotyping and Quality Assurance
To get more information about crop phenotyping capabilities with mobile - ask Petiole Pro
Research Assistant @SIU | PhD Student | Computer Vision
1 周Thank you Maryna Kuzmenko, Ph.D ???? for featuring our work.
Helping Healthtech and Life Sciences SaaS companies to build World-Class sales teams! Let's connect! ?? ???? Ex-sales leader, now sales headhunter and GTM team builder. Family Law Advocate
1 个月As somebody who was in medical cannabis farming for many years I wonder how this technology helps?
Business Development / Agtech / Sustainable Agriculture Irrigation /Vertical Farming / Plant Breeding / Sales / Networker
5 个月Always Informative!
Strategy & Leadership | AI & Digital Transformation | PMP | Product Management | Venture Investments | Military Veteran
5 个月Great analysis! Thank you! I will be conducting my field experiments next season:-)
Data scientist | AI & ML engineer | EdTech | AgriTech | Google WTM Ambassador | Global Ambassador at WomenTechNetwork
5 个月Very Useful!