Addai commited on
Commit
0670066
·
verified ·
1 Parent(s): a835f6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -3,22 +3,27 @@ from fastai.vision.all import *
3
  import skimage
4
 
5
  learn = load_learner('export.pkl')
6
-
7
  labels = learn.dls.vocab
 
8
  def predict(img):
9
  img = PILImage.create(img)
10
- pred,pred_idx,probs = learn.predict(img)
11
- prediction = str(pred)
12
-
13
- return prediction
14
-
15
 
16
  title = "Breast cancer detection with Deep Transfer Learning(ResNet18)."
17
- description = "<p style='text-align: center<p>"
18
- article="<p style='text-align: center'>Web app is built and managed by Addai Fosberg<b></p>"
19
  examples = ['img1.jpeg', 'img2.jpeg']
20
- enable_queue=True
21
 
22
- #interpretation='default'
 
 
 
 
 
 
 
 
 
23
 
24
- gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,enable_queue=enable_queue).launch()
 
3
  import skimage
4
 
5
  learn = load_learner('export.pkl')
 
6
  labels = learn.dls.vocab
7
+
8
  def predict(img):
9
  img = PILImage.create(img)
10
+ pred, pred_idx, probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
 
 
12
 
13
  title = "Breast cancer detection with Deep Transfer Learning(ResNet18)."
14
+ description = "<p style='text-align: center'><b>As a radiologist or oncologist, it is crucial to know what is wrong with a breast x-ray image.</b><br><b>Upload the breast X-ray image to know what is wrong with a patient's breast with or without implant. This product is from the findings of my (Team) published research paper: <a href='https://iopscience.iop.org/article/10.1088/2057-1976/ad3cdf' target='_blank' style='color: blue;'>read paper</a>. Learn more about me: <a href='https://www.linkedin.com/in/fosberg-addai-53a6991a7/' target='_blank' style='color: blue;'>Fosberg Addai</a></b></p>"
15
+ article = "<p style='text-align: center'><b>Web app is built and managed by Addai Fosberg</b></p>"
16
  examples = ['img1.jpeg', 'img2.jpeg']
 
17
 
18
+ iface = gr.Interface(
19
+ fn=predict,
20
+ inputs=gr.Image(shape=(512, 512)),
21
+ outputs=gr.Label(num_top_classes=3),
22
+ title=title,
23
+ description=description,
24
+ article=article,
25
+ examples=examples,
26
+ enable_queue=True
27
+ )
28
 
29
+ iface.launch()