File size: 960 Bytes
bcfc921
 
 
 
 
 
8d24c08
b509c08
0d1ab03
b548b33
bcfc921
 
 
 
 
 
 
 
 
 
 
 
 
 
f8ad5ab
b548b33
 
8d24c08
b548b33
bcfc921
 
7bc0e85
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
30
31
32
from keras.models import load_model
import numpy as np
from keras.preprocessing import image
import gradio as gr
from PIL import Image

def show(img):    
    img = img.reshape( 64,64,3)
    model=load_model('./demo.h5')
    test_image=np.expand_dims(img, axis=0)    
    result=model.predict(test_image)
    if result[0][0]==1:
        prediction='Dog'
        print(prediction)
        return prediction
    else:
        prediction='Cat'
        print(prediction)
        return prediction
 

input = gr.inputs.Image(type='pil', label="Original Image", source="upload", optional=True)
inputs = [input]
outputs = gr.outputs.Image(type="pil", label="Output Image")
title = "Dog and Cat Image Classification"
image = gr.inputs.Image(shape=(64,64))

demo=gr.Interface(fn=show, inputs=image,examples=["photo/a01.jpg", "photo/a02.jpg","photo/a03.jpg","photo/a04.jpg"],title=title,outputs="text").launch(debug='True')


if __name__ == "__main__":
    demo.launch()