Blog
How to Build: Custom Model Training for Diabetic Retinopathy Screening on Tablets using Clarion TM-7200-24 Medical AIO PC
Teguar Engineering Team · August 18, 2025
An engineering guide showing how to implement custom model training for diabetic retinopathy screening on tablets on Teguar's purpose-built Clarion TM-7200-24 Medical AIO PC with computer vision & model training.
Diabetic retinopathy is a leading cause of vision loss worldwide. Early screening through fundus photography can prevent blindness, but clinics often struggle to analyze scans quickly due to specialist shortages. Building custom machine learning models trained locally allows clinics to classify eye scans automatically.
This engineering guide outlines how to preprocess fundus scan datasets and train custom convolutional models on Teguar's Clarion TM-7200-24 Medical AIO PC, exportable for deployment to tablets at outpatient hubs.
Hardware Platform: Clarion TM-7200-24 Medical AIO PC
Model training requires intensive computing capacity and accurate, high-fidelity screens.
- 24" High-Contrast IPS Display: Crucial for verifying fine retinal structures, hemorrhages, and lesions on fundus scans.
- Sealed IP65 Front Glass: Chemical-resistant surface protects against clinical cleaning liquids.
- Compute Power: Supports multi-core processors and expandable RAM, allowing local training runs without cloud compute bills.
Training & Deployment Workflow
+---------------------------------------------------------------------------------+
| Clarion TM-7200-24 Medical AIO PC |
| |
| +--------------------+ +--------------------+ +--------------------+ |
| | Retinal Fundus | ---> | Preprocessing | --> | Local CNN Training | |
| | Dataset (Local) | | (Normalization) | | (PyTorch/Tensorflow| |
| +--------------------+ +--------------------+ +---------+----------+ |
| | |
| v |
| +---------+----------+ |
| | ONNX / TFLite | |
| | Optimization | |
| +---------+----------+ |
| | |
| v |
| +---------+----------+ |
| | Edge Deployment to |
| | Clinical Tablets | |
| +--------------------+ |
+---------------------------------------------------------------------------------+
Code Walkthrough
Step 1: Install PyTorch and Torchaudio
pip install torch torchvision numpy pandas opencv-python scikit-learn
Step 2: Data Preprocessing
Retinal fundus images are cropped and normalized to highlight microaneurysms.
import cv2
import torch
from torchvision import transforms
from PIL import Image
# High-resolution image normalization transforms
preprocess = transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
def preprocess_fundus_image(img_path):
img = cv2.imread(img_path)
# Apply green-channel extraction to increase blood vessel contrast
b, g, r = cv2.split(img)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
enhanced_g = clahe.apply(g)
merged = cv2.merge([b, enhanced_g, r])
pil_img = Image.fromarray(cv2.cvtColor(merged, cv2.COLOR_BGR2RGB))
return preprocess(pil_img).unsqueeze(0)
Step 3: Model Definition and Local Training Loop
We define a ResNet-based binary classifier to distinguish healthy retinas from those with signs of retinopathy.
import torch.nn as nn
from torchvision.models import resnet18, ResNet18_Weights
def get_retinopathy_model():
# Load ResNet model
model = resnet18(weights=ResNet18_Weights.DEFAULT)
num_ftrs = model.fc.in_features
# Binary output: 0 - Normal, 1 - Retinopathy detected
model.fc = nn.Linear(num_ftrs, 2)
return model
def train_one_epoch(model, dataloader, optimizer, criterion):
model.train()
running_loss = 0.0
for images, labels in dataloader:
optimizer.zero_grad()
outputs = model(images)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
running_loss += loss.item() * images.size(0)
return running_loss / len(dataloader.dataset)
Step 4: Exporting Model to ONNX for Mobile Tablets
After training on the Clarion PC, we export the model weights to ONNX format to deploy on portable clinics.
def export_to_onnx(model, save_path="retinopathy_classifier.onnx"):
model.eval()
dummy_input = torch.randn(1, 3, 256, 256)
torch.onnx.export(
model,
dummy_input,
save_path,
input_names=["input"],
output_names=["output"],
dynamic_axes={"input": {0: "batch_size"}, "output": {0: "batch_size"}}
)
print(f"Model exported to {save_path} for mobile deployment.")
Deployment Guidelines
- Mobile Inference: Deploy the exported ONNX model on target tablets using
ONNX Runtime Mobile. This allows tablets to run classification predictions locally in under 100ms. - Regular Model Audits: Check screening results against clinical diagnoses periodically to detect potential classification drift.
Conclusion
Teguar's Clarion TM-7200-24 AIO PC serves as an excellent clinical workstation, capable of training and optimizing custom screening models to deploy diagnostic capabilities to remote clinics.