File size: 869 Bytes
449d298
33871ce
5917c05
 
3d74340
5917c05
 
 
 
33871ce
 
3a1c44f
33871ce
 
5917c05
48133ea
 
1511c08
 
3ca229a
1511c08
3ca229a
33871ce
 
a088002
 
33871ce
a088002
3d74340
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub

loaded_model = tf.keras.models.load_model(
       ('CatDogmodel.h5'),
       custom_objects={'KerasLayer':hub.KerasLayer}
)

def model(image):
    
    im_scaled = image/255
    im_reshape = np.reshape(im_scaled,[1,224,224,3])
    pred = loaded_model.predict(im_reshape)
    cat_pred = pred
    dog_pred = 1-pred
    pred_label = np.argmax(pred)
    if (pred_label == 0):
        return "The Image is of a Dog."
    if (pred_label == 1):
        return "The Image is of a Cat."

image = gr.inputs.Image(shape=(224,224))
background='body{background-image:url("https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX35440124.jpg");}'
title = "Cat & Dog Classifier"

iface = gr.Interface(fn=model, inputs=image, outputs='text', css=background, title=title)
iface.launch(debug=True)