Spaces:
Sleeping
Sleeping
File size: 1,100 Bytes
722fcb5 3092c67 5ab7af2 70d7e2d 3092c67 8180fc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import gradio as gr
from huggingface_hub import hf_hub_download
from fastai.learner import load_learner
repo_id = "ethanmac/dr-macbloomber-retina-condition-classifier"
model = load_learner(
hf_hub_download(repo_id, "model.pkl")
)
class_names = [
'Normal',
'Hollenhorst Emboli',
'Hypertensive Retinopathy',
'Coat\'s',
'Macroaneurism',
'Choroidal Neovascularization',
'Other',
'Branch Retinal Artery Occlusion',
'Cilio-Retinal Artery Occlusion',
'Branch Retinal Vein Occlusion',
'Central Retinal Vein Occlusion',
'Hemi-Central Retinal Vein Occlusion',
'Background Diabetic Retinopathy',
'Proliferative Diabetic Retinopathy',
'Arteriosclerotic Retinopathy'
]
categories = [c.replace('_', ' ').title() for c in class_names]
def classify_image(img):
pred, idx, probs = model.predict(img)
out = dict(zip(categories, map(float, probs)))
return out
intf = gr.Interface(
fn=classify_image,
inputs=gr.Image(),
outputs=gr.Label(num_top_classes=5),
title="Retinal Image Condition Classifier",
examples=['healthy.jpg', 'crvo.jpg']
)
intf.launch(inline=False, share=True) |