Vinit710 commited on
Commit
41776fc
·
1 Parent(s): 29241c5

Add model and Gradio app

Browse files
Files changed (2) hide show
  1. app.py +19 -0
  2. cats_and_dogs_classifier.h5 +3 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from tensorflow.keras.models import load_model
3
+ from tensorflow.keras.preprocessing.image import img_to_array, load_img
4
+ import numpy as np
5
+
6
+ # Load your model (using a relative path)
7
+ model = load_model('cats_and_dogs_classifier.h5')
8
+
9
+ def predict(image):
10
+ img = image.resize((224, 224))
11
+ img = img_to_array(img)
12
+ img = np.expand_dims(img, axis=0)
13
+ prediction = model.predict(img)
14
+ class_label = 'cat' if prediction[0][0] < 0.5 else 'dog'
15
+ return class_label
16
+
17
+ # Create a Gradio interface
18
+ interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(type="pil"), outputs="text")
19
+ interface.launch()
cats_and_dogs_classifier.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c80f0f5aae24df553ba40ce004ec8ff803d4ff42a5075b26a795f3c34340bc6
3
+ size 41498088