Views
No views yet
pip install torch torchvision timm albumentations pytorch-lightning1from retinaradar import RetinaRadarInference
2
3# Initialize model
4inferencer = RetinaRadarInference(
5 model_path="retinaradar_model.ckpt",
6 device="cuda" # or "cpu"
7)
8
9# Run inference
10predictions = inferencer.predict("path/to/fundus_image.jpg")
11
12# Access results
13print(f"Laterality: {predictions['laterality']['label']}")
14print(f"Image usable: {predictions['usable']['prediction']}")1import torch
2from PIL import Image
3import albumentations as A
4from albumentations.pytorch import ToTensorV2
5
6# Load model
7model = torch.load("retinaradar_model.ckpt")
8model.eval()
9
10# Preprocessing
11IMAGENET_MEAN = [0.485, 0.456, 0.406]
12IMAGENET_STD = [0.229, 0.224, 0.225]
13
14transform = A.Compose([
15 A.Resize(256, 256),
16 A.CenterCrop(224, 224),
17 A.Normalize(mean=IMAGENET_MEAN, std=IMAGENET_STD),
18 ToTensorV2(),
19])
20
21# Load and preprocess image
22image = Image.open("fundus_image.jpg")
23image = np.array(image)
24transformed = transform(image=image)
25image_tensor = transformed["image"].unsqueeze(0)
26
27# Run inference
28with torch.no_grad():
29 logits = model(image_tensor)
30 probabilities = torch.sigmoid(logits)
31
32# Get predictions
33predictions = probabilities > 0.5| Category | Accuracy | F1 Score |
|---|---|---|
| Laterality | 98.5% | 98.3% |
| Fundus Type | 96.7% | 96.4% |
| Artifacts | 94.2% | 93.8% |
| Clarity | 95.8% | 95.5% |
| Illumination | 93.9% | 93.6% |
| Contrast | 94.6% | 94.2% |
| Field | 92.8% | 92.4% |
| Usable | 96.1% | 95.9% |
1@software{retinaradar2025,
2 title={RetinaRadar: Multi-Label Retinal Image Quality Assessment},
3 author={Your Name},
4 year={2025},
5 url={https://huggingface.co/your-username/retinaradar}
6}