|
import gradio as gr |
|
import tensorflow as tf |
|
import numpy as np |
|
from PIL import Image |
|
import tensorflow.keras as keras |
|
|
|
from tensorflow.keras.models import load_model |
|
|
|
|
|
model = load_model('mmodel.h5') |
|
|
|
classnames = ['Pikachu','Raichu','Pichu'] |
|
|
|
|
|
|
|
def predict_image(img): |
|
img_4d=img.reshape(-1,224, 224,3) |
|
prediction=model.predict(img_4d)[0] |
|
return {classnames[i]: float(prediction[i]) for i in range(3)} |
|
|
|
|
|
|
|
image = gr.inputs.Image(shape=(224, 224)) |
|
label = gr.outputs.Label(num_top_classes=3) |
|
|
|
|
|
gr.Interface(fn=predict_image, inputs=image, title="Garbage Classifier V3", |
|
description="ThiFaces using Gradio.",outputs=label,enable_queue=True,interpretation='default').launch() |