diagnose / app.py
tlmdesign's picture
Update app.py
aec589b verified
# -*- coding: utf-8 -*-
"""App.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1sSLrAgb1d83QPcQ4_UtxD86m0pS4i7s6
"""
#|export
from fastai.vision.all import *
import gradio as gr
#|export
learn=load_learner('fracturedmodel.pkl')
#|export
categories=("This is a fractured bone.", "Bone does not appear to be fractured.")
def classify_image(img):
pred,idx,probs=learn.predict(img)
return dict(zip(categories, map(float, probs)))
#|export
with gr.Blocks(theme='Nymbo/Alyx_Theme') as demo:
gr.Markdown( """
# Radiology Report
Upload your xray to create a radiology report.
""")
image = gr.Image(type="pil",label="Upload your x-ray")
classify_btn = gr.Button("Create Report")
label = gr.Label(label="Radiology Report")
examples = gr.Examples(['arm.png', 'hand.png', 'broken1.jpg','nbroken1.jpg'], image)
classify_btn.click(fn=classify_image, inputs=image, outputs=label)
# Launch the interface
demo.launch(inline=False)