File size: 717 Bytes
fe39c62
94953c9
a81bf1c
 
1d9e018
a81bf1c
94953c9
 
 
 
 
 
b69b22d
 
4cd218e
 
 
94953c9
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastai.vision.all import *
from fastai.data.external import *
import gradio as gr

learn = load_learner('lung.pkl')

categories = ('ACA', 'Benign', 'SCC')

def classify_image(img):
    pred,idx,probs = learn.predict(img)
    return dict(zip(categories, map(float,probs)))

image = gr.components.Image(shape=(768, 768))
label = gr.components.Label()
examples = ['lungaca.jpeg', 'lungaca142.jpeg', 'lungaca199.jpeg', 'lungaca861.jpeg',
             'lungn.jpeg', 'lungn159.jpeg', 'lungn380.jpeg', 'lungn633.jpeg', 
             'lungscc.jpeg', 'lungscc958.jpeg', 'lungscc626.jpeg', 'lungscc344.jpeg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)