File size: 927 Bytes
b7243ec
 
 
 
93dd1a5
b7243ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('model_novo.h5')

categories = ('Cancer', 'Normal')
#labels = learn.dls.vocab

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

#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 = "Breast Cancer Detection"
description = "A breast cancer detection trained on small dataset, from RSNA Challenge, with fastai. Created as a demo for Gradio and HuggingFace Spaces."
image = gr.inputs.Image()
label = gr.outputs.Label()
examples = ['Cancer.png']
interpretation = 'lime'

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