MohammedAlakhras commited on
Commit
07741c2
·
1 Parent(s): cb69aee

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import platform
2
+ import pathlib
3
+ plt = platform.system()
4
+ pathlib.WindowsPath = pathlib.PosixPath
5
+
6
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
7
+
8
+ # %% auto 0
9
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
10
+
11
+ # %% app.ipynb 1
12
+ from fastai.vision.all import *
13
+ import PIL.Image
14
+ PIL.Image.MAX_IMAGE_PIXELS = None
15
+ from PIL import Image
16
+
17
+ import gradio as gr
18
+
19
+ # %% app.ipynb 2
20
+ learn = load_learner('tumorClassifier.pkl')
21
+
22
+ # %% app.ipynb 3
23
+ categories=('COVID19','Normal','Pneumonia','Turberculosis')
24
+
25
+ def classify_image(img):
26
+ pred,indx,probs=learn.predict(img)
27
+ return dict(zip(categories,map(float,probs)))
28
+
29
+
30
+ # %% app.ipynb 4
31
+ image=gr.inputs.Image(shape=(512,512))
32
+ label=gr.outputs.Label()
33
+ examples=['1.jpeg', '2.jpg', '3.png','a.jpg','b.jpg','c.jpg','d.jpg','e.jpg','f.jpg']
34
+
35
+
36
+ interface=gr.Interface(fn=classify_image, inputs=image ,outputs=label,examples=examples)
37
+ interface.launch(inline=False)