create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""App.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1sSLrAgb1d83QPcQ4_UtxD86m0pS4i7s6
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
#|export
|
| 11 |
+
from fastai.vision.all import *
|
| 12 |
+
import gradio as gr
|
| 13 |
+
|
| 14 |
+
#|export
|
| 15 |
+
learn=load_learner('fracturedmodel.pkl')
|
| 16 |
+
|
| 17 |
+
#|export
|
| 18 |
+
categories=("This is a fractured bone.", "Bone does not appear to be broken.")
|
| 19 |
+
def classify_image(img):
|
| 20 |
+
pred,idx,probs=learn.predict(img)
|
| 21 |
+
return dict(zip(categories, map(float, probs)))
|
| 22 |
+
|
| 23 |
+
#|export
|
| 24 |
+
with gr.Blocks() as demo:
|
| 25 |
+
image = gr.Image(type="pil")
|
| 26 |
+
label = gr.Label()
|
| 27 |
+
examples = gr.Examples(['arm.png', 'hand.png'], image)
|
| 28 |
+
|
| 29 |
+
classify_btn = gr.Button("Diagnose")
|
| 30 |
+
classify_btn.click(fn=classify_image, inputs=image, outputs=label)
|
| 31 |
+
|
| 32 |
+
# Launch the interface
|
| 33 |
+
demo.launch(inline=False)
|