File size: 934 Bytes
f31353f
43af43a
728103f
 
43af43a
f31353f
43af43a
f31353f
 
 
 
 
 
 
 
 
39e5c71
b37f678
39e5c71
f31353f
39e5c71
f31353f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastai.vision.all import *
import gradio as gr
import pathlib
pathlib.WindowsPath = pathlib.PosixPath

learn = load_learner("export.pkl")

categories = ('CT', 'MRI', "Ultrasound", "X-Ray")

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

image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['mri.jpg','ct.jpg','ultrasound.jpg', 'xray.jpg']
title = 'Medical Image Classifier'
description = 'You need to know whether you are dealing with an MRI , X-Ray, CT, or Ultrasound image, and you need an answer fast? Then you have come to the right place. Upload the picture to classify it.'
article = "Author: <a href=\"https://huggingface.co/archietram\">Archie Tram</a>. "

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