Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
|
7 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from tensorflow.keras.preprocessing import image
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import numpy as np
|
6 |
+
model = tf.keras.models.load_model('dogcat_model_bak.h5')
|
7 |
+
def image_classifier(img):
|
8 |
+
img1 = image.load_img(img, target_size=(64, 64))
|
9 |
+
img1 = image.img_to_array(img1)
|
10 |
+
img1 = img1/255
|
11 |
+
img1 = np.expand_dims(img1, axis=0)
|
12 |
+
res = model.predict(img, batch_size=None,steps=1)
|
13 |
+
if(res[:,:]>0.5):
|
14 |
+
value ='Dog :%1.2f'%(prediction[0,0])
|
15 |
+
else:
|
16 |
+
value ='Cat :%1.2f'%(1.0-prediction[0,0])
|
17 |
+
return value
|
18 |
|
19 |
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
|
20 |
demo.launch()
|