M. Saad Munawar commited on
Commit
4285f36
1 Parent(s): 449d298

https://huggingface.co/spaces/Saad123/minimal

Browse files
Files changed (2) hide show
  1. app.py +22 -4
  2. requirements.txt +9 -0
app.py CHANGED
@@ -1,7 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
1
+ from fastai.vision.all import *
2
+ import pathlib
3
+ import numpy as np
4
+ import cv2
5
+ from PIL import image
6
+
7
+ plt = platform.system()
8
+ if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
9
+ learn=load_learner("CatvsDogmodel.pkl")
10
+ categories=('Cat','Dog')
11
+ def classify_image(img):
12
+ pred, idx, probs = learn.predict(img)
13
+ return dict(zip(categories, map(float,probs)))
14
  import gradio as gr
15
+ image=gr.inputs.Image(shape=(224, 224))
16
+
17
+ image = cv2.imread(image)
18
+ Image.open(image)
19
+ image = image/255
20
+ image = np.reshape(image, [1,224,224,3])
21
 
 
 
22
 
23
+ label=gr.outputs.Label()
24
+ intf=gr.Interface(fn=classify_image, inputs=image, outputs=label)
25
+ intf.launch(inline=False)
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ numpy
2
+ matplotlib.pyplot
3
+ tensorflow
4
+ tensorflow_hub
5
+ cv2
6
+ PIL
7
+ Image
8
+ pickle
9
+ gradio