Spaces:
Sleeping
Sleeping
| 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) |