dag101 commited on
Commit
237cc09
·
1 Parent(s): bb98452
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -1,11 +1,10 @@
1
  #Importing necessary libraries
2
  import gradio as gr
3
- #import scikit-learn as sklearn
4
  from fastai.vision.all import *
5
  from sklearn.metrics import roc_auc_score
6
 
7
  #Define dependent functions
8
- def get_x(row): return Path(str(path/f"{row['rootname']}_small"/f"{row['ID']}") + ".png")
9
  def get_y(row): return row["LABEL"]
10
 
11
  def auroc_score(input, target):
@@ -15,31 +14,43 @@ def auroc_score(input, target):
15
  #Load the model
16
  learn = load_learner("export.pkl")
17
 
18
- #Identify labels from the dataloaders class
19
  labels = ["Negative", "Positive"]
20
 
21
  #Define function for making prediction
22
  def predict(img):
23
- img = PILImage.create(img)
24
  pred, idx, probs = learn.predict(img)
25
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
26
 
27
- #Customizing the gradio interface
28
- title = "Ethiopian based Tuberculosis(TB) model"
 
 
 
29
 
30
- description = """e"""
 
 
31
 
32
- article="<p style='text-align: center'><a href='https' target='_blank'>n</a></p>"
 
 
 
33
 
34
- examples = ['patient1.png', 'patient2.png', 'patient3.png']
 
 
35
 
 
36
  enable_queue=True
37
 
38
-
39
- #Launching the gradio application
40
- gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),
41
- outputs=gr.outputs.Label(num_top_classes=1),
42
  title=title,
43
- description=description,article=article,
44
  examples=examples,
45
- enable_queue=enable_queue).launch(inline=False)
 
 
1
  #Importing necessary libraries
2
  import gradio as gr
 
3
  from fastai.vision.all import *
4
  from sklearn.metrics import roc_auc_score
5
 
6
  #Define dependent functions
7
+ def get_x(row): return Path(str(path/f"{row['rootname']}_small"/f"{row['ID']}") + ".png")
8
  def get_y(row): return row["LABEL"]
9
 
10
  def auroc_score(input, target):
 
14
  #Load the model
15
  learn = load_learner("export.pkl")
16
 
17
+ #Identify labels from the dataloaders class
18
  labels = ["Negative", "Positive"]
19
 
20
  #Define function for making prediction
21
  def predict(img):
22
+ img = PILImage.create(img)
23
  pred, idx, probs = learn.predict(img)
24
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
25
 
26
+ #Custom CSS
27
+ custom_css = """
28
+ body, button {
29
+ background-color: #00FBB9;
30
+ }
31
 
32
+ button {
33
+ color: #333;
34
+ }
35
 
36
+ p, span {
37
+ color: #333;
38
+ }
39
+ """
40
 
41
+ #Customizing the gradio interface
42
+ title = "Ethiopian based Tuberculosis(TB) model"
43
+ description = """Model to detect TB from chest x-rays"""
44
 
45
+ examples = ['patient1.png', 'patient2.png', 'patient3.png']
46
  enable_queue=True
47
 
48
+ #Launching the gradio interface
49
+ gr.Interface(fn=predict,
50
+ inputs=gr.inputs.Image(shape=(512, 512)),
51
+ outputs=gr.outputs.Label(num_top_classes=1),
52
  title=title,
53
+ description=description,
54
  examples=examples,
55
+ enable_queue=enable_queue,
56
+ css=custom_css).launch(inline=False)