CorneaUlcer / app.py
ccmscifair's picture
Update app.py
c12ca31 verified
raw
history blame
1.78 kB
# Version 1.0. Copyright Colleen Mahr 2025
import gradio as gr
from fastai.vision.all import *
import skimage
learn = load_learner('export.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
title = "Cornea Ulcer Image Classifier"
description = "Version 1.0. Copyright Colleen Mahr 2025"
article_text = "This machine learning image classifier was trained on publicly available external eye photos "
article_text = article_text + "beginning with the ResNet152 convolutional neural network (https://arxiv.org/abs/1512.03385) pre-trained foundation."
article_text = article_text + "It is not medical advice. If you have medical concerns, seek professional medical help immediately. "
article_text = article_text + "You can upload an external eye photo and it will return an AI prediction of the probability of "
article_text = article_text + "a corneal ulcer being present. This AI cornea ulcer classifier has 97% accuracy on both training and previously unseen test images."
article_text = article_text + "Here is a link to additional information about corneal ulcers: "
article_text = article_text + "www.aao.org/eye-health/diseases/corneal-ulcer "
article = article_text
examples = ['examplecorneaulcer.jpeg','exampleconjunctivitisnocorneaulcer.jpeg','examplenormaleye.jpeg']
interpretation = 'default'
enable_queue = True
demo = gr.Interface(
fn=predict,
inputs=gr.Image(height = 512, width = 512),
outputs=gr.Label(num_top_classes=2),
title=title,
description=description,
article=article,
examples=examples,
#interpretation='default',
#enable_queue=enable_queue
)
demo.launch(share = True)