DLA_projects / app.py
BharathyVinothKumar's picture
app.py
8b56f43 verified
Raw History Blame Contribute Delete
465 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load model
model = tf.keras.models.load_model("model.h5")
# Prediction function
def predict(image):
image = image.resize((48,48)) # change size if needed
image = np.array(image)/255.0
image = np.expand_dims(image, axis=0)
pred = model.predict(image)
return str(np.argmax(pred))
# UI
gr.Interface(fn=predict, inputs="image", outputs="text").launch()