IYRIProject1 / app.py
vmath's picture
Create app.py
4a4fafb
raw
history blame contribute delete
778 Bytes
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()