M. Saad Munawar commited on
Commit
3d74340
1 Parent(s): 33871ce

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

Browse files
Files changed (2) hide show
  1. app.py +10 -3
  2. requirements.txt +0 -2
app.py CHANGED
@@ -1,12 +1,19 @@
1
  import gradio as gr
2
  import numpy as np
 
 
 
3
 
4
  def model(image):
5
  im_scaled = image/255
6
  im_reshape = np.reshape(im_scaled,[1,224,224,3])
7
- return im_reshape
 
 
 
 
8
 
9
  image = gr.inputs.Image(shape=(224,224))
10
 
11
- iface = gr.Interface(fn=model, inputs=image, outputs='numpy')
12
- iface.launch()
 
1
  import gradio as gr
2
  import numpy as np
3
+ from fastai.vision.all import *
4
+
5
+ classifier=load_learner("CatvsDogmodel.pkl")
6
 
7
  def model(image):
8
  im_scaled = image/255
9
  im_reshape = np.reshape(im_scaled,[1,224,224,3])
10
+ pred = classifier.predict(im_reshape)
11
+ if (pred == 0):
12
+ return "The Image is of a Dog."
13
+ if (pred == 1):
14
+ return "The Image is of a Cat."
15
 
16
  image = gr.inputs.Image(shape=(224,224))
17
 
18
+ iface = gr.Interface(fn=model, inputs=image, outputs='text')
19
+ iface.launch(debug=True)
requirements.txt CHANGED
@@ -1,5 +1,3 @@
1
  fastai==2.7.9
2
  gradio==3.1.7
3
  numpy==1.21.5
4
- opencv_python==4.6.0.66
5
- Pillow==9.2.0
 
1
  fastai==2.7.9
2
  gradio==3.1.7
3
  numpy==1.21.5