Spaces:
Runtime error
Runtime error
SalmanAboAraj
commited on
Commit
•
9de8244
1
Parent(s):
91578a7
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import platform
|
2 |
+
import pathlib
|
3 |
+
plt = platform.system()
|
4 |
+
pathlib.WindowsPath = pathlib.PosixPath
|
5 |
+
|
6 |
+
|
7 |
+
import requests
|
8 |
+
|
9 |
+
|
10 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
11 |
+
|
12 |
+
# %% auto 0
|
13 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
|
14 |
+
|
15 |
+
# %% app.ipynb 1
|
16 |
+
from fastai.vision.all import *
|
17 |
+
import PIL.Image
|
18 |
+
PIL.Image.MAX_IMAGE_PIXELS = None
|
19 |
+
from PIL import Image
|
20 |
+
|
21 |
+
import gradio as gr
|
22 |
+
|
23 |
+
# %% app.ipynb 2
|
24 |
+
learn = load_learner('Binarymodel.pkl')
|
25 |
+
|
26 |
+
# %% app.ipynb 3
|
27 |
+
categories=('Random','X_ray')
|
28 |
+
|
29 |
+
def classify_image(img):
|
30 |
+
pred,indx,probs=learn.predict(img)
|
31 |
+
return dict(zip(categories,map(float,probs)))
|
32 |
+
|
33 |
+
|
34 |
+
# %% app.ipynb 4
|
35 |
+
image=gr.inputs.Image(shape=(512,512))
|
36 |
+
label=gr.outputs.Label()
|
37 |
+
examples=['1.jpeg','10.png','2.png','9.jpeg','3.jpeg','4.jpeg','5.jpeg','6.jpeg','7.jpeg',
|
38 |
+
'8.jpeg','9.jpeg','b.jpeg','d.jpeg','f.jpg','e.jpg']
|
39 |
+
|
40 |
+
|
41 |
+
interface=gr.Interface(fn=classify_image, inputs=image ,outputs=label,examples=examples)
|
42 |
+
interface.launch(inline=False)
|