adiyamasoora01's picture
Update app.py
9968120 verified
Raw
History Blame Contribute Delete
697 Bytes
import gradio as gr
import numpy as np
from keras.models import load_model
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
# load model
model = load_model("intel_model.keras")
# class labels (same order as training)
class_labels = ['buildings', 'forest', 'glacier', 'mountain', 'sea', 'street']
def predict(img):
img = img.resize((150,150))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
pred = model.predict(img_array)
return class_labels[np.argmax(pred)]
# UI
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs="label",
title="Intel Image Classifier"
).launch()