File size: 593 Bytes
b2d7ff1
4eb83e3
3c39a65
 
4eb83e3
b2d7ff1
 
 
 
3c39a65
 
1bb8f5e
 
 
 
b2d7ff1
 
 
 
1bb8f5e
 
b2d7ff1
 
 
 
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
import gradio as gr
import tensorflow
import numpy
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import load_model

model = load_model('vgg_model.keras')

def predict(img):
    img = image.img_to_array(img)
    img = numpy.expand_dims(img, axis=0)
    img = img.reshape((-1, 150, 150, 3))
    prediction = model.predict(img)
    confidences = {"Cat": float(prediction[0]), 'Dog': float(prediction[1])}
    return confidences


demo = gr.Interface(
    fn=predict,
    inputs=gr.Image(shape=(150, 150)),
    outputs=gr.Label(num_top_classes=2),
)


demo.launch()