Editing
Ai Ophthalmology
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Diabetic retinopathy grading from fundus images:''' <syntaxhighlight lang="python"> import torch import torch.nn as nn from torchvision import models, transforms from torch.utils.data import Dataset, DataLoader from PIL import Image import pandas as pd import numpy as np from sklearn.metrics import cohen_kappa_score, roc_auc_score class RetinalDataset(Dataset): """Retinal fundus image dataset for DR grading.""" DR_GRADES = {0: 'No DR', 1: 'Mild', 2: 'Moderate', 3: 'Severe', 4: 'Proliferative'} def __init__(self, df, transform=None): self.df = df self.transform = transform def __len__(self): return len(self.df) def __getitem__(self, idx): row = self.df.iloc[idx] img = Image.open(row['image_path']).convert('RGB') if self.transform: img = self.transform(img) return img, int(row['dr_grade']) # EfficientNet-B4 for DR grading (strong baseline) transform = transforms.Compose([ transforms.Resize(380), transforms.CenterCrop(380), transforms.RandomHorizontalFlip(), transforms.RandomVerticalFlip(), transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ]) model = models.efficientnet_b4(weights='IMAGENET1K_V1') model.classifier[1] = nn.Linear(model.classifier[1].in_features, 5) # 5 DR grades # Ordinal classification loss (preserves grade ordering) class OrdinalLoss(nn.Module): """Convert ordinal regression to K-1 binary classifiers.""" def __init__(self, n_classes=5): super().__init__() self.n_classes = n_classes def forward(self, logits, targets): cumulative_targets = torch.zeros(len(targets), self.n_classes - 1) for i, t in enumerate(targets): cumulative_targets[i, :t] = 1 # 1 for all grades β€ target return nn.BCEWithLogitsLoss()(logits[:, :-1], cumulative_targets.to(logits.device)) criterion = OrdinalLoss(n_classes=5) optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4, weight_decay=1e-2) # Key metric: quadratic weighted kappa (Kaggle DR competition metric) def quadratic_kappa(y_true, y_pred): return cohen_kappa_score(y_true, y_pred, weights='quadratic') </syntaxhighlight> ; Ophthalmology AI tools : '''Commercial DR screening''' β IDx-DR (Digital Diagnostics), Eyenuk EyeArt, Retinalyze : '''Multi-disease screening''' β DeepMind Streams (now Verily), Notal Vision : '''AMD/OCT analysis''' β Heidelberg HEYEX AI, Zeiss CIRRUS AI : '''Glaucoma''' β Glaukos AI, Ora ClinicalEdge, Optomed Aurora : '''Datasets''' β EyePACS (1M+ images), Kaggle DR, DRIVE, ORIGA, REFUGE </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information