File size: 1,353 Bytes
92aa748
 
a2a5b20
92aa748
 
d444637
 
34917f7
42e38b7
 
 
 
 
34917f7
d444637
3b82920
42e38b7
741c74f
f825554
 
 
 
96f2bb3
f825554
1c07639
 
 
 
 
 
 
 
 
d444637
92aa748
 
d444637
b8f132d
187b87b
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
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
from fastai.vision.all import *
from efficientnet_pytorch import EfficientNet 


title = "COVID_19 Infection Detectation App!"
head = (
  "<div>"
    "This Space demonstrates model based on efficientnet base model. I has been trained to classify chest xray image." 
    " "
    "To test it, Use the Example Images Provided or Upload your own xray images the space provided."
    " "
    "The model is trained using [anasmohammedtahir/covidqu](https://www.kaggle.com/datasets/anasmohammedtahir/covidqu) dataset"  
  "</div>"
)
description = head

examples = [
    ['covid/covid_1038.png'], ['covid/covid_1034.png'], 
    ['covid/cd.png'], ['covid/covid_1021.png'], 
    ['covid/covid_1027.png'], ['covid/covid_1042.png'], 
    ['covid/covid_1031.png']
]

#learn = load_learner('model/predictcovidfastaifinal18102023.pkl')
learn = load_learner('model/final_20102023_eb7_model.pkl')

categories = learn.dls.vocab

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

interpretation="default"
enable_queue=True

gr.Interface(fn=predict_image, inputs=gr.Image(shape=(224,224)),
             outputs = gr.Label(num_top_classes=3),title=title,description=description,examples=examples, interpretation=interpretation,enable_queue=enable_queue).launch(share=False)