AI in Dermatology
Skin Lesion Classification
ABCDE Criteria
| Criterion | Description | AI Feature |
|---|---|---|
| Asymmetry | Asymmetric shape | Symmetry score |
| Border | Irregular borders | Border irregularity |
| Color | Multiple colors | Color variance |
| Diameter | > 6mm | Size measurement |
| Evolution | Changing over time | Temporal analysis |
import torchvision.models as models
class SkinLesionClassifier(nn.Module):
def __init__(self, n_classes=7):
super().__init__()
self.backbone = models.inception_v3(pretrained=True)
self.backbone.fc = nn.Sequential(
nn.Linear(2048, 512), nn.ReLU(), nn.Dropout(0.5),
nn.Linear(512, n_classes))
def forward(self, x):
return self.backbone(x)
CLASSES = ['Melanoma', 'Nevus', 'Basal Cell', 'Actinic Keratosis',
'Benign Keratosis', 'Dermatofibroma', 'Vascular Lesion']
Melanoma Detection
Grad-CAM Explainability
class GradCAM:
def generate_heatmap(self, input_image, class_idx):
output = self.model(input_image)
output[0, class_idx].backward()
gradients = self.model.get_gradient()
weights = torch.mean(gradients, dim=[2, 3], keepdim=True)
cam = torch.relu(torch.sum(weights * self.model.get_activation(), dim=1))
return cam / cam.max()