M. Saad Munawar
commited on
Commit
•
4d4b238
1
Parent(s):
3ddbe9e
https://huggingface.co/spaces/Saad123/minima
Browse files- CatDogmodel2.h5 +3 -0
- app.py +22 -4
- requirements.txt +4 -0
CatDogmodel2.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3fdef209df3115267f8318110fc0c814c927d2f7fd3fb7a7a7f893e42690d064
|
3 |
+
size 87673584
|
app.py
CHANGED
@@ -1,6 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
import tensorflow as tf
|
4 |
+
import tensorflow_hub as hub
|
5 |
|
6 |
+
loaded_model = tf.keras.models.load_model(
|
7 |
+
('CatDogmodel2.h5'),
|
8 |
+
custom_objects={'KerasLayer':hub.KerasLayer}
|
9 |
+
)
|
10 |
+
|
11 |
+
def model(image):
|
12 |
+
im_scaled = image/255
|
13 |
+
im_reshape = np.reshape(im_scaled,[1,160,160,3])
|
14 |
+
pred = loaded_model.predict(im_reshape)
|
15 |
+
pred_label = np.argmax(pred)
|
16 |
+
if (pred_label == 0):
|
17 |
+
return "The Image is of a Dog."
|
18 |
+
if (pred_label == 1):
|
19 |
+
return "The Image is of a Cat."
|
20 |
+
|
21 |
+
image = gr.inputs.Image(shape=(160,160))
|
22 |
+
|
23 |
+
iface = gr.Interface(fn=model, inputs=image, outputs='text')
|
24 |
+
iface.launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.1.7
|
2 |
+
numpy==1.21.5
|
3 |
+
tensorflow==2.9.1
|
4 |
+
tensorflow_hub==0.12.0
|