File size: 778 Bytes
4a4fafb |
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 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
# Define the paths and filenames
model_path = "IYRI1.h5"
# Load the model and label encoder
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')
# Run the Gradio interface
iface.launch() |