|
import os |
|
import gradio as gr |
|
import numpy as np |
|
from PIL import Image |
|
from tensorflow.keras.models import load_model |
|
from tensorflow.keras.preprocessing.image import img_to_array |
|
|
|
|
|
model_path = "IYRI1.h5" |
|
|
|
|
|
model = load_model(model_path) |
|
|
|
class_names = ["Cat", "Dog"] |
|
def predict_input_image(img): |
|
img_4d=img.reshape(-1,100,100,3) |
|
prediction=model.predict(img_4d)[0] |
|
return {class_names[i]: float(prediction[i]) for i in range(2)} |
|
image = gr.inputs.Image(shape=(100,100)) |
|
label = gr.outputs.Label(num_top_classes=2) |
|
|
|
iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title="IYRI Classifier 1",interpretation='default').launch(debug='True') |
|
|
|
|
|
iface.launch() |