CorneaUlcer / app.py
ccmscifair's picture
Update app.py
e6bbb19 verified
# 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 - Rochester, MN STEM Fair"
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
html_article = "<div><p>This machine learning image classifier was trained on publicly available external eye photos beginning with the ResNet152 convolutional neural network (<a href='https://arxiv.org/abs/1512.03385'>https://arxiv.org/abs/1512.03385</a>) pre-trained foundation. It is not medical advice. If you have medical concerns, seek professional medical help immediately. You can upload an external eye photo and it will return an AI prediction of the probability of a corneal ulcer being present. This AI cornea ulcer classifier has 97% accuracy on both training and previously unseen test images. Here is a link to additional information about corneal ulcers:&nbsp;<a href='http://www.aao.org/eye-health/diseases/corneal-ulcer'>www.aao.org/eye-health/diseases/corneal-ulcer</a></p></div>"
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=html_article,
examples=examples,
#interpretation='default',
#enable_queue=enable_queue
)
demo.launch(share = True)