Josephus67 commited on
Commit
5d6feb4
·
verified ·
1 Parent(s): a77e640

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +22 -0
  2. dogcat_model.h5 +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ # Load model
7
+ model = tf.keras.models.load_model("dogcat_model.h5")
8
+
9
+ def predict(image):
10
+ image = image.convert("RGB").resize((224,224))
11
+ image = np.array(image) / 255.0
12
+ image = np.expand_dims(image, axis=0)
13
+ pred = model.predict(image)[0][0]
14
+ return {"Cat": float(1-pred), "Dog": float(pred)}
15
+
16
+ iface = gr.Interface(
17
+ fn=predict,
18
+ inputs=gr.Image(type="pil"),
19
+ outputs=gr.Label(num_top_classes=2)
20
+ )
21
+
22
+ iface.launch()
dogcat_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc8f0df68b4d988bcf4a8b0f999d557c7715fe825d5477a1ecac4c0536656e85
3
+ size 231224216
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tensorflow
2
+ gradio
3
+ numpy
4
+ pillow