Jamshaid89 commited on
Commit
f16f975
1 Parent(s): 4a7b7f4

added model

Browse files
Files changed (2) hide show
  1. app.py +31 -4
  2. cat_dog_recognition.h5 +3 -0
app.py CHANGED
@@ -1,7 +1,34 @@
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
  import gradio as gr
2
+ import tensorflow as tf
3
 
4
+ # def greet(name):
5
+ # return "Hello " + name + "!!"
6
 
7
+ def predict_image(image):
8
+ # Preprocess the image
9
+ image = image.reshape((1, 160, 160, 3))
10
+
11
+ model = tf.keras.models.load_model('./cat_dog_recognition.h5')
12
+
13
+ # Make prediction
14
+ pred = model.predict(image)
15
+
16
+ predicted_label = "Dog " + str(pred[0])
17
+ if pred >= 0.5:
18
+ predicted_label = "Cat " + str(pred[0])
19
+
20
+ # Return the predicted label
21
+ return f"Predicted Label: {predicted_label}"
22
+
23
+
24
+
25
+ # input_image = [gr.components.Image(type="filepath" , label="Input Image"),]
26
+
27
+ # iface = gr.Interface(fn=detect, inputs=input_image, outputs="text" , title="Cat vs Dog Detector")
28
+ # iface.launch()
29
+
30
+ image_input = gr.inputs.Image(shape=(160,160))
31
+ label_output = gr.outputs.Textbox()
32
+
33
+ # Create the Gradio interface
34
+ gr.Interface(fn=predict_image, inputs=image_input, outputs=label_output).launch()
cat_dog_recognition.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e521bd487a0f1c3e98fe0b0b36fd676e5f442dfed747780425e86b3fc3649067
3
+ size 250489304