Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Industrial Internet of Things >> Embedded

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

A portable medical device capable of accurately identifying diabetic retinopathy stages without an internet connection could drastically reduce blindness worldwide. With embedded machine learning, algorithms that run directly on battery‑powered hardware are now viable. This article walks through the steps to train such a model using the Edge Impulse platform.

Diabetic retinopathy damages the blood vessels at the back of the eye, often progressing to blindness if untreated. More than two‑in‑five Americans with diabetes have some form of the disease, making early detection critical. In rural areas where vision care is scarce, even mild cases are frequently missed until they become severe.

To address this, we leveraged a publicly available dataset to train a model that can assess DR severity from retinal camera images. The dataset is divided into five classes:

Patient identifiers were replaced with id_code and a diagnosis score from 0 (No DR) to 5 (Proliferative DR). Dataset link.

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

Because the images were stored in a flat structure, I wrote a VBA script to read the Excel list of id_code values, locate each image, and move it into the corresponding class folder. The script is available here. If you prefer Python or another language, similar automation is straightforward.

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

Edge Impulse simplifies ingestion via its data upload interface. I performed five separate uploads—one per class—labeling each folder appropriately. The platform also offers cloud bucket integration and device collection, but manual upload worked best for our dataset.

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

Edge Impulse automatically splits data 80/20 into training and testing sets, but I added ~500 images manually to the test set to better balance the classes.

For the model, I selected the image block and applied a transfer‑learning architecture to classify the five DR stages. Initial training yielded a best accuracy of about 74%, which is respectable but highlights misclassifications—especially between severe and mild DR. The confusion matrix (shown below) illustrates this challenge.

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

In a real‑world deployment, a portable retinal camera would capture an image, run the model locally, and immediately notify the clinician whether the patient requires follow‑up. The priority is to detect all DR stages, so the current accuracy is acceptable for a screening tool.

Possible improvements include:

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

The final model occupies 306 kB of flash and 236 kB of RAM. On a Cortex‑M4 at 80 MHz the inference time ranges from 0.8 s to 6 s, while a Cortex‑M7 at 216 MHz is faster—making it suitable for handheld devices that capture images on the fly.

In summary, we demonstrated that an open‑source dataset can train an effective edge model for diabetic retinopathy detection. Deploying such models on embedded microcontrollers or lightweight Linux devices can bring reliable screening to remote or underserved communities, overcoming connectivity barriers.

Build an Offline AI Model that Detects Diabetic Retinopathy Stages with Edge‑Impulse

Further details and future work are available here.

Embedded

  1. Titanium: From Its 18th‑Century Discovery to Today’s High‑Performance Applications
  2. The Cloud Revolution: How Cloud Computing Transforms IT, Security, and Careers
  3. Leveraging Work Order Data: A Proven Path to Maintenance Excellence
  4. 5 Cutting-Edge Technologies to Detect and Stop Pump Cavitation
  5. Understanding Welding Porosity: Causes, Detection, and Prevention Techniques
  6. 5 Types of Sand Casting Defects & Prevention Strategies
  7. Identifying Key Machine Failure Causes and Strategies to Avoid Downtime
  8. Track & Analyze Machine Downtime: Boost Efficiency & Reduce Costs
  9. Detecting and Preventing Fluid System Leaks: A Comprehensive Guide
  10. Effective Leak Detection and Repair for Industrial Air Systems