Computer based sexing of Black Soldier flies using deep learning
Computer based sexing of Black Soldier flies using deep learning
Date
2026-02-09
Authors
Asimwe, Samuel
Journal Title
Journal ISSN
Volume Title
Publisher
Makerere university
Abstract
Accurate sex determination of Black Soldier Fly (BSF) larvae is a critical factor in the successful implementation of selective breeding programs, which are essential for scaling BSF farming
as a sustainable solution for organic waste management and protein production. Current sex
determination methods primarily rely on the visual identification of adult flies, a process that is
labor-intensive, prone to human error, and limited by the fragility, small size, and short metamorphic life cycle of BSF larvae. These constraints hinder early-stage selection, ultimately
impacting the efficiency and effectiveness of breeding efforts. To address this challenge, this
project proposes a novel approach utilizing deep learning techniques for non-invasive and accurate sex determination of BSF larvae at an earlier developmental stage.
We developed a computer vision-based system that leverages Convolutional Neural Networks
(CNNs), specifically fine-tuning pre-trained models like ResNet and EfficientNet, to analyze
subtle morphological features in larval images. A dataset of BSF larvae images was collected
using a Raspberry Pi camera under controlled conditions, labeled upon maturation, and preprocessed for model training. The system was trained, optimized, and evaluated using metrics
such as accuracy, precision, recall, and F1-score, achieving a peak validation accuracy of 87%
with EfficientNet-B0, outperforming traditional methods.
The successful implementation of this technology holds the potential to revolutionize BSF
breeding practices by enabling early-stage sex determination, thus optimizing breeding candidate selection, improving colony management, and enhancing productivity in BSF-based
industries. This study contributes to sustainable agriculture by supporting the scalability of
BSF farming, reducing reliance on environmentally damaging protein sources, and promoting
a circular economy through efficient waste valorization. Future work will focus on improving
dataset quality, integrating the system into farm workflows via mobile platforms, and exploring
hybrid approaches combining deep learning with traditional image processing for enhanced
robustness.
This project also highlights the interdisciplinary nature of modern engineering challenges,
bridging electrical engineering, computer science, and agricultural science to address pressing global issues. By leveraging advancements in artificial intelligence, we aim to provide
a scalable solution that can be adopted by BSF farms worldwide, contributing to the United
Nations’ Sustainable Development Goals, particularly in the areas of responsible consumption
and production (SDG 12) and climate action (SDG 13
Description
A project report submitted to the College of Engineering Design and Art in partial fulfillment of the requirement for the award of the degree Bachelor of Science Electrical Engineering of Makerere University.
Keywords
Computer vision,
Sexing,
Black Soldier flies,
Deep learning
Citation
Asimwe, Samuel. (2026). Computer based sexing of Black Soldier flies using deep learning. (Unpublished undergraduate Project Report) Makerere University; Kampala, Uganda.