Spaces:
Runtime error
Runtime error
jacquelinegrimm
commited on
Commit
•
67151f3
1
Parent(s):
787b4ea
Update app.py
Browse files
app.py
CHANGED
@@ -8,18 +8,19 @@ subprocess.run(['pip', 'install', '-Uqq', 'timm'])
|
|
8 |
from fastai.vision.all import *
|
9 |
import gradio as gr
|
10 |
|
11 |
-
|
|
|
12 |
|
13 |
learn = load_learner('model.pkl')
|
14 |
|
15 |
-
|
16 |
-
categories = ('No Finding', 'Obstructive Pulmonary Disease', 'Pneumonia')
|
17 |
|
|
|
18 |
def classify_image(img):
|
19 |
pred,idx,probs = learn.predict(img)
|
20 |
return dict(zip(categories, map(float,probs)))
|
21 |
|
22 |
-
#
|
23 |
examples = ['normal.jpeg', 'obs.jpeg', 'pneu.jpeg']
|
24 |
intf = gr.Interface(fn=classify_image, inputs='image', outputs='label', examples=examples)
|
25 |
intf.launch(inline=False)
|
|
|
8 |
from fastai.vision.all import *
|
9 |
import gradio as gr
|
10 |
|
11 |
+
# Define a custom label function
|
12 |
+
def diagnosis(x): return x[0].isupper()
|
13 |
|
14 |
learn = load_learner('model.pkl')
|
15 |
|
16 |
+
categories = ('Degenerative Infectious Disease', 'Mediastinal Anomalies', 'No Finding', 'Obstructive Pulmonary Disease', 'Pneumonia')
|
|
|
17 |
|
18 |
+
# Function that predicts an image's category and returns a dictionary mapping categories to their probabilities
|
19 |
def classify_image(img):
|
20 |
pred,idx,probs = learn.predict(img)
|
21 |
return dict(zip(categories, map(float,probs)))
|
22 |
|
23 |
+
# Create and launch a Gradio interface, allowing interactive image classification
|
24 |
examples = ['normal.jpeg', 'obs.jpeg', 'pneu.jpeg']
|
25 |
intf = gr.Interface(fn=classify_image, inputs='image', outputs='label', examples=examples)
|
26 |
intf.launch(inline=False)
|