File size: 769 Bytes
f42669b
544aeaa
 
f42669b
 
 
 
aeffca2
f42669b
544aeaa
fa4978f
544aeaa
 
 
aeffca2
 
 
 
f42669b
952f5b1
544aeaa
f42669b
544aeaa
cc33b7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from tensorflow.keras.models import load_model
import gradio as gr
from PIL import Image
import numpy as np

model = load_model('Pikachu_and_Raichu.h5')

labels = ['Pikachu', 'Raichu']

def predict(img):
    img=img.reshape(160,160,3)
    """images_list = []
    images_list.append(np.array(img))
    x = np.asarray(images_list)"""
    #prediction = model.predict(img)[0]
    prediction = model.predict(img).flatten()
    confidences = {labels[i]: float(prediction[i]) for i in range(2)}
    return confidences

image = gr.inputs.Image(shape=(160, 160))
label = gr.outputs.Label(num_top_classes=2)

gr.Interface(fn=predict, inputs=image,  title="Garbage Classifier",
    description="Tradio.",outputs=label,interpretation='default').launch(debug=True,enable_queue=True)